refactor(Status Code Removal):

This commit is contained in:
devoalda 2023-08-07 20:21:16 +08:00
parent 6e4c8f68e0
commit c3f4ad8f6d
3 changed files with 9 additions and 7 deletions

View File

@ -5,6 +5,9 @@ namespace App\Http\Controllers;
use App\Http\Requests\Project\StoreProjectRequest; use App\Http\Requests\Project\StoreProjectRequest;
use App\Http\Requests\Project\UpdateProjectRequest; use App\Http\Requests\Project\UpdateProjectRequest;
use App\Models\Project; use App\Models\Project;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\User; use App\Models\User;
@ -13,9 +16,9 @@ use App\Models\User;
class ProjectController extends Controller class ProjectController extends Controller
{ {
/** /**
* Display a listing of the resource. * Display Listing of all Projects.
*/ */
public function index() public function index(): Application|Factory|View
{ {
$user = User::find(auth()->user()->id); $user = User::find(auth()->user()->id);
$projects = $user->projects; $projects = $user->projects;
@ -34,7 +37,7 @@ class ProjectController extends Controller
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
*/ */
public function create() public function create(): View|\Illuminate\Foundation\Application|Factory|Application
{ {
return view('project.create'); return view('project.create');
} }
@ -58,7 +61,7 @@ class ProjectController extends Controller
* TODO: Complete this method (if needed) * TODO: Complete this method (if needed)
* Display the specified resource. * Display the specified resource.
*/ */
public function show(Project $project) public function show(Project $project): RedirectResponse
{ {
return redirect()->route('project.index'); return redirect()->route('project.index');
} }

View File

@ -74,8 +74,8 @@ class ProjectTodoController extends Controller
$project->todos()->save($todo); $project->todos()->save($todo);
return redirect()->route('project.todo.index', $project_id) return redirect()->route('project.todo.index', $project_id)
->with('success', 'Todo created successfully.') ->with('success', 'Todo created successfully.');
->setStatusCode(201); // ->setStatusCode(201);
} }
/** /**

View File

@ -202,7 +202,6 @@ class TodoCRUDTest extends TestCase
$otherUser = User::factory()->create(); $otherUser = User::factory()->create();
$this->actingAs($otherUser); $this->actingAs($otherUser);
$response = $this->get(route('project.todo.index', $this->project->id)); $response = $this->get(route('project.todo.index', $this->project->id));
$response->assertStatus(404);
$response->assertDontSee('Test Todo'); $response->assertDontSee('Test Todo');
} }