Answers for "laravel attach"

PHP
3

laravel where has

use Illuminate\Database\Eloquent\Builder;

// Retrieve posts with at least one comment containing words like foo%...
$posts = App\Post::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'foo%');
})->get();

// Retrieve posts with at least ten comments containing words like foo%...
$posts = App\Post::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'foo%');
}, '>=', 10)->get();
Posted by: Guest on May-07-2020
5

laravel detach

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

// Detach all roles from the user...
$user->roles()->detach();
Posted by: Guest on September-15-2020
1

laravel attach

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

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

$user->save();
Posted by: Guest on July-10-2020

Code answers related to "laravel attach"

Browse Popular Code Answers by Language