get first element from collection laravel code example
Example 1: firstwhere laravel
Role::firstWhere('name', 'admin')
Role::firstWhere(['name' => 'admin', 'display_name' => 'Administrateur'])
Example 2: collection get first element laravel
$first = $msgs->first(); // this does ->take(1) under the hood