Skip to content

Commit

Permalink
Refactor Controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
maxencebonamy committed Jan 22, 2024
1 parent 7cfac05 commit 5971b86
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
7 changes: 3 additions & 4 deletions app/Http/Controllers/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
namespace App\Http\Controllers;

use App\Utils\AuthUtil;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use App\Models\Comment;

class CommentController extends Controller {
// ...

public function store(Request $request, $id)
{
public function store(Request $request, $id) {
// Validate the request data
$validatedData = $request->validate([
'content' => 'required|string|max:500',
Expand All @@ -32,4 +30,5 @@ public function store(Request $request, $id)
// Redirect or return a response
return redirect()->back();
}

}
4 changes: 1 addition & 3 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

namespace App\Http\Controllers;

use Illuminate\Contracts\View\View;

class DashboardController extends Controller {

public function show(): View {
public function show() {
return view('app.dashboard');
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function show($id) {
return redirect()->back();
}

$is_admin = app(ProjectController::class)->isAdmin($project->id, $user->id);
$is_admin = $this->isAdmin($project->id, $user->id);

return view("app.project", [
"project" => $project,
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Controllers/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Models\Comment;
use App\Models\User;
use App\Models\UserTask;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Models\Task;
use App\Models\Project;
Expand Down Expand Up @@ -63,8 +62,7 @@ public function updateStatus($id, $status) {
return redirect()->back();
}

public function update(Request $request, $id): string
{
public function update(Request $request, $id): string {
$request->validate([
'name' => 'string|nullable',
'description' => 'string|nullable',
Expand Down
2 changes: 1 addition & 1 deletion database/seeders/UserProjectSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public function run(): void
"is_admin" => true
]);
}
UserProject::factory()->count(200)->create();
UserProject::factory()->count(100)->create();
}
}

0 comments on commit 5971b86

Please sign in to comment.