“Laravel où a” Réponses codées

Laravel où a

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

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

Laravel comment interroger la relation appartenance

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

Réponses similaires à “Laravel où a”

Questions similaires à “Laravel où a”

Plus de réponses similaires à “Laravel où a” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code