Applies on Laravel 8
These are the things I learned when learning to develop using Laravel 8 from scratch:
Use packagist for installing composer packages
composer require packagename
.env file –> .gitignore!
.env file -> disable debug on production
SQL
Spaces in column names? Use backtick (shift+~) to enclose
datetime must be converted into datetime object (if string)
multiple inputs in forms? Use for loop, not foreach, like so:
Do NOT use raw mode for query builder. It will make your system more vulnerable to SQL injection.
Forms can be as big as you want, with inputs spanning within tabs. Think out of the box.
Eloquent
Don’t use (model)->update(blabla) because you can’t getDirty() later
getDirty() to get modified values after last model get
save AFTER getDirty(), if not then it’d be blank
Controllers
You can do this to separate keys and values
foreach ($variable->getDirty() as $key=>$value)
If Foreach fails use regular For
for ($i=0; $i<count($Variable); $i++)
Or just move the i++ to inside the for, works too.
Blade
Use partials (separate parts of Blade) whenever possible. Then
@include('blade.file.path.using.dot.notation')