vendredi 26 juin 2020

Laravel is returning view with 404

web.php

Route::get('/jobs/{id}/edit', 'JobController@edit')->name('job.edit');

then html page:

                         <td>
                            <a href=""><button class="btn btn-dark">Edit</button></a>

                            <a href=""><button class="btn btn-success btn-sm">Apply</button></a>
                        </td>

The jobs.show is working, so that's fine

If I click on the edit button the url is:

http://127.0.0.1:8000/jobs/41/edit

controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Job;
use App\Company;
use App\Http\Requests\JobPostRequest;

class JobController extends Controller
{
    public function index()
    {
        $jobs = Job::all()->take(10);
        return view('welcome', compact('jobs'));
    }

    public function edit($id) {
        $job = Job::findOrFail($id);
        return view('jobs.edit', compact('job'));
    }
    
    public function show($id, Job $job) {
        return view('jobs.show', compact('job'));
    }

folder where the edit view is located:

resources - views - jobs - edit.blade.php

Does anyone has an idea why I get page 404?




Aucun commentaire:

Enregistrer un commentaire