Skip to content

Commit ae5bdaa

Browse files
Merge pull request #27 from khalidmaquilang/feature/si-25-product-subcategory
Feature | category and product
2 parents 069ec24 + 880b980 commit ae5bdaa

15 files changed

+45
-197
lines changed

app/Filament/Pages/Settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Settings extends Page implements HasForms
3030

3131
protected static ?string $navigationGroup = 'Admin Menu';
3232

33-
protected static ?int $navigationSort = 5;
33+
protected static ?int $navigationSort = 4;
3434

3535
protected static string|array $withoutRouteMiddleware = [OnboardingMiddleware::class];
3636

app/Filament/Resources/CategoryResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public static function form(Form $form): Form
2424
{
2525
return $form
2626
->schema([
27+
Forms\Components\Select::make('category_id')
28+
->relationship('category', 'name', ignoreRecord: true)
29+
->nullable(),
2730
Forms\Components\TextInput::make('name')
2831
->required()
2932
->maxLength(255),
@@ -36,6 +39,9 @@ public static function table(Table $table): Table
3639
{
3740
return $table
3841
->columns([
42+
Tables\Columns\TextColumn::make('category.name')
43+
->label('Parent Category')
44+
->sortable(),
3945
Tables\Columns\TextColumn::make('name')
4046
->searchable(),
4147
Tables\Columns\TextColumn::make('created_at')

app/Filament/Resources/PaymentTypeResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class PaymentTypeResource extends Resource
1818

1919
protected static ?string $navigationGroup = 'Admin Menu';
2020

21-
protected static ?int $navigationSort = 3;
21+
protected static ?int $navigationSort = 2;
2222

2323
public static function form(Form $form): Form
2424
{

app/Filament/Resources/ProductResource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static function table(Table $table): Table
2727
{
2828
return $table
2929
->columns([
30+
Tables\Columns\TextColumn::make('category.name'),
3031
Tables\Columns\TextColumn::make('sku')
3132
->label('SKU')
3233
->searchable(),

app/Filament/Resources/SubCategoryResource.php

Lines changed: 0 additions & 84 deletions
This file was deleted.

app/Filament/Resources/SubCategoryResource/Pages/CreateSubCategory.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

app/Filament/Resources/SubCategoryResource/Pages/EditSubCategory.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

app/Filament/Resources/SubCategoryResource/Pages/ListSubCategories.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

app/Filament/Resources/UserResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class UserResource extends Resource
1818

1919
protected static ?string $navigationIcon = 'heroicon-o-user';
2020

21-
protected static ?int $navigationSort = 4;
21+
protected static ?int $navigationSort = 3;
2222

2323
public static function form(Form $form): Form
2424
{

app/Models/Category.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Database\Eloquent\Factories\HasFactory;
66
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
78
use Illuminate\Database\Eloquent\Relations\HasMany;
89
use Illuminate\Database\Eloquent\SoftDeletes;
910

@@ -20,8 +21,23 @@ class Category extends Model
2021
'id' => 'integer',
2122
];
2223

23-
public function subCategories(): HasMany
24+
/**
25+
* Belongs To Parent Category
26+
*
27+
* @return BelongsTo
28+
*/
29+
public function category(): BelongsTo
30+
{
31+
return $this->belongsTo(self::class);
32+
}
33+
34+
/**
35+
* Category has many category
36+
*
37+
* @return HasMany
38+
*/
39+
public function categories()
2440
{
25-
return $this->hasMany(SubCategory::class);
41+
return $this->hasMany(self::class);
2642
}
2743
}

0 commit comments

Comments
 (0)