mardi 25 août 2015

Laravel 5 - Unable to access the ID variable within the route

My current setup:

Controller:

public function showGeneralPage($id, ShowClinicFormRequest $request)
{
    return View::make('clinic.general', ['clinic' => Clinic::where('id', $id)
        ->first()]);
}

ShowClinicFormRequest:

public function authorize()
{
    $clinicId = $this->route('clinic');

    return Clinic::where('id', $clinicId)
    ->where('user_id', Auth::id())
    ->exists();
}

Route:

Route::get('clinic/{id}/general', 'ClinicController@showGeneralPage

When trying to click through to the page - <a href="{{ url('/clinic/general') }}">General</a>, it presents a forbidden error.

To be honest, I'm not overly fussed on even having to show the ID based on the clinic, within the URL, but I can't see any other way around it? Any help would be hugely appreciated. Many thanks.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1JXnkYY
via IFTTT

Aucun commentaire:

Enregistrer un commentaire