“Laravel Wo hat Beziehung” Code-Antworten

Laravel wo hat

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

Hasone -Beziehung in Laravel

//Model Function
public function hasOneFunction(){
        return $this->hasOne('App\Models\ModelName', 'targetedId');
    }
//in controller function
$data = ModelName::with('hasOneFunction')->get();
Isaac

Wie erhalten Sie Daten, wenn Sie eine Beziehung in Laravel haben

Doctor::has('DoctorMessage')->with('DoctorMessage')->get()
Mohamad

Laravel, wie man die Beziehung zwischen hingehören

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

Laravel Wo hat Beziehung

// Laravel 8+ or above
$projects = Project::whereRelation('projectOffers', ['teacher_id'=>'Naveed', 'status_id'=>'Approved'])->where('status_id', "In Progress")->get();

// Laravel 8 below
$projects = Project::whereHas('projectOffers', function ($offer) {
            $offer->where('teacher_id', "Naveed");
            $offer->where('status_id', "Approved");
        })->where('status_id', "In Progress")->get();
Naveed Shahzad

Ähnliche Antworten wie “Laravel Wo hat Beziehung”

Fragen ähnlich wie “Laravel Wo hat Beziehung”

Weitere verwandte Antworten zu “Laravel Wo hat Beziehung” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen