add field project_id to label
Tests & Lint & Deploy to Railway / build (2.6.6, 20.x, 8.3) (push) Has been cancelled Details

This commit is contained in:
aslan 2024-05-29 16:18:46 +03:00
parent 474a2ae4e1
commit 8969b67af8
4 changed files with 12 additions and 0 deletions

View File

@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Label extends Model
{
@ -15,4 +16,9 @@ class Label extends Model
'department_id',
'created_by_id',
];
public function tasks(): BelongsToMany
{
return $this->belongsToMany(Task::class);
}
}

View File

@ -10,6 +10,7 @@ class LabelFactory extends Factory
{
return [
'name' => fake()->name(),
'project_id' => 1,
];
}
}

View File

@ -11,6 +11,7 @@ return new class extends Migration
Schema::create('labels', function (Blueprint $table) {
$table->id();
$table->string('name', 255);
$table->foreignId('project_id')->constrained('projects');
$table->timestamps();
});
}

View File

@ -14,18 +14,22 @@ class LabelSeeder extends Seeder
DB::table('labels')->insert([
[
'name' => 'ошибка',
'project_id' => 1,
'created_at' => Carbon::now(),
],
[
'name' => 'документация',
'project_id' => 1,
'created_at' => Carbon::now(),
],
[
'name' => 'дубликат',
'project_id' => 1,
'created_at' => Carbon::now(),
],
[
'name' => 'доработка',
'project_id' => 1,
'created_at' => Carbon::now(),
],
]);