Laravel Community Tools by Tighten

Tag "models" tricks

58 tricks
You can unguard all your Models instead of setting the protected guarded variable to an empty array in each App\Models\YourModel class using Model::unguard() in the boot method of AppServiceProvider class.
berto309 5 years ago 24902
Make your dynamic post caching for load your website post fast.
haruncpi 6 years ago 8750
If you want to count the number of results from a relationship without actually loading them you may use the "withCount" method, which will place a "{relation}_count" column on your resulting models.
kupendra 7 years ago 12347
If you want your search functionality to be dynamic as possible to avoid code repetitions, you can use this trait directly in your models
kissartisa... 8 years ago 12329
Sometimes you need to want tables columns as array while you editing the data, this will return a columns as array.
decipher 8 years ago 4644
Title : Access Control Allow Origin http set Headers Site Name : http://live24u.com/ URL : http://live24u.com/access-control-allow-origin-http-set-headers/ Live Example : http://live24u.com/tutorial/ We are Web Technology Experts and Team who provide you very Important information on Web Development information, Interview Questions and Answers, live project problem solution and their solution and online free tutorials – “live24u.com”.
live24u 9 years ago 7677
This example provides a quick and simple method to generate a hash for a model without saving a UUID/GUID to the database.
Donny5300 9 years ago 8475
Automatically deleting related rows in Laravel (Eloquent ORM)
dickyeka 9 years ago 30816
I'm using a pivot table on the project I'm working with to filter category
dickyeka 9 years ago 9592