Skip to content

Commit

Permalink
added subtitle to category
Browse files Browse the repository at this point in the history
  • Loading branch information
A1Gard committed Apr 9, 2024
1 parent 36cb6a8 commit 36bafb9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions database/migrations/create_starter_kit_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CreateStarterKitTable extends Migration
$table->id();
$table->string('name', 128);
$table->string('slug', 128)->unique();
$table->string('subtitle')->nullable();
$table->text('description')->nullable();
$table->integer('sort')->default(0);
$table->unsignedInteger('parent_id')->nullable()->default(null)->index();
Expand Down
7 changes: 7 additions & 0 deletions resources/views/admin/category/categoryForm.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
<input name="name" type="text" class="form-control @error('name') is-invalid @enderror"
placeholder="{{__('Category name')}}" value="{{old('name',$ccat->name??null)}}"/>
</div>
<div class="col-md-8 mt-3">
<label for="subtitle">
{{__('Subtitle')}}
</label>
<input name="subtitle" type="text" class="form-control @error('subtitle') is-invalid @enderror"
placeholder="{{__('Subtitle')}}" value="{{old('subtitle',$ccat->subtitle??null)}}"/>
</div>
<div class="col-md-8 mt-3">
<label for="parent">
{{__('Category Parent')}}
Expand Down
1 change: 1 addition & 0 deletions src/Controllers/Admin/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function createOrUpdate(Category $cat, CategorySaveRequest $request)
$cat->name = $request->input('name');
$cat->slug = \StarterKit::slug($request->input('name'));
$cat->description = $request->input('description');
$cat->subtitle = $request->input('subtitle');
$cat->parent_id = $request->input('parent') == '' ? null : $request->input('parent');
$cat->save();

Expand Down
2 changes: 1 addition & 1 deletion src/Models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Category extends Model
{
use SoftDeletes,HasTranslations;

public $translatable = ['name','description'];
public $translatable = ['name','description','subtitle'];
public function posts()
{
return $this->belongsToMany(Post::class);
Expand Down

0 comments on commit 36bafb9

Please sign in to comment.