2015-12-07 23:00:34 +00:00
|
|
|
<?php
|
|
|
|
|
2018-09-25 11:30:50 +00:00
|
|
|
use BookStack\Uploads\Image;
|
2015-12-07 23:00:34 +00:00
|
|
|
use Illuminate\Database\Migrations\Migration;
|
2021-06-26 15:23:15 +00:00
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
2015-12-07 23:00:34 +00:00
|
|
|
|
|
|
|
class AddImageUploadTypes extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
Schema::table('images', function (Blueprint $table) {
|
|
|
|
$table->string('path', 400);
|
|
|
|
$table->string('type')->index();
|
|
|
|
});
|
|
|
|
|
2021-06-26 15:23:15 +00:00
|
|
|
Image::all()->each(function ($image) {
|
2015-12-07 23:00:34 +00:00
|
|
|
$image->path = $image->url;
|
|
|
|
$image->type = 'gallery';
|
|
|
|
$image->save();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::table('images', function (Blueprint $table) {
|
|
|
|
$table->dropColumn('type');
|
|
|
|
$table->dropColumn('path');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|