Merge pull request 'bổ sung migrate' (#47) from Sprint-4/MS-35-BE-Technical into master

Reviewed-on: #47
This commit is contained in:
vincent.vo 2024-09-19 18:47:51 +10:00
commit a11861efb1
3 changed files with 65 additions and 2 deletions

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('technicals', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->unsignedTinyInteger('level')->nullable(); // Level từ 1-3, cho phép null
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('technicals');
}
};

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('technicals_users', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users')->onDelete('cascade'); // Khóa ngoại tới bảng users
$table->foreignId('technical_id')->constrained('technicals')->onDelete('cascade'); // Khóa ngoại tới bảng technicals
$table->unsignedTinyInteger('point')->default(0); // Điểm từ 0-3, mặc định 0
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('technicals_users');
}
};

View File

@ -29,7 +29,7 @@ interface TableRow {
criteria: string
note: string
createdBy: string
point: string
point: number
}
interface ExpandedProjects {
@ -62,7 +62,7 @@ const CriteriaTable = ({ data }: { data: TableRow[] }) => (
<Table.Td style={{ textAlign: 'start' }}>{row.criteria}</Table.Td>
<Table.Td style={{ textAlign: 'start' }}>{row.note}</Table.Td>
<Table.Td style={{ textAlign: 'start' }}>{row.createdBy}</Table.Td>
<Table.Td>{row.point}</Table.Td>
<Table.Td>{row.point == 0 ? '' : row.point}</Table.Td>
</Table.Tr>
))}
</Table.Tbody>