laravel data-item value code example

Example 1: firstwhere laravel

Role::firstWhere('name', 'admin')
Role::firstWhere(['name' => 'admin', 'display_name' => 'Administrateur'])

Example 2: laravel property

// Create a new user in the database...dddd
$user = User::create(array('name' => 'John'));

// Retrieve the user by the attributes, or create it if it doesn't exist...
$user = User::firstOrCreate(array('name' => 'John'));

// Retrieve the user by the attributes, or instantiate a new instance...
$user = User::firstOrNew(array('name' => 'John'));

Tags:

Php Example