Can someone tell me what is wrong with my syntax? I am trying to write this set of php code in the a laravel blade file
@php $identifiedIndex = $relevantTicketFlows->search(function($query) use ($data->ticket_flow_id){return $query->id == $data->ticket_flow_id;});
echo '<p> $relevantTicketFlows[$identifiedIndex] </p> '
@endphp
CodePudding user response:
Firstly, you should really avoid this kind of behavior, Laravel uses MVC pattern, and having logic in a view is the devil.
Then, I think you just have a syntax error:
use ($data->ticket_flow_id){return $query->id
You can't have this in a use
(I'm pretty sure), try:
use ($data) {
// access $data->ticket_flow_id inside closure
CodePudding user response:
For the js
const user = '{{$user->id}}'
For the html
<a href="{{ route('get_user', ['user' => $user->id]) }}">