hi i have problem with my laravel 8 project ,everything in the foreach column raises an error when I test the order, the error will appear but when I don't order the error doesn't appear
this my controller
public $sources = [
[
'model' => Booking::class,
'date_field' => 'time_from',
'date_field_to' => 'time_to',
'field' => 'user_id',
'names' => 'studios_id',
'prefix' => '',
'suffix' => '',
],
];
public function index(Request $request){
$bookings = [];
$studios = Studios::where('status',1)->get();
foreach ($this->sources as $source) {
$models = $source['model']::where('status', '0')
->get();
foreach ($models as $model) {
$crudFieldValue = $model->getOriginal($source['date_field']);
$crudFieldValueTo = $model->getOriginal($source['date_field_to']);
$studios = Studios::findOrFail($model->getOriginal($source['names']));
$user = User::findOrFail( $model->getOriginal($source['field']));
$timeBreak = \Carbon\Carbon::parse($crudFieldValueTo)->format('H:i');
if (!$crudFieldValue && $crudFieldValueTo) {
continue;
}
$bookings[] = [
'title' => trim($source['prefix'] . "($studios->names)" . $user->name
. " " ). " " . $timeBreak,
'start' => $crudFieldValue,
'end' => $crudFieldValueTo,
];
}
}
return view('welcome', compact('studios', 'bookings'));
}
and this is my blade and sorry if my welcome.blade is a mess I don't know why if I don't use '' then the code doesn't appear
<div class="row">
@foreach($studios as $studios)
<div class="col-lg-4 mb-5">
<div class="card" style="width: 18rem;">
@if($studios->photo)
<img src="{{ $studios->photo->getUrl() }}" class="card-img-top" alt="...">
@endif
<div class="card-body">
<h5 class="card-title">{{ $studios->names }}</h5>
<p class="card-text">Harga : Rp{{ number_format($studios->price,2,',','.') }} / Jam</p>
<p class="card-text"> Rp{{ number_format($studios->org,2,',','.') }} / Orang</p>
<a href="{{ route('booking', ['studio' => $studios->names]) }}" class="btn btn-primary">Booking</a>
</div>
</div>
</div>
@endforeach
</div>
</div>```