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 :: php Undefined index: error 
Php :: test in laravel 
Php :: laravel where condition with if 
Php :: divide page in pdf with page break using php 
Php :: update php 
Php :: how to define a function in scheme 
Php :: how to make trait in laravel 
Php :: php echo example 
Php :: if condtion in varibale value how to change in loop in php 
Php :: connexion à la base de donnée microsoftsqlserver avec php 
Php :: laravel log error 
Php :: functions.php not working wordpress 
Php :: Add to cart, link to product page 
Php :: clear log file laravel 
Php :: drupal get route current content type 
Php :: php artisan websockets serve 
Php :: laravel toastr option 
Php :: php function use 
Php :: use external variable in php function 
Php :: Laravel catch TokenMismatchException 
Php :: Export Database Records to CSV 
Php :: yajra datatables html column bulder example 
Php :: php wait for exec to finish 
Php :: array filter php get first object 
Php :: how to append an array into associative array 
Php :: laravel scope 
Php :: attach one or multiple files laravel mail 
Php :: mailjet 
Php :: where is cache file in laravel 
Php :: create xml php 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =