laravel detach
snippet in php

laravel detach

user5088

// Detach a single role from the user...
$user->roles()->detach($roleId);

// Detach all roles from the user...
$user->roles()->detach();

latavel attach method

user3507

$user->roles()->attach($roleId, ['expires' => $expires]);

laravel how to query belongsTo relationship

user1947

$movies = Movie::whereHas('director', function($q) {
    $q->where('name', 'great');
})->get();

laravel attach

user5931

//id for single
$user->reasons->attach($reasonId);

//array for multiple
$user->reasons->attach($reasonIds);

$user->save();