added additional field to category

This commit is contained in:
peternuernberger 2020-09-07 16:38:54 +02:00
parent 702ef4410a
commit f7a89da0c7
3 changed files with 42 additions and 1 deletions

View File

@ -26,6 +26,9 @@ class Category extends JsonResource
'meta_keywords' => $this->meta_keywords,
'status' => $this->status,
'image_url' => $this->image_url,
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAdditionalToCategory extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('categories', function (Blueprint $table) {
$table->json('additional')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('categories', function (Blueprint $table) {
$table->dropColumn('additional');
});
}
}

View File

@ -31,7 +31,13 @@ class Category extends TranslatableModel implements CategoryContract
'meta_keywords',
];
protected $fillable = ['position', 'status', 'display_mode', 'parent_id'];
protected $fillable = [
'position',
'status',
'display_mode',
'parent_id',
'additional',
];
protected $with = ['translations'];