diff --git a/.github/workflows/deploy-application.yml b/.github/workflows/deploy-application.yml new file mode 100644 index 00000000..48291b12 --- /dev/null +++ b/.github/workflows/deploy-application.yml @@ -0,0 +1,51 @@ +name: Deploy Application + +on: + push: + branches: + - '*' + +jobs: + create-deployment-artifact: + name: Create Deployment Artifact + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + tools: composer + + - name: Install PHP Dependencies + working-directory: ./ShopFlow + run: | + composer install --no-interaction --prefer-dist --optimize-autoloader + + - name: Compile CSS and JavaScript + working-directory: ./ShopFlow + run: | + npm ci + npm run build + + - name: Setup Environment + working-directory: ./ShopFlow + run: | + cp .env.example .env + php artisan key:generate + + - name: Run Pint Test + working-directory: ./ShopFlow + run: | + ./vendor/bin/pint --test + + - name: Run Pest Tests + working-directory: ./ShopFlow + run: | + ./vendor/bin/pest + + - name: Run PHPStan Analysis + working-directory: ./ShopFlow + run: | + ./vendor/bin/phpstan --memory-limit=2048M analyse diff --git a/ShopFlow/app/Filament/Resources/CategoryResource.php b/ShopFlow/app/Filament/Resources/CategoryResource.php index 09050145..a4046585 100644 --- a/ShopFlow/app/Filament/Resources/CategoryResource.php +++ b/ShopFlow/app/Filament/Resources/CategoryResource.php @@ -97,7 +97,10 @@ 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 @@