public function handle()
{
$this->info("Publishing the assets");
$this->call('vendor:publish', ['--provider' => 'Appzcoder\\LaravelAdmin\\LaravelAdminServiceProvider']);
$this->info("Dumping the composer autoload");
(new Process('composer dump-autoload'))->run();
$this->info("Migrating the database tables into your application");
$this->call('migrate');
$this->info("Adding the routes");
$routeFile = app_path('Http/routes.php');
if (\App::VERSION() >= '5.3') {
$routeFile = base_path('routes/web.php');
}
$routes = <<<EOD
Route::get('admin', 'Admin\\AdminController@index');
Route::get('admin/give-role-permissions', 'Admin\\AdminController@getGiveRolePermissions');
Route::post('admin/give-role-permissions', 'Admin\\AdminController@postGiveRolePermissions');
Route::resource('admin/roles', 'Admin\\RolesController');
Route::resource('admin/permissions', 'Admin\\PermissionsController');
Route::resource('admin/users', 'Admin\\UsersController');
EOD;
File::append($routeFile, "\n" . $routes);
$this->info("Generating the authentication scaffolding");
$this->call('make:auth');
$this->info("Overriding the AuthServiceProvider");
$contents = File::get(__DIR__ . '/publish/Providers/AuthServiceProvider.php');
File::put(app_path('Providers/AuthServiceProvider.php'), $contents);
$this->info("Successfully installed Laravel Admin!");
}