Eloquent Model

These posts are all related to Laravel eloquent model.

February 24, 2021

Convert datetime string to carbon instance with laravel eloquent

Recently I was working on a project, where after querying the database via eloquent I get back a datetime string. I wanted to convert it in to timestamp. To my surprise, converting default...

Read

February 11, 2021

Laravel 8 - Retrieve one or two columns from Model

Often times when you are retrieving data from eloquent model, you just need some columns and not all of them. When using Laravel eloquent model to query database, Laravel will return a collection...

Read

Sign up for monthly newsletter