The Laravel Dev

486 posts

The Laravel Dev banner
The Laravel Dev

The Laravel Dev

@TheLaravelDev

🚀 Laravel / PHP Tips | YouTube: https://t.co/ORdNufCN8d | Blogs: https://t.co/yc2lXv5Vdd 🤝 Our dev team is open for outsourcing partnerships! DM open.

Katılım Aralık 2020
40 Takip Edilen5.8K Takipçiler
Sabitlenmiş Tweet
The Laravel Dev
The Laravel Dev@TheLaravelDev·
While adding a New Column to existing table using Migration, the column is always added at the last. ✅You can use the after() to place the New Column after a specific column. ✅You can also use the first() to place the New Column at the start of the table. #Laravel
The Laravel Dev tweet media
English
9
23
95
0
The Laravel Dev
The Laravel Dev@TheLaravelDev·
TIL about the intended() which sends users to their originally requested page after authentication, or to '/fallback' if no previous URL. redirect()->intended('/fallback'); Great for maintaining user flow after login!
English
0
1
5
782
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Did you know that Laravel Artisan command has table method to output data. 👉 Cleaner, more readable output 👉 Automatic column alignment 👉 Easy to scan and compare data 👉 Professional-looking results
The Laravel Dev tweet media
English
0
2
23
2K
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Have you tried Str::slug method in Laravel? 👉 It handles multiple spaces 👉 It handles special characters 👉 It also handles other languages. 🔥 You can also specify the separator and language other than english.
The Laravel Dev tweet media
English
0
3
9
651
The Laravel Dev
The Laravel Dev@TheLaravelDev·
"avoid using else" is one of the interesting tips for writing clean code. We cann't fully avoid it but remove un-necessary else. In following code, we can even simplify using ternary operator.
The Laravel Dev tweet media
English
7
8
87
7.1K
The Laravel Dev
The Laravel Dev@TheLaravelDev·
@ErikSlooff yes, I also prefer 2nd example. If condition become complex in future or new logic needs to be inserted, it is easier to change 2nd block of code.
English
0
0
1
161
Erik Slooff
Erik Slooff@ErikSlooff·
@TheLaravelDev While I agree that the third example is “compact” I find the second example easier to read when scanning large chunks of code.🤔
English
1
0
3
182
Jonathan Dey
Jonathan Dey@jonathandey·
@TheLaravelDev The Hash facade has a “isHashed” method you can you as well: #method_isHashed" target="_blank" rel="nofollow noopener">laravel.com/api/11.x/Illum…
English
1
0
4
254
The Laravel Dev
The Laravel Dev@TheLaravelDev·
TIL that Laravel uses bcrypt for hashing the password by default. The hashed password is always 60 char long and always starts with $2y$. Came across following code which was used to check whether Password is hashed.
The Laravel Dev tweet media
English
3
6
50
4.5K
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Str::after() in Laravel makes code cleaner and more intuitive. Same code using raw PHP involves using multiple methods and some gymnastics with substr() and strpos().
The Laravel Dev tweet media
English
1
11
89
5.3K
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Write Clean code by refactoring the nested code into what is referred to as Guard Clauses. Below is an example. For more such examples and link to free e-book check out the next tweet.
The Laravel Dev tweet media
English
6
7
140
44.6K
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Be specific with your database queries! 👉Use select() to fetch only the columns you need, 👉You can even do this for related Model. 🔥Laravel also provides a alternate short-cut for selecting related Model column.
The Laravel Dev tweet media
English
1
19
96
7.9K
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Checking if a string starts with a specific substring? Ditch strpos() === 0. Laravel's Str::startsWith() or PHP 8's str_starts_with() have got you covered!
The Laravel Dev tweet media
English
0
3
14
1.2K
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Need to truncate long strings in Laravel. Use Str::limit(). Perfect for summaries or previews!
The Laravel Dev tweet media
English
0
9
42
2.9K
The Laravel Dev retweetledi
Taylor Otwell
Taylor Otwell@taylorotwell·
I'm excited to announce that Laravel has raised a $57M Series A in partnership with Accel. I believe that Laravel is the most productive way to build full-stack web applications, and Laravel Cloud will be the platform for shipping those applications that this community deserves.
Taylor Otwell tweet media
English
313
646
4K
984.5K
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Catch N+1 Query Issues in your Laravel App. 👉Instantly alerts you to potential performance issues. 👉Forces efficient eager loading 👉Helps maintain performant code as your app grows Make sure to only enable it in Development Mode.
The Laravel Dev tweet media
English
0
9
26
1.1K
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Scopes in Laravel are used to add constraint to the query using where conditions. But did you know that you can use them to encapsulate 'with' relationships too!
The Laravel Dev tweet media
English
0
12
54
2.9K
The Laravel Dev retweetledi
The Laravel Dev
The Laravel Dev@TheLaravelDev·
TIL that you can apply Higher Order orWhere Method on Local Scope. Helps to avoid the closure and makes the code readable.
The Laravel Dev tweet media
English
2
29
120
0
The Laravel Dev retweetledi
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Laravel makes it so easy to fetch a Record using a column other than the primary key. For those new to Laravel, this feature is known as Route Model Binding.
The Laravel Dev tweet media
English
1
21
71
0
The Laravel Dev
The Laravel Dev@TheLaravelDev·
Eloquent has the increment() method to increase the value of a column. 👉 Can increment by a specific value. 👉 Works with Decimal as well. 👉 Its Atomic as no need to fetch Model. 👉 Can update other columns simultaneously. 🔥There is also a decrement() method.
The Laravel Dev tweet media
English
0
7
19
1.1K