Found (6) results for "laravel eloquent"

Laravel eloquent, query based on where AND OR inside it

Some times you will need to create an eloquent where clause and inside that where you may need to add extra or where claused

Complicated eloquent queries

Here is a sample of a complicated query that includes where and with and inner queries. This snuppet is the one used to get the legislative event stream on the dashboard in the GovIQ project.

Eloquent normal sql select statement

In laravel and eloquent, some times you might need to run a normal SQL select statement. So here is an example to do so:

orderBy on relationship

Sometimes you will need to order the eloquent results based on a relationship for example posts and categgories. Here are different ways to do so based on this laravel daily video :

Eloquent query with multiple withs or with with within a hirarchy

Some time, you may need to get a record with some relationship and at the same time you need to get an inner relationship to that relationship and so forth. Here is the key : $records->with(['bill', 'bill.sponsor', 'bill.sponsorSenator', 'bill.sponsor.actions']).

laravel eloquent order by varchar as int

Sometimes, You will need to order by a varchar column as an integer. for example if you have the billNumbers in two rows as 5 and 1400 the order as varchar in desc order will get that with 5 first then that with 1400. While the opposite is what is wanted in the ordering using integers.