Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
forbidals
/
admin_panel
/
app
/
Console
/
Commands
:
MigrateSchoolRollbackTable.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Console\Commands; use App\Models\School; use Illuminate\Console\Command; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\DB; class MigrateSchoolRollbackTable extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'migrate:school:rollback'; /** * The console command description. * * @var string */ protected $description = 'Command description'; /** * Execute the console command. */ public function handle() { // $schools = School::withTrashed()->get(); foreach ($schools as $key => $school) { Config::set('database.connections.school.database', $school->database_name); DB::purge('school'); DB::connection('school')->reconnect(); DB::setDefaultConnection('school'); Artisan::call('migrate:rollback', [ '--database' => 'school', '--path' => 'database/migrations/schools' ]); } } }