Laravel Pro Tips
#Laravel Migration Tip 🔥
You can use the `from` method to set the starting value of an auto-incrementing field.
#Laravel tip 🔥 virtual generated column
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 #PHP
Aftab Khan 🚀
🔥 I have been using #Laravel for years and I just discovered the migrate:status command. It shows you which migrations have run so far.
🔥 #Laravel Tip: Sometimes you need to seed a database with millions of records e.g. for stress-testing. To avoid crippling the DB with millions of ‘create’ queries, instead consider ‘making’ a large collection of models, then chunk and insert them.
🔥 Laravel Tip: In your migrations, you can add multiple columns after another column using the after method.
#Laravel Tip 🔥 : Now you can add the column in the database table only if its not present & can drop it if, its present. For that following methods are introduced:
Let's see example:
#PHP #100devs #100DaysOfCode #webdeveloper
Mohammad Haris ⚡
🔥 #Laravel #Eloquent Tip:
The new concept "invisible column" in MySQL8 enables you to hide the column value when you run the `select *` query. To get the value you need to `select` explicitly.
In Laravel use `->invisble()` in table migration.
🔥 #Laravel Tip: you can define default values for columns in two places: Migrations and models.
Via Models you can specify default attribute values and change them time by time only in code level, while in migration you need to write extra migration.
#Laravel $Tip #Php
No articles were found.