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 :: laravel migration remove constraint 
Php :: flutter form autadjust height 
Php :: laravel append to model 
Php :: remove decimal php 
Php :: laravel blade auth user 
Php :: laravel check pagination in blade 
Php :: PHP strrev — Reverse a string 
Php :: php check if associative array is null 
Php :: run composer with different php version 
Php :: How to insert time in table using CodeIgniter 
Php :: laravel 8 check if null or empty 
Php :: newline in php 
Php :: php header location not working 
Php :: what sign is greater than or equal to php 
Php :: how to get variable from url in laravel 
Php :: if text contains word then in php 
Php :: check if url is https laravel 
Php :: how to return with open model popup in laravel 
Php :: symfony get query param 
Php :: faker 
Php :: custom post type 
Php :: how to use multiple where condition in codeigniter 
Php :: loop index foreach laravel 
Php :: pagination prestashop 1.7 
Php :: php json_encode without square brackets 
Php :: laravel change column 
Php :: how to upload pdf file using php 
Php :: php delete array element 
Php :: how set variable public in static method in laravel 
Php :: php round() function 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =