laravel check in collection code example
Example 1: laravel check collection has key
$collection = collect(['account_id' => 1, 'product' => 'Desk', 'amount' => 5]);
$collection->has('product');
// true
$collection->has(['product', 'amount']);
// true
$collection->has(['amount', 'price']);
// false
Example 2: laravel check if collection has value
Auth::user()->ports->contains('port', $request->port);