Search
 
SCRIPT & CODE EXAMPLE
 

PHP

eager load relationships by default in the model laravel

class Post extends Model
{
    protected $with = ['category', 'author'];

    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function author()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: windows logged in user name in php 
Php :: sendmail php 
Php :: disable display error 
Php :: wordpress if is not page template 
Php :: php pdo sql server connect 
Php :: laravel post ajax proper csrf 
Php :: softDelete laravel8 
Php :: Session/Session.php error codeigniter 3 
Php :: laravel auth 
Php :: codeigniter how to know update failed 
Php :: autoloader php 
Php :: rest api response 404 wordpress 
Php :: acf sub_field image title 
Php :: how to add column to database in laravel 
Php :: start php cli 
Php :: get field object acf 
Php :: mysql Cannot pass parameter 2 by reference 
Php :: php if negative then 0 
Php :: laravel imap - Get message attachments 
Php :: php multiplication 
Php :: assigning variable in php 
Php :: how create page 419 in laravel 
Php :: php check if user exists in database 
Php :: text or description laravel database column type 
Php :: laravel if else condition in blade file 
Php :: laravel 9 route group 
Php :: pagination in codeigniter with example 
Php :: Return length of string PHP 
Php :: laravel pdf export 
Php :: Corsair K70 RGB MK.2 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =