add assigned to Tasks
Tests & Lint & Deploy to Railway / build (2.6.6, 20.x, 8.3) (push) Failing after 3m57s Details

This commit is contained in:
aslan 2024-06-11 13:17:26 +03:00
parent 9e618d9ba5
commit aaa33ac58d
3 changed files with 29 additions and 2 deletions

View File

@ -27,6 +27,11 @@ class Task extends Model
return $this->belongsTo(User::class, 'created_by_id'); return $this->belongsTo(User::class, 'created_by_id');
} }
public function assigned(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
public function status(): BelongsTo public function status(): BelongsTo
{ {
return $this->belongsTo(TaskStatus::class); return $this->belongsTo(TaskStatus::class);

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('task_user', function (Blueprint $table) {
$table->foreignId('task_id')->constrained('tasks');
$table->foreignId('user_id')->constrained('users');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('task_user');
}
};

View File

@ -18,7 +18,7 @@
@foreach($tasks as $task) @foreach($tasks as $task)
<tr> <tr>
<th scope="row">{{ $task->id }}</th> <th scope="row">{{ $task->id }}</th>
<td>{{ $task->department->name }}</td> <td>{{ $task->department }}</td>
<td>{{ $task->name }} <td>{{ $task->name }}
<br> <br>
@foreach($task->labels as $label) @foreach($task->labels as $label)
@ -28,7 +28,7 @@
<td>{{ $task->status->name }}</td> <td>{{ $task->status->name }}</td>
<td>{{ $task->creator->name }}</td> <td>{{ $task->creator->name }}</td>
<td> <td>
@foreach($task->users as $user) @foreach($task->assigned as $user)
{{ $user->name }}<br> {{ $user->name }}<br>
@endforeach @endforeach
</td> </td>