Skip to content

Tag: eloquent

Laravel custom db driver

i know there is a nice way of defining connections via app/config/database.php . But i don’t think there is a driver for me available. Imagine my db is read from file, like a txt. (Yeah! that’s my client db, sort of). So in that file, before I i need a real driver! Currently it uses a txt base db …

Laravel Carbon Group by Month

Can anyone see what I’m doing wrong? I’m trying to output all the months but group them so they are unique. I’m getting the following back In my database I have five news articles all created_at 05/01/2017 so it’s right that I only get one response but I’m not getting the number …

Laravel – Eloquent – Dynamically defined relationship

Is it possible to set a model’s relationship dynamically? For example, I have model Page, and I want to add relationship banners() to it without actually changing its file? So does something like this exist: Or something similar? As they are fetched using the magic methods anyway, perhaps I can add the …

Laravel Eloquent where field is X or null

I have a table like this: Now I want to get all entries where field1 is 1, field2 is null and where datefield is smaller than X or null. I already tried something like this: but thats not working. I always get every entry where datefield is null. It doesn’t matter what the other fields are. I also tried…