I have the following code in my view:
@if(Session::has('quality-data'))
<a href="{{ route('showQualityResult' , compact(Session::get('quality-data'))) }}">Submited Quality Check</a>
@endif
Now when i open this view in the frontEnd i get the following error:
The method thats invoked when clicked on the a tag is the following:
public function showQualityResult($qualityData) {
return $qualityData;
// return view('quality-result' , compact($qualityData));
}
Now even though i have not clicked on the a tag i am still getting an error that the parameter for the function has't been passed , Why ??
Just the fact that i have the below lines of code in my view:
@if(Session::has('quality-data'))
<a href="{{ route('showQualityResult' , compact(Session::get('quality-data'))) }}">Submited Quality Check</a>
@endif
Makes my application not work :(
I think your error is due to the usage of compact .. that does not match with the expected data required.
Indeed, your route require the data
argument. Compact will create an array where the key the string in parameter, and the value associated. Is Session::get('quality-data')
return 'data' ? And $data
exists ?
So, you should write:
@if(Session::has('quality-data'))
<a href="{{ route('showQualityResult' , ['data' => Session::get('quality-data')]) }}">Submited Quality Check</a>
@endif
If this works ... so, you will be able to simplify the writing.