Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
development:php:laravel [2020/02/27 14:47] kalenpw |
development:php:laravel [2021/06/29 15:15] (current) kalenpw [Add column to existing table] |
||
---|---|---|---|
Line 18: | Line 18: | ||
</ | </ | ||
- | To allow CORS for all routes, add the HandleCors middleware in the $middleware property of app/ | + | To allow CORS for all routes, add the HandleCors middleware in the '' |
<code php> | <code php> | ||
protected $middleware = [ | protected $middleware = [ | ||
Line 44: | Line 44: | ||
php artisan vendor: | php artisan vendor: | ||
</ | </ | ||
+ | |||
+ | ---- | ||
+ | ===== Database ===== | ||
+ | ** Add column to existing table ** \\ | ||
+ | <code bash> | ||
+ | php artisan make: | ||
+ | </ | ||
+ | <code php> | ||
+ | public function up() | ||
+ | { | ||
+ | Schema:: | ||
+ | $table-> | ||
+ | // to set default value: | ||
+ | $table-> | ||
+ | }); | ||
+ | } | ||
+ | </ | ||
+ | and a rollback option | ||
+ | <code php> | ||
+ | public function down() | ||
+ | { | ||
+ | Schema:: | ||
+ | $table-> | ||
+ | }); | ||
+ | } | ||
+ | </ | ||
+ | then run migration | ||
+ | <code bash> | ||
+ | php artisan migrate | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | ===== Order By ===== | ||
+ | <code php> | ||
+ | $users = DB:: | ||
+ | -> | ||
+ | ->get(); | ||
+ | // or | ||
+ | |||
+ | $projects = \App\Project:: | ||
+ | </ | ||
+ | |||
+ | ---- |