laravel add custom attribute to model code example
Example 1: laravel add attribute to model
$user = User::find(1);
$user->setAttribute('occupation', 'Web Developer');
Example 2: laravel property
$user = User::create(array('name' => 'John'));
$user = User::firstOrCreate(array('name' => 'John'));
$user = User::firstOrNew(array('name' => 'John'));
Example 3: laravel property
$user = User::create(array('name' => 'John'));
$user = User::firstOrCreate(array('name' => 'John'));
$user = User::firstOrNew(array('name' => 'John'));