Migration move media table and fixed attribute issue

This commit is contained in:
cuneytsenturk
2018-01-03 20:08:56 +03:00
parent 3c15d3e96f
commit 5788233c2e
10 changed files with 72 additions and 8 deletions

View File

@@ -24,5 +24,33 @@ class Version116 extends Listener
return;
}
$migrations = [
'\App\Models\Auth\User' => 'picture',
'\App\Models\Item\Item' => 'picture',
'\App\Models\Expense\Bill' => 'attachment',
'\App\Models\Expense\BillPayment' => 'attachment',
'\App\Models\Expense\Payment' => 'attachment',
'\App\Models\Income\Invoice' => 'attachment',
'\App\Models\Income\InvoicePayment' => 'attachment',
'\App\Models\Income\Revenue' => 'attachment',
];
foreach ($migrations as $model => $name) {
if ($model != '\App\Models\Auth\User') {
$items = $model::where('company_id', '<>', '0')->get();
} else {
$items = $model::all();
}
foreach ($items as $item) {
if ($item->$name) {
$path = explode('uploads/', $item->$name);
$media = MediaUploader::importPath(config('mediable.default_disk'), $path[1]);
$item->attachMedia($media, $name);
}
}
}
}
}