php -S 0.0.0.0:8080 -t public/
composer global require "laravel/installer=~1.1"
composer create-project laravel/laravel myapp
php artisan tinker
For example, seed user table:
$ php artisan tinker
>>> factory(App\User::class, 100)->create();
In folder /config/app.php
add the package provider and aliases.
php artisan key:generate
php artisan serve
php artisan make:model Task --migration --controller --resource
php artisan route:list
php artisan view:clear
Migrate
php artisan migrate
Drop Tables and Migrate again
php artisan migrate:fresh
Create Migrations
php artisan make:migration 'create_user_role_table'
Migrate specific migration
php artisan migrate --path=/database/migrations/specificMigration/
Add fields to table
php artisan make:migration add_publishers_id_to_collections --table="collections"
public function up()
{
Schema::table('images', function (Blueprint $table) {
$table->integer('publishers_id')->nullable($value = true);
});
}
public function down()
{
Schema::table('images', function (Blueprint $table) {
$table->dropColumn('publishers_id');
});
}
Create Seed
php artisan make:seeder TaskTableSeeder
Seed database (existing data is NOT deleted)
php artisan db:seed
Seed database and re-run migrations
php artisan migrate:refresh --seed
Seed specific seeder file
php artisan db:seed --class=UsersTableSeeder
Scaffold authentication
php artisan make:auth
Create Middleware
php artisan make:middleware CheckRole
Create controller with resources (CRUD)
php artisan make:controller AdminController --resource
- Make a command
php artisan make:command TestCommand
- Add the following to the
kernel.php
file:
protected $commands = [
//This is the line of code added, at the end, we the have class name of DeleteInActiveUsers.php inside app\console\commands
Commands\CoinMarketCapOverview::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
//insert name and signature of you command and define the time of excusion
$schedule->command('TestCommand:deleteusers')
->everyMinute();
}
php artisan list
should show the command
DONE.
php artisan preset react
Swaps out the Vue scaffolding with React scaffolding.
php artisan preset none
Removes all scaffolding.
Throw exception in code:
throw new \ErrorException('Error found');