Laravel Community Tools by Tighten

Recent tricks

458 tricks
This query searches the data from the Table and also with its relation table columns dynamically.
Muzamil-kh... 4 years ago 10059
Get products count which are under sub categories of a parent category
Faridbabay... 4 years ago 11385
set custom table name for eloquent model
uniqueginu... 4 years ago 7915
Using laravel eloquent, you have an amazing feature called `Accessors`, which allows you to define a non-existing column, here's an example to get user full_name that does not exist in the users table
thefeqy 4 years ago 15764
# Report(): The report() method allows us to log the raised exceptions or parse them to various error logging engines like the sentry. All this method does by default is passing the thrown exception to the base class where it is logged, but we are free to customize.
harshaldos... 5 years ago 9872
If you only need the functionality of a custom rule once throughout your application, you may use a Closure instead of a rule object. The Closure receives the attribute's name, the attribute's value, and a $fail callback that should be called if validation fails. Below is the code example:
asifzcpe 5 years ago 21053
If you have DB column which you want to be set only once and never updated again, you can set that restriction on Eloquent Model, with a mutator
fatihtopra... 5 years ago 17616
What if you’re working with non-Laravel database and your timestamp columns are named differently? Maybe, you have create_time and update_time. Luckily, you can specify them in the model, too
fatihtopra... 5 years ago 14991
You can filter by NULL in Eloquent, but if you're filtering the collection further - filter by empty string, there's no "null" in that field anymore.
fatihtopra... 5 years ago 15212