I have two models, model1 and model2 . I am using this models in blade template and I don't want to use controller for getting value.
@php
$school = App\Models\Model1::all()
$department = App\Models\Model2::all()
@endphp
<select name="school">
<option value="" selected="">school</option>
@foreach($school as $val)
<option value="">{{$val->name}}</option>
@endforeach
</select>
<select name="departments">
<option value="" selected="">department</option>
@foreach($department as $val)
<option value="">{{$val->name}}</option>
@endforeach
</select>
But I am getting this error:
syntax error, unexpected '$department' (T_VARIABLE)
But when I call only one model, the data shows perfectly. How can i solve this problem?