“Laravel attach” Kode Jawaban

Laravel di mana

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();
Alberto Peripolli

Laravel attach

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

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

$user->save();
Freeburn

Jawaban yang mirip dengan “Laravel attach”

Pertanyaan yang mirip dengan “Laravel attach”

Lebih banyak jawaban terkait untuk “Laravel attach” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya