samedi 2 janvier 2016

Laravel 5 check if object exists and use if true

Instead of having to write:

{{$x = $data->where('colour_id', 1)->where('size_id', 1)->where('product_id', 1)->first() ? $data->where('colour_id', 1)->where('size_id', 1)->where('product_id', 1)->first()->quantity : 0}}

Is there a much cleaner way?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire