Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel model sync

//Single
$user->roles()->sync([1,2,3]);

//With attributes
$user->roles()->sync([ 
    1 => ['expires' => true],
    2 => ['expires' => false],
    ...
]);
Comment

sync laravel

$user = User::find(1);

$user->roles()->detach([1, 2, 3]);

$user->roles()->attach([
    1 => ['expires' => $expires],
    2 => ['expires' => $expires],
]);
Comment

laravel sync with attributes

$user->roles()->sync(array(1 => array('expires' => true)));
Comment

PREVIOUS NEXT
Code Example
Php :: how to start the index from 1 in php? 
Php :: finding second highest number in array 
Php :: laravel collection intersect 
Php :: php creating a subdomain automatically in cpanel 
Php :: SUM with Eloquent 
Php :: mktime() php 
Php :: php to print array value if key exists 
Php :: Add Text After or Before on the Shop Page/Archive Page 
Php :: wp php footer date automatically 
Php :: namespace in php 
Php :: macrotime phph 
Php :: encode zlib php 
Php :: php get json objects by key without indez 
Php :: guarded and fillable in laravel 
Php :: create config value file in php 
Php :: ./yii serve not working in advanced template 
Php :: laravel what is migrations 
Php :: Regullar date format for php 
Php :: where statement multiple argument in codeigniter 
Php :: static function php 
Php :: log magenot 1 
Php :: php trait example 
Php :: php split 
Php :: get time ISO 8601 wordpress 
Php :: Error : Call to undefined method IlluminateNotificationsChannelsMailChannel::assertSentTo() 
Php :: send data with url in php 
Php :: use htaccess to redirect in cpanel laravel 
Php :: How to make a simple mail system in Laravel without view or notification 
Php :: php config file 
Php :: coinbase commerce laravel 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =