Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel where condition on relationship

AppRequest::where('id',4)
    ->whereHas('quotes', function ($query) {
        $query->where('status','=','3');
    })
    ->with('quotes','sourceTable','destinationTable')
    ->get(); 
Comment

laravel adding condition to relation

class Game extends Eloquent {
    // many more stuff here

    // relation without any constraints ...works fine 
    public function videos() {
        return $this->hasMany('Video');
    }

    // results in a "problem", se examples below
    public function available_videos() {
        return $this->videos()->where('available','=', 1)->get();
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: php get html with special characters 
Php :: php foreach skip to next 
Php :: wordpress login user programmatically 
Php :: api resource create in laravel 
Php :: file get content php post 
Php :: downgrade php version 
Php :: php get duplicate keys in array without using inbuilt function 
Php :: replace last two characters string php 
Php :: laravel get from model 
Php :: how to loop by index in php 
Php :: how remove column in migration laravel 
Php :: what is lang in laravel 
Php :: Get data from array (from an API) in Laravel 
Php :: command to create middleware in laravel 
Php :: laravel eloquent multiple join 
Php :: laravel one command for model table and controller 
Php :: socket in laravel 
Php :: php rce command 
Php :: Regex to remove span tags using php [duplicate] 
Php :: session array 
Php :: cara membuat koneksi php 
Php :: php after leave page 
Php :: laravel hash password sample 
Php :: filament make resource 
Php :: validate file count with validate in laravel 
Php :: cara install php7.3 di ubuntu 20.04 
Php :: php signature capture 
Php :: laravel websockets 
Php :: laravel database engine innodb 
Php :: canany else 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =