Laravel - Relationships - Eager Loading By Default

Sometimes you might want to always load some relationships when retrieving a model. To accomplish this, you may define a $with property on the model:

    
    belongsTo(Author::class);
        }
    
        /**
         * Get the genre of the book.
         */
        public function genre()
        {
            return $this->belongsTo(Genre::class);
        }
    }
	

If you would like to remove an item from the $with property for a single query, you may use the without method:

    
    $books = Book::without('author')->get();
	

If you would like to override all items within the $with property for a single query, you may use the withOnly method:

    
    $books = Book::withOnly('genre')->get();