add relationships
Tests & Lint & Deploy to Railway / build (2.6.6, 20.x, 8.3) (push) Has been cancelled
Details
Tests & Lint & Deploy to Railway / build (2.6.6, 20.x, 8.3) (push) Has been cancelled
Details
This commit is contained in:
parent
1e66821452
commit
f23b2e8652
|
@ -4,6 +4,7 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Department extends Model
|
||||
{
|
||||
|
@ -14,4 +15,14 @@ class Department extends Model
|
|||
'name',
|
||||
'created_by_id',
|
||||
];
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
public function projects(): HasMany
|
||||
{
|
||||
return $this->hasMany(Project::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Project extends Model
|
||||
{
|
||||
|
@ -16,4 +18,13 @@ class Project extends Model
|
|||
'department_id',
|
||||
'created_by_id',
|
||||
];
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\DepartmentController;
|
||||
use App\Http\Controllers\LabelController;
|
||||
use App\Http\Controllers\ProfileController;
|
||||
use App\Http\Controllers\ProjectController;
|
||||
use App\Http\Controllers\TaskController;
|
||||
use App\Http\Controllers\TaskStatusesController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
@ -22,6 +24,8 @@ Route::middleware('auth')->group(function () {
|
|||
|
||||
Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () {
|
||||
Route::resources([
|
||||
'/departments' => DepartmentController::class,
|
||||
'/projects' => ProjectController::class,
|
||||
'/tasks' => TaskController::class,
|
||||
'/labels' => LabelController::class,
|
||||
'/task_statuses' => TaskStatusesController::class,
|
||||
|
|
Loading…
Reference in New Issue