From c77e9bb3dc3af2296d33e7fa93cb4310813aed47 Mon Sep 17 00:00:00 2001 From: Bosun18 Date: Wed, 7 Feb 2024 16:16:26 +0300 Subject: [PATCH] update project --- app/Http/Controllers/LabelController.php | 20 ++++++++------------ app/Http/Controllers/TaskController.php | 24 +++++++++--------------- app/Models/User.php | 8 -------- app/Policies/TaskPolicy.php | 1 - 4 files changed, 17 insertions(+), 36 deletions(-) diff --git a/app/Http/Controllers/LabelController.php b/app/Http/Controllers/LabelController.php index 773e508..fffbbca 100644 --- a/app/Http/Controllers/LabelController.php +++ b/app/Http/Controllers/LabelController.php @@ -5,6 +5,8 @@ use App\Models\Label; use App\Http\Requests\StoreLabelRequest; use App\Http\Requests\UpdateLabelRequest; +use Illuminate\Contracts\View\View; +use Illuminate\Http\RedirectResponse; class LabelController extends Controller { @@ -15,9 +17,7 @@ public function __construct() /** * Display a listing of the resource. */ - public function index(): \Illuminate\Contracts\View\View| - \Illuminate\Foundation\Application| - \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application + public function index(): View { $labels = Label::all(); return view('Label.index', compact('labels')); @@ -26,9 +26,7 @@ public function index(): \Illuminate\Contracts\View\View| /** * Show the form for creating a new resource. */ - public function create(): \Illuminate\Contracts\View\View| - \Illuminate\Foundation\Application| - \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application + public function create(): View { $label = new Label(); return view('Label.create', compact('label')); @@ -37,7 +35,7 @@ public function create(): \Illuminate\Contracts\View\View| /** * Store a newly created resource in storage. */ - public function store(StoreLabelRequest $request): \Illuminate\Http\RedirectResponse + public function store(StoreLabelRequest $request): RedirectResponse { $data = $request->validated(); @@ -51,9 +49,7 @@ public function store(StoreLabelRequest $request): \Illuminate\Http\RedirectResp /** * Show the form for editing the specified resource. */ - public function edit(Label $label): \Illuminate\Contracts\View\View| - \Illuminate\Foundation\Application| - \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application + public function edit(Label $label): View { return view('Label.edit', compact('label')); } @@ -61,7 +57,7 @@ public function edit(Label $label): \Illuminate\Contracts\View\View| /** * Update the specified resource in storage. */ - public function update(UpdateLabelRequest $request, Label $label): \Illuminate\Http\RedirectResponse + public function update(UpdateLabelRequest $request, Label $label): RedirectResponse { $data = $request->validated(); @@ -75,7 +71,7 @@ public function update(UpdateLabelRequest $request, Label $label): \Illuminate\H /** * Remove the specified resource from storage. */ - public function destroy(Label $label): \Illuminate\Http\RedirectResponse + public function destroy(Label $label): RedirectResponse { if ($label->tasks()->exists()) { flash(__('messages.label.deleted.error'))->error(); diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index 0ab500e..5cada5e 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -3,6 +3,8 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use Illuminate\Contracts\View\View; +use Illuminate\Http\RedirectResponse; use App\Models\Task; use Spatie\QueryBuilder\QueryBuilder; use Spatie\QueryBuilder\AllowedFilter; @@ -21,9 +23,7 @@ public function __construct() /** * Display a listing of the resource. */ - public function index(Request $request): \Illuminate\Contracts\View\View| - \Illuminate\Foundation\Application| - \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application + public function index(Request $request): View { $users = User::pluck('name', 'id')->all(); @@ -47,9 +47,7 @@ public function index(Request $request): \Illuminate\Contracts\View\View| /** * Show the form for creating a new resource. */ - public function create(): \Illuminate\Contracts\View\View| - \Illuminate\Foundation\Application| - \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application + public function create(): View { $taskStatuses = TaskStatus::select('name', 'id')->pluck('name', 'id'); $users = User::select('name', 'id')->pluck('name', 'id'); @@ -61,7 +59,7 @@ public function create(): \Illuminate\Contracts\View\View| /** * Store a newly created resource in storage. */ - public function store(StoreTaskRequest $request): \Illuminate\Http\RedirectResponse + public function store(StoreTaskRequest $request): RedirectResponse { $request->validated(); @@ -83,9 +81,7 @@ public function store(StoreTaskRequest $request): \Illuminate\Http\RedirectRespo /** * Display the specified resource. */ - public function show(Task $task): \Illuminate\Contracts\View\View| - \Illuminate\Foundation\Application| - \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application + public function show(Task $task): View { $labels = $task->labels; @@ -95,9 +91,7 @@ public function show(Task $task): \Illuminate\Contracts\View\View| /** * Show the form for editing the specified resource. */ - public function edit(Task $task): \Illuminate\Contracts\View\View| - \Illuminate\Foundation\Application| - \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application + public function edit(Task $task): View { $taskStatuses = TaskStatus::all(); $users = User::select('name', 'id')->pluck('name', 'id'); @@ -110,7 +104,7 @@ public function edit(Task $task): \Illuminate\Contracts\View\View| /** * Update the specified resource in storage. */ - public function update(UpdateTaskRequest $request, Task $task): \Illuminate\Http\RedirectResponse + public function update(UpdateTaskRequest $request, Task $task): RedirectResponse { $request->validated(); @@ -131,7 +125,7 @@ public function update(UpdateTaskRequest $request, Task $task): \Illuminate\Http /** * Remove the specified resource from storage. */ - public function destroy(Task $task): \Illuminate\Http\RedirectResponse + public function destroy(Task $task): RedirectResponse { $task->labels()->detach(); $task->delete(); diff --git a/app/Models/User.php b/app/Models/User.php index 4d4fec8..21b63f5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -61,12 +61,4 @@ public function assignedTasks(): HasMany { return $this->hasMany(Task::class, 'assigned_to_id'); } - - /** - * Get the labels assigned to the user. - */ - public function labels(): BelongsToMany - { - return $this->belongsToMany(Label::class, 'label_user', 'user_id', 'label_id'); - } } diff --git a/app/Policies/TaskPolicy.php b/app/Policies/TaskPolicy.php index 4ba2784..f4f1b13 100644 --- a/app/Policies/TaskPolicy.php +++ b/app/Policies/TaskPolicy.php @@ -37,7 +37,6 @@ public function create(User $user): bool */ public function update(User $user, Task $task): bool { -// return Auth::check() && $task->created_by_id === $user->id; return Auth::check(); }