πŸ”₯ #Laravel Eloquent Models - [ πŸ₯·πŸ» "hidden" properties ]
We are all familiar with $table, $fillable, $dates and $appends and a few more but did you know there are more undocumented properties that we can make use of in our Laravel models?

Here is the complete list 🧡 πŸ‘‡πŸ»
1️⃣ You can specify the relations to eager load on every query for that model using $with Image
2️⃣ You can set how the relationship counts that should be eager loaded on every query for a given model Image
3️⃣ You can enable or disable lazy loading for a model using $preventsLazyLoading Image
4️⃣ You can limit the number of models to return for pagination using $perPage Image
5️⃣ You can indicate if the model was inserted during the current request lifecycle using $wasRecentlyCreated Image
6️⃣ If you want the object's string representation to be escaped when __toString is invoked you can set $escapeWhenCastingToString to true Image
7️⃣ You can indicate if broadcasting is currently enabled for a model using $isBroadcasting Image
8️⃣
BONUS - For all of the available options you can check out Laravel's model class:

github.com/laravel/framew…

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Marian Pop πŸŽ™ Laravel Magazine

Marian Pop πŸŽ™ Laravel Magazine Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @mvpopuk

Jan 19
Laravel makes it simple to create background-processing queued jobs. Your application can reply to web requests with lightning speed and give your clients a better user experience by transferring time-consuming operations to a queue.

Laravel Queues [ Pocket Guide ] 🧡 πŸ‘‡πŸ»
1️⃣ Dispatching and running jobs
You can create a new job running the following artisan command:
2️⃣ Queues to database
In order for the queues to use your database, you have to configure the queue connection in queue.php to point to your database. Once that is configured, you have to create two tables in your database: jobs and failed_jobs:
Read 19 tweets
Jan 6
πŸ”₯ Epic Laravel Tips Thread πŸ”₯ [ Part 1 ] I decided to create weekly threads and share epic @laravelphp tips that will lead to a cleaner and more performant code!

Let's go 🧡 #epiclaravel πŸ‘‡πŸ»

1/11
πŸ”₯ Epic Laravel πŸ”₯ - Tip No. 1 [ Eloquent Global Query Scopes ] Implementing your own eloquent global query scopes can be a quick and straightforward approach to ensure that all queries for a given model are subject to certain limitations:

2/11
πŸ”₯ Epic Laravel πŸ”₯ - Tip No. 2 [ Conditional Relationships ]
Relationships allow for powerful method chaining and querying. However, for consistency reasons consider creating a separate relationship method that includes the desired chaining or querying:
3/11
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(