“Sync Laravel” Réponses codées

WHAME SITE: 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

Sync de modèle Laravel

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

Laravel attachée

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

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

$user->save();
Freeburn

Sync Laravel

$user = User::find(1);

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

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

Méthode de fixation Latavel

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

Laravel Sync avec les attributs

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

Réponses similaires à “Sync Laravel”

Questions similaires à “Sync Laravel”

Plus de réponses similaires à “Sync Laravel” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code