“sincronizar laravel” Código de respuesta

Wherehas Sitio: https: //laravel.com/docs/

use Illuminate\Database\Eloquent\Builder;

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

// Retrieve posts with at least ten comments containing words like code%...
$posts = Post::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'code%');
}, '>=', 10)->get();
Tiago F2

sincronización del modelo de laravel

$user->roles()->sync([1, 2, 3]);
Fahim Foysal

adjunta de laravel

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

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

$user->save();
Freeburn

sincronizar laravel

$user = User::find(1);

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

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

Método de fijación de Latavel

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

Laravel Sync con atributos

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

Respuestas similares a “sincronizar laravel”

Preguntas similares a “sincronizar laravel”

Más respuestas relacionadas con “sincronizar laravel” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código