From 5e276cf5ea9607c950cca9b6743278955fb9d0c0 Mon Sep 17 00:00:00 2001 From: bahman Date: Sat, 21 Dec 2024 17:55:05 +0330 Subject: [PATCH] wip --- .../Filament/Resources/CategoryResource.php | 4 ++- .../app/Filament/Resources/UserResource.php | 2 +- ShopFlow/app/Models/Category.php | 1 - ShopFlow/app/Providers/AppServiceProvider.php | 1 - .../0001_01_01_000000_create_users_table.php | 4 +-- ..._08_01_080210_create_permission_tables.php | 30 ++++++++++++------- ...2024_08_01_080211_create_imports_table.php | 4 ++- ...2024_08_01_080212_create_exports_table.php | 4 ++- ...080213_create_failed_import_rows_table.php | 4 ++- ...24_08_07_033330_create_provinces_table.php | 2 ++ .../2024_08_07_033430_create_cities_table.php | 2 ++ ...24_08_07_033435_create_addresses_table.php | 5 +++- .../2024_08_07_151806_create_images_table.php | 2 ++ ...4_08_07_151807_create_categories_table.php | 2 ++ 14 files changed, 47 insertions(+), 20 deletions(-) diff --git a/ShopFlow/app/Filament/Resources/CategoryResource.php b/ShopFlow/app/Filament/Resources/CategoryResource.php index 09050145..3fe63141 100644 --- a/ShopFlow/app/Filament/Resources/CategoryResource.php +++ b/ShopFlow/app/Filament/Resources/CategoryResource.php @@ -97,7 +97,9 @@ public static function table(Table $table): Table ->sortable(), Tables\Columns\ImageColumn::make('images') ->getStateUsing(function (Category $record) { - return $record->images->first()?->path; + /** @var \Illuminate\Database\Eloquent\Collection|\App\Models\Image[] $images */ + $images = $record->images; + return $images->first()?->path; }), Tables\Columns\TextColumn::make('created_at') diff --git a/ShopFlow/app/Filament/Resources/UserResource.php b/ShopFlow/app/Filament/Resources/UserResource.php index c39a8b7f..52e52236 100644 --- a/ShopFlow/app/Filament/Resources/UserResource.php +++ b/ShopFlow/app/Filament/Resources/UserResource.php @@ -188,7 +188,7 @@ public static function getEloquentQuery(): Builder $query = parent::getEloquentQuery(); $query->whereNot('id', auth()->id()); if (! auth()->user()->hasRole(RolesEnum::SUPER_ADMIN->value) && auth()->user()->hasRole(RolesEnum::ADMIN->value)) { - $query->withoutRole(RolesEnum::SUPER_ADMIN->value); + $query->withoutRole(RolesEnum::SUPER_ADMIN->value); // @phpstan-ignore-line } return $query; diff --git a/ShopFlow/app/Models/Category.php b/ShopFlow/app/Models/Category.php index 78828c6a..5ee5b163 100644 --- a/ShopFlow/app/Models/Category.php +++ b/ShopFlow/app/Models/Category.php @@ -46,7 +46,6 @@ class Category extends Model 'status', ]; - public function images(): MorphMany { return $this->morphMany(Image::class, 'imageable'); diff --git a/ShopFlow/app/Providers/AppServiceProvider.php b/ShopFlow/app/Providers/AppServiceProvider.php index 5e033d7a..8325058d 100644 --- a/ShopFlow/app/Providers/AppServiceProvider.php +++ b/ShopFlow/app/Providers/AppServiceProvider.php @@ -24,4 +24,3 @@ public function boot(): void // } } - diff --git a/ShopFlow/database/migrations/0001_01_01_000000_create_users_table.php b/ShopFlow/database/migrations/0001_01_01_000000_create_users_table.php index 38212b7d..76336570 100644 --- a/ShopFlow/database/migrations/0001_01_01_000000_create_users_table.php +++ b/ShopFlow/database/migrations/0001_01_01_000000_create_users_table.php @@ -19,9 +19,9 @@ public function up(): void $table->string('last_name'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); - $table->string('mobile',20)->nullable(); + $table->string('mobile', 20)->nullable(); $table->timestamp('mobile_verified_at')->nullable(); - $table->string('national_id',10)->nullable(); + $table->string('national_id', 10)->nullable(); $table->string('password'); $table->unsignedTinyInteger('status')->default(\App\Enums\UserStatusEnum::ACTIVE->value); $table->rememberToken(); diff --git a/ShopFlow/database/migrations/2024_08_01_080210_create_permission_tables.php b/ShopFlow/database/migrations/2024_08_01_080210_create_permission_tables.php index 9c7044b4..2354b1b3 100644 --- a/ShopFlow/database/migrations/2024_08_01_080210_create_permission_tables.php +++ b/ShopFlow/database/migrations/2024_08_01_080210_create_permission_tables.php @@ -1,8 +1,10 @@ unsignedBigInteger($columnNames['team_foreign_key']); $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index'); - $table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'], - 'model_has_permissions_permission_model_type_primary'); + $table->primary( + [$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary' + ); } else { - $table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'], - 'model_has_permissions_permission_model_type_primary'); + $table->primary( + [$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary' + ); } }); @@ -90,11 +96,15 @@ public function up(): void $table->unsignedBigInteger($columnNames['team_foreign_key']); $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index'); - $table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'], - 'model_has_roles_role_model_type_primary'); + $table->primary( + [$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary' + ); } else { - $table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'], - 'model_has_roles_role_model_type_primary'); + $table->primary( + [$pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary' + ); } }); diff --git a/ShopFlow/database/migrations/2024_08_01_080211_create_imports_table.php b/ShopFlow/database/migrations/2024_08_01_080211_create_imports_table.php index 34c5fc5b..259c9be3 100644 --- a/ShopFlow/database/migrations/2024_08_01_080211_create_imports_table.php +++ b/ShopFlow/database/migrations/2024_08_01_080211_create_imports_table.php @@ -1,10 +1,12 @@