Monday, April 3, 2017

Laravel custom error page if authorization fails

I am trying to show a custom 403 file in laravel when authorization fails in my edit request.

I tried forbiddenResponse() but as it turns out it has been eliminated.

Then I tried failedauthorization() but this does not redirect as well and allows me to edit.

here is my request file

public function authorize()
{
  $job_posting_id = $this->route('id');

  $job_posting = Job_postings::where('id', $job_posting_id)->where('user_id', user()->id)->exists();

  if($job_posting){
    return true;
  }

  return false;
}

public function failedAuthorization()
{

  return redirect('errors.dashboard.parent.403');
}

I have a folder called errors and inside there I have dashboard folder and parent where the error file is located.

How can I redirect to that page if authorization fails?



via raqulka

Advertisement