Menu
About LCS
Eloquent ORM
It is object relational mapper that provides smooth interaction with database.
Quick way to save or update post with one liner of eloquent code
Typically, we fetch the post with a single or set of criteria to see if it already exists, and if...
Topic:
Eloquent Builder
3 years ago
Using model observer - a separate class to observe model changes and run desired logic
Model observer methods checks if any changes occur around model such as - created() after record getting creeated- creating() before...
Topic:
Eloquent Builder
3 years ago
Changing model values using accessors before viewing in table
Sometimes we need to change model value before showing it to user in browser . With help of accessors we...
Topic:
Accessors
3 years ago
Changing model values using mutators before saving in database
Sometimes we need to change model value before saving in the database. With help of mutators we can achieve this...
Topic:
Eloquent Builder
3 years ago
Using Seeder and factory to create dummy data for User, Post and Comment model
Step 01: create fresh laravel projectcomposer create-project laravel/laravel postcomment Step 02: Setting Up migration, factory of Post model and migration,...
Topic:
Seeding
3 years ago
Using parameters in find() method
find() does not only take single value as parameter like belowPost::find(1); find() method also can accept array like belowPost::find([1,2]) //...
Topic:
Eloquent Builder
3 years ago
Using findorFail() and firstOrFail() method
Without findorFail() method we need to implement like following snippet$post = Post::find(12333); if(!$post) { abort(404); } We can implement the...
Topic:
Eloquent Builder
3 years ago
Using whereDate, whereYear, whereMonth, whereDay and whereCreatedAt for dates
Following snippets would be able to fetch records based on given magic where() methods.01. whereCreatedAt - using exact value of...
Topic:
Eloquent Builder
3 years ago
Using brackets to specify two or more where clauses into its own where function in eloquent
Suppose we need to fetch records from post table where user id of post needs to be 1 and they...
Topic:
Eloquent Builder
3 years ago
Using local scope in eloquent
If there are repeating eloquent conditions in different methods and we can group and reuse those in different methods of...
Topic:
Eloquent Builder
3 years ago
‹
1
2
3
4
5
›