Subcategory: Eloquent Tips

Use Cursor In Eloquent Query To Reduce Memory In Laravel

Do you know Laravel has a cursor method to reduce your memory size. The cursor method allows us to loop through your database records using a cursor, which will only runs a single query... Read more

#laravel #eloquent-tips

Laravel WhereJsonContains Query Example

Hello devs In this tutorial i will discouss about laravel wherejsoncontains method. You will know wherejsoncontains laravel example from this example tutorial. Sometimes you know that we need... Read more

#laravel #eloquent-tips #json

Laravel WhereHas And WhereDoesntHave Query Example

Hello Laravel Lover In this tips tutorial i am going to discuss about laravel whereHas and doesntHave query example. Sometimes we face such type of situation that you want to fetch only such kind o... Read more

#laravel #laravel-8x #eloquent-tips

Laravel Check If Relationship Has Data Query Example

Hello Artisan  In this tutorial i will explain existence of a relationship in Laravel. For example, imagine you would like to fetch all blog posts that have at least one comment. To... Read more

#laravel #eloquent-tips

How To Get Last N Days Records In Laravel

Hello Artisan In this tutorial i am going share with you that how to get last 7 days record in laravel? Actually it's not last 7 days, it should be last N days records. If you know this query t... Read more

#laravel #eloquent-tips

Laravel WhenHas And WhenFilled Method Example

Do you know that Laravel has a cool built in method called whenHas. Sometimes we need to check out that the request has specific data or not. That type of task you can use Laravel whenHas to check you... Read more

#laravel #eloquent-tips

Save Models And Relationships At The Same Time Laravel

Hey Artisan Lover, i am going to show you an amazing tips of Laravel. Do you know that we can update model column value and its relationship column at the same time in Laravel?  So in this exa... Read more

#laravel #laravel-tips

Laravel WithMin(), WithMax() Eloquent Query Example

Do you know that Laravel 8.x provide some powerfull eloquent aggregate function to fecth max, avg, sum etc. Eloquent provides withMin, withMax, withAvg, and withSum metho... Read more

#laravel #laravel-8x #eloquent-tips