Backpack for Laravel Profile Banner
Backpack for Laravel Profile
Backpack for Laravel

@laravelbackpack

3,406
Followers
9
Following
341
Media
501
Statuses

We help web developers build admin panels for their clients. Follow us for tips & tricks on Laravel, Backpack, admin panels.

Joined October 2020
Don't wanna be here? Send us removal request.
@laravelbackpack
Backpack for Laravel
8 months
⚡️Speed up a #Laravel app by caching the entire response. You can use Spatie's ResponseCache package or create a middleware to store the response in the cache:
Tweet media one
5
45
259
@laravelbackpack
Backpack for Laravel
6 months
Did you know... about the skip method of Laravel's scheduler? You can define inside skip() when the command should NOT be executed:
Tweet media one
4
41
239
@laravelbackpack
Backpack for Laravel
7 months
#PHP Tip: Embrace PHP 8's match expression for cleaner conditional logic. 🧹
Tweet media one
3
23
215
@laravelbackpack
Backpack for Laravel
6 months
#Laravel Tip: Find out queries that take a long time. It's simple to log them using:
Tweet media one
1
37
218
@laravelbackpack
Backpack for Laravel
24 days
#PHP Tip Make use of Laravel's "dot" notation for accessing nested array values. 🎯 Simplify accessing multidimensional arrays with a single dot-separated string.
Tweet media one
7
29
213
@laravelbackpack
Backpack for Laravel
4 months
Laravel Tip If you are using where clause on relationships often, better create a separate relationship method with the additional "where" condition.
Tweet media one
4
25
193
@laravelbackpack
Backpack for Laravel
1 month
#PHP Tip Embrace PHP 8's match expression for cleaner conditional logic. 🧹
Tweet media one
4
27
188
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip Do you want to keep a tab on your laravel application's queries? Just add this to the boot() method in AppServiceProvider to get them in your logs:
Tweet media one
3
20
177
@laravelbackpack
Backpack for Laravel
8 months
#Laravel Tip: Don't let database queries slow you down. Use Laravel's cache facade to cache data temporarily, reducing database queries.
Tweet media one
1
31
176
@laravelbackpack
Backpack for Laravel
4 months
1/3. Laravel Tip Did you know... While iterating through a foreach loop, a $loop variable will be available inside of your loop. This variable provides access to some useful bits of information. More info in the short 🧵👇
Tweet media one
2
22
175
@laravelbackpack
Backpack for Laravel
4 months
Laravel Collections Tip Check out the static `times` method. It creates a new collection, invoking the given closure a specified number of times.
Tweet media one
0
22
170
@laravelbackpack
Backpack for Laravel
5 months
Laravel Tip Have you ever needed a variable available in many views of your Laravel application? Here's a simple solution for that:
Tweet media one
5
15
167
@laravelbackpack
Backpack for Laravel
9 months
#PHP Tip: Make use of Laravel's "dot" notation for accessing nested array values. 🎯 Simplify accessing multidimensional arrays with a single dot-separated string.
Tweet media one
5
32
160
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip Effortlessly make concurrent HTTP requests using `pool()`:
Tweet media one
1
26
161
@laravelbackpack
Backpack for Laravel
11 months
#Laravel Tip: Optimize database performance by utilizing Laravel's query caching. By caching frequently executed queries, that are not meant to change for a while, you can reduce database load and speed up your application.
Tweet media one
1
35
155
@laravelbackpack
Backpack for Laravel
5 months
Laravel Tip Careful when you call SUM, AVG or COUNT with Pagination! - before paginate() - you get the SUM of the query; - after paginate() - you get the SUM of that page;
Tweet media one
2
27
155
@laravelbackpack
Backpack for Laravel
1 month
#Laravel Tip Find out queries that take a long time. It's simple to log them using:
Tweet media one
4
17
157
@laravelbackpack
Backpack for Laravel
6 months
Did you know... that #Laravel Faker can generate not only text values but also IMAGES? 🤯
Tweet media one
9
22
151
@laravelbackpack
Backpack for Laravel
13 days
#Laravel Tip Load data faster when the targeted value is an integer. Use 𝘄𝗵𝗲𝗿𝗲𝗜𝗻𝘁𝗲𝗴𝗲𝗿𝗜𝗻𝗥𝗮𝘄() instead of the 𝘄𝗵𝗲𝗿𝗲𝗜𝗻() method to load data faster when the targeted value is an integer.
Tweet media one
2
28
154
@laravelbackpack
Backpack for Laravel
5 months
#Laravel Tip: Use rawValue() method to get a value from a SQL expression. Here are some examples:
Tweet media one
4
24
151
@laravelbackpack
Backpack for Laravel
1 year
#Laravel Tip: The find() method is quite common, did you know it can accept multiple IDs:
Tweet media one
3
31
147
@laravelbackpack
Backpack for Laravel
7 months
#PHP Tip: Enhance readability with PHP 8 named arguments. Makes code more self-explanatory! 📖
Tweet media one
4
17
146
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip Simplify retrieving all primary keys without even passing the column name:
Tweet media one
5
20
144
@laravelbackpack
Backpack for Laravel
1 year
#Laravel Tip: You can group WHEREs using closure functions in Eloquent.
Tweet media one
1
33
142
@laravelbackpack
Backpack for Laravel
1 year
Laravel Tip: You know model properties like timestamps, appends etc but there are more...
Tweet media one
5
32
142
@laravelbackpack
Backpack for Laravel
11 months
#Laravel Tip: Use Laravel's "chunk" method when dealing with large datasets in Eloquent queries. It fetches records in smaller chunks, preventing memory issues and improving performance.
Tweet media one
4
23
140
@laravelbackpack
Backpack for Laravel
1 year
#Laravel Tip: You can pass multiple parameters to "orWhere"
Tweet media one
6
40
139
@laravelbackpack
Backpack for Laravel
9 months
Hot tip: #laravel has oldestOfMany(), newestOfMany() and ofMany(), that you can use on a hasMany relationship.
Tweet media one
0
30
140
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip: Did you know... you can easily filter complex data with Collection's `filter()` method:
Tweet media one
0
17
135
@laravelbackpack
Backpack for Laravel
9 months
#Laravel Tip: Load multiple levels of relationships with a single eager loading call. Use Laravel's with() method for eager loading nested relationships.
Tweet media one
2
23
135
@laravelbackpack
Backpack for Laravel
1 month
#Laravel Tip Do you want to keep a tab on your laravel application's queries? Just add this to the boot() method in AppServiceProvider to get them in your logs:
Tweet media one
3
15
135
@laravelbackpack
Backpack for Laravel
7 months
#Laravel Tip: You can add a URI fragment when redirecting to a route. This is super useful when redirecting to a specific section of the page. E.g. reviews section on a product page 📈
Tweet media one
3
24
132
@laravelbackpack
Backpack for Laravel
1 month
Laravel Tip ⚡️Speed up a #Laravel app by caching the entire response. You can use Spatie's ResponseCache package or create a middleware to store the response in the cache:
Tweet media one
3
16
134
@laravelbackpack
Backpack for Laravel
7 months
#Laravel Tip: Use 𝘄𝗵𝗲𝗿𝗲𝗕𝗲𝘁𝘄𝗲𝗲𝗻 to load records between two timestamps and pass the fallback value using the null coalescing operator (??).
Tweet media one
1
21
132
@laravelbackpack
Backpack for Laravel
8 months
#Laravel Tip: Limit the number of requests a user can make in a given amount of time and prevent your APIs from abuse.
Tweet media one
1
28
130
@laravelbackpack
Backpack for Laravel
17 days
#Laravel Tip Did you know about Auth::once()? You can login user only for ONE REQUEST, using method Auth::once(). No sessions or cookies will be utilized. It's helpful when building a stateless API.
Tweet media one
3
19
133
@laravelbackpack
Backpack for Laravel
2 months
Laravel Tip 💾 Transfer large files seamlessly using streams:
Tweet media one
2
28
130
@laravelbackpack
Backpack for Laravel
10 months
#PHP Tip: Make use of Laravel's "dot" notation for accessing nested array values. 🎯 Simplify accessing multidimensional arrays with a single dot-separated string.
Tweet media one
4
16
126
@laravelbackpack
Backpack for Laravel
22 days
#Laravel Tip Don't let database queries slow you down. Use Laravel's cache facade to cache data temporarily, reducing database queries.
Tweet media one
5
18
126
@laravelbackpack
Backpack for Laravel
7 months
#Laravel Tip: Load data faster when the targeted value is an integer. Use 𝘄𝗵𝗲𝗿𝗲𝗜𝗻𝘁𝗲𝗴𝗲𝗿𝗜𝗻𝗥𝗮𝘄() instead of the 𝘄𝗵𝗲𝗿𝗲𝗜𝗻() method to load data faster when the targeted value is an integer.
Tweet media one
2
27
126
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip Did you know...you can temporarily disable timestamps when saving a model?
Tweet media one
1
15
125
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip Did you know... you can eager load nested relations using clean array syntax:
Tweet media one
2
14
123
@laravelbackpack
Backpack for Laravel
4 months
Laravel Tip When a user updates their password, it's more secure to also change the API Token - right? Here's how to quickly do it via mutator:
Tweet media one
1
17
122
@laravelbackpack
Backpack for Laravel
6 months
#Laravel Tip: The eloquent's method `orderByRaw()` let's us simply pass a raw query to order the results. For example, sorting by the difference between two columns.
Tweet media one
1
21
121
@laravelbackpack
Backpack for Laravel
10 months
#Laravel Tip: ⚙️ Chain multiple jobs together, to be executed one after the other, using Laravel:
Tweet media one
0
28
120
@laravelbackpack
Backpack for Laravel
7 months
Did you know #Laravel has 'production' & 'env' blade directives that help us to show data in the specific environment?
Tweet media one
2
22
118
@laravelbackpack
Backpack for Laravel
5 months
Laravel Tip Do you want to test email contents in your app but unable/unwilling to set up something like Mailgun? Just use the .env parameter MAIL_DRIVER=log and all the emails will be saved into storage/logs/laravel.log file, instead of being sent.
Tweet media one
4
15
117
@laravelbackpack
Backpack for Laravel
5 months
Laravel Tip Did you know about Auth::once()? You can login user only for ONE REQUEST, using method Auth::once(). No sessions or cookies will be utilized. It's helpful when building a stateless API.
Tweet media one
0
16
116
@laravelbackpack
Backpack for Laravel
26 days
#Laravel Tip Effortlessly make concurrent HTTP requests using `pool()`:
Tweet media one
2
18
116
@laravelbackpack
Backpack for Laravel
12 days
#Laravel Tip Did you know... Laravel has 'production' and 'env' blade directives that help us to show data in the specific environment?
Tweet media one
1
21
114
@laravelbackpack
Backpack for Laravel
1 month
#Laravel Tip Did you know... about the skip method of Laravel's scheduler? You can define inside skip() when the command should NOT be executed:
Tweet media one
2
20
115
@laravelbackpack
Backpack for Laravel
2 months
Laravel Tip Do you use Expressive "Where" syntax in your project?
Tweet media one
5
10
112
@laravelbackpack
Backpack for Laravel
16 days
#Laravel Tip Laravel has oldestOfMany(), newestOfMany() and ofMany(), that you can use on a hasMany relationship.
Tweet media one
1
16
112
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip Did you know...you can mask part of a string like passwords or credit card numbers using `Str::mask()`:
Tweet media one
0
18
107
@laravelbackpack
Backpack for Laravel
6 months
Did you know... #Laravel has a Benchmark class that lets you measure the time of any task:
Tweet media one
0
15
104
@laravelbackpack
Backpack for Laravel
6 months
#Laravel Tip: If you have an API endpoint which performs some operations but has an empty response, make sure to return 204 status code "No content":
Tweet media one
1
15
106
@laravelbackpack
Backpack for Laravel
10 days
#PHP Tip Make use of Laravel's "dot" notation for accessing nested array values. 🎯 Simplify accessing multidimensional arrays with a single dot-separated string.
Tweet media one
3
15
120
@laravelbackpack
Backpack for Laravel
14 days
#Laravel Tip When a user updates their password, it's more secure to also change the API Token - right? Here's how to quickly do it via mutator:
Tweet media one
3
11
106
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip Simplify existence checks with Eloquent via methods `exists()` & `doesntExist()` 🧑‍💻 One-liner, hassle-free existence checks:
Tweet media one
2
16
102
@laravelbackpack
Backpack for Laravel
23 days
#Laravel Tip: Did you know... you can easily filter complex data with Collection's `filter()` method:
Tweet media one
1
11
99
@laravelbackpack
Backpack for Laravel
4 months
#PHP Tip Did you know about "First-class callable syntax"? Using the first-class callable syntax, you simply call the function or method followed by an ellipsis (...) to create a first-class callable. That way, you can rewrite that code like this:
Tweet media one
2
13
97
@laravelbackpack
Backpack for Laravel
4 months
Laravel Tip Did you know that you can re-use an existing Laravel Eloquent scope in defining a new relationship, instead of writing the conditions all over again?
Tweet media one
3
10
98
@laravelbackpack
Backpack for Laravel
2 months
Laravel Tip Did you ever need to generate temporary URLs for file downloads in #Laravel ? Use the temporaryUrl() method to generate a signed temporary URL valid for the specified duration:
Tweet media one
3
13
96
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip Everybody knows how to query soft-deleted models by using `Post::withTrashed()` Did you know... you can also use it on an entire route?
Tweet media one
0
14
95
@laravelbackpack
Backpack for Laravel
1 year
#Laravel Tip: Want to use UUID as primary keys in your Laravel models? 🆔 Simply set the 'uuid' attribute as the primary key and the 'string' as the key type. Laravel handles UUID generation automatically! 😍
Tweet media one
2
23
90
@laravelbackpack
Backpack for Laravel
19 days
#Laravel Tip The eloquent's method `orderByRaw()` lets us simply pass a raw query to order the results. For example, sorting by the difference between two columns.
Tweet media one
1
18
91
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip Simplify workflows by streamlining your tasks with Pipelines! 🚀 Use the Pipeline class to organize complex processes step by step:
Tweet media one
Tweet media two
1
13
89
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip Do you want to know how your scheduled task performed at midnight? You are in luck! You can easily save or email the output of your scheduled tasks:
Tweet media one
0
14
88
@laravelbackpack
Backpack for Laravel
4 months
Laravel Tip You can use the when() or unless() methods in your MailMessage notifications to add conditional content.
Tweet media one
0
14
87
@laravelbackpack
Backpack for Laravel
28 days
#Laravel Tip Be careful when you call SUM, AVG, or COUNT with Pagination! - before paginate() - you get the SUM of the query; - after paginate() - you get the SUM of that page;
Tweet media one
0
12
86
@laravelbackpack
Backpack for Laravel
5 months
#Laravel Tip: You can run the Artisan command not only from the Terminal but from Code as well. Use Artisan::call() method:
Tweet media one
1
21
85
@laravelbackpack
Backpack for Laravel
11 months
#Laravel Tip: Enhance validation by creating custom validation rules in Laravel. You can define your own rules to handle complex validation scenarios, specific to your application.
Tweet media one
Tweet media two
3
22
82
@laravelbackpack
Backpack for Laravel
1 year
#Laravel Tip: You can keep a check on performance leaks during development, using laravel's Strict Mode. It was introduced in Laravel 9.
Tweet media one
0
20
84
@laravelbackpack
Backpack for Laravel
1 month
1/3. #Laravel Tip Did you know... While iterating through a foreach loop, a $loop variable will be available inside your loop. This variable provides access to some useful bits of information. More info in the short 🧵👇
Tweet media one
1
9
83
@laravelbackpack
Backpack for Laravel
1 month
#Laravel Collections Tip Check out the static `times` method. It creates a new collection, invoking the given closure a specified number of times.
Tweet media one
0
12
81
@laravelbackpack
Backpack for Laravel
7 months
#Laravel Tip: You can get all primary keys from an Eloquent Collection using the modelKeys() method.
Tweet media one
2
11
80
@laravelbackpack
Backpack for Laravel
2 months
Laravel Tip You can schedule routine cleanup, to avoid overflowing log files:
Tweet media one
1
14
81
@laravelbackpack
Backpack for Laravel
1 month
#Laravel Tip You may want to get only those rows that have child rows. Here's how you can do it:
Tweet media one
3
3
79
@laravelbackpack
Backpack for Laravel
2 months
Laravel Tip We usually specify the column's default value in migration. Did you know… you can specify default attribute values in the Models as well:
Tweet media one
3
6
80
@laravelbackpack
Backpack for Laravel
8 months
🔥 #Laravel Tip: In scheduled tasks, you can specify what to do if a scheduled task fails or succeeds.
Tweet media one
1
16
77
@laravelbackpack
Backpack for Laravel
11 months
#Laravel Tip: Simplify eager loading with Laravel's withDefault() method. 🔍 Load relationships and provide default values if the related model does not exist.
Tweet media one
1
16
77
@laravelbackpack
Backpack for Laravel
2 months
Laravel Tip Check out some handy Laravel helper methods for a smoother coding experience!🧵👇
Tweet media one
Tweet media two
3
8
76
@laravelbackpack
Backpack for Laravel
7 months
#Laravel tip: You can create custom disks at runtime without the need to have the config in your config/filesystems file. This can be handy to manage files in custom paths.
Tweet media one
0
10
77
@laravelbackpack
Backpack for Laravel
20 days
#Laravel Tip Use 𝘄𝗵𝗲𝗿𝗲𝗕𝗲𝘁𝘄𝗲𝗲𝗻 to load records between two timestamps and pass the fallback value using the null coalescing operator (??).
Tweet media one
1
12
75
@laravelbackpack
Backpack for Laravel
1 month
#Laravel Tip Sometimes, you may want to prevent saving or updating on some condition or stop some users from updating records. Here is a simple trick to prevent saving or updating via model events:
Tweet media one
2
9
76
@laravelbackpack
Backpack for Laravel
1 year
#Laravel Tip: you can save a model and its corresponding relationships using the push() method. It will save() and sync() at the same time!
Tweet media one
0
24
73
@laravelbackpack
Backpack for Laravel
4 months
Laravel Tip Create Your Own Blade Directive! It’s very easy - just add your own method in app/Providers/AppServiceProvider.php.
Tweet media one
0
13
72
@laravelbackpack
Backpack for Laravel
3 months
Laravel Tip We often convert values while displaying in views or taking inputs in controllers before saving! Better, we define `Accessor` & `Mutator` in our model once. It converts the attribute every time before saving or retrieving it. Quick example:
Tweet media one
3
6
73
@laravelbackpack
Backpack for Laravel
11 months
#Laravel Tip: Improve code readability with Laravel's optional helper function. 🕶️ Simplify accessing properties or calling methods on potentially null values.
Tweet media one
4
14
69
@laravelbackpack
Backpack for Laravel
2 months
Laravel Tip Did you know about Boot Eloquent Traits? For example, if you have multiple models with slug, you don't want to rewrite the slug creation logic in every model. You can define a trait and use a boot* method:
Tweet media one
4
14
70
@laravelbackpack
Backpack for Laravel
3 months
GraphQL is the future of APIs !!! Wanna know, how you can build GraphQL APIs on your Laravel app?
Tweet media one
4
7
71
@laravelbackpack
Backpack for Laravel
5 months
#Laravel Tip: Execute a Closure after the command runs without errors or has any errors:
Tweet media one
0
11
67
@laravelbackpack
Backpack for Laravel
10 months
#Laravel Tip: Use Laravel's optional() helper with a callback to handle null values gracefully. 🕶️ That way, you can perform operations on potentially null values without throwing errors.
Tweet media one
2
8
64
@laravelbackpack
Backpack for Laravel
21 days
#PHP Tip Enhance readability with PHP 8 named arguments. It makes code more self-explanatory! 📖
Tweet media one
0
7
65
@laravelbackpack
Backpack for Laravel
2 months
Laravel Tip Did you want to do something when your scheduled tasks either succeeded or failed? You can use the `onSuccess()` or `onFailure()` callbacks to take any action you want!
Tweet media one
1
14
65
@laravelbackpack
Backpack for Laravel
11 months
Tip: In #Laravel , several core classes are "macroable," which means you can add functionality without modifying the core code.
Tweet media one
Tweet media two
0
19
64
@laravelbackpack
Backpack for Laravel
1 month
#Laravel Tip You can set a default order in your relationships. It'll help you get consistent & organized data. 🌟
Tweet media one
1
7
63
@laravelbackpack
Backpack for Laravel
15 days
#Laravel Tip Did you know... you can temporarily disable timestamps when saving a model?
Tweet media one
1
4
62
@laravelbackpack
Backpack for Laravel
6 months
#Laravel Tip: Don't parse API headers manually to get the access token from authorization header. Do this instead:
Tweet media one
0
7
56
@laravelbackpack
Backpack for Laravel
1 year
#Laravel Tip: whereX can make your queries expressive. Append any field name to “where” as a suffix and it will work - like magic!
Tweet media one
3
16
58