Skip to content

Commit

Permalink
#4 - #6 - #9 - #10 - kebab, sauce and filling crud, kebab data (#14)
Browse files Browse the repository at this point in the history
* wip kebab

* wip

* fix opening hours, add order options

* add sauce, filling, fix kebab

* tabs

* wip update factories and admin views

* enums, requests validation

* change rating

* request validation, empty lines

* imports

* test and lint php

* composer.lock

* fix

* composer

* app key

* fix

* street, building number -> address

* wip kebab_data.json

* add all kebab places, add new kebab places, seeder wip, rm columns

* gitignore

* wip img

* wip img

* images

* empty line

* cr changes + data fix

* cr changes
  • Loading branch information
AleksandraKozubal authored Jan 15, 2025
1 parent 6748bfe commit 572a18d
Show file tree
Hide file tree
Showing 149 changed files with 6,825 additions and 2,230 deletions.
2 changes: 1 addition & 1 deletion .env.ci
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APP_NAME=kula-web
APP_ENV=testing
APP_KEY=
APP_KEY=base64:WJ8UjwOaG3Fd3P2N2gTC1cssY/BmLWSNiiRxorBcX1M=
APP_DEBUG=false
APP_URL=http://kula-web.localhost

Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/test-and-lint-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Test & lint PHP codebase

on:
pull_request:
branches: [ "main" ]
types: [opened, synchronize, reopened, ready_for_review]
paths:
- '**.php'
- 'composer.json'
- 'composer.lock'
- 'phpunit.xml'
- 'env.ci'

jobs:
test-and-lint-php:
name: Test & lint PHP codebase
timeout-minutes: 10
if: github.event.pull_request.draft == false
runs-on: ubuntu-22.04
services:
pgsql:
image: postgres:15.2-alpine3.17
env:
POSTGRES_DB: escooters
POSTGRES_USER: escooters
POSTGRES_PASSWORD: password
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 3s
--health-timeout 3s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@v4

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-composer-dependencies-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-dependencies

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, intl
coverage: none

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction

- name: Run PHP linter
run: composer cs

- name: Execute tests
run: php artisan test --env=ci
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ google-credentials.json
.composer
/public/build/
supervisord.pid
.php-cs-fixer.cache
19 changes: 19 additions & 0 deletions app/Actions/RemoveFillingFromKebabAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Actions;

use App\Models\KebabPlace;

class RemoveFillingFromKebabAction
{
public function execute(int $fillingId): void
{
KebabPlace::query()->whereJsonContains("fillings", $fillingId)->get()
->each(function (KebabPlace $kebabPlace) use ($fillingId): void {
$kebabPlace->fillings = array_values(array_diff($kebabPlace->fillings, [$fillingId]));
$kebabPlace->save();
});
}
}
19 changes: 19 additions & 0 deletions app/Actions/RemoveSauceFromKebabAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Actions;

use App\Models\KebabPlace;

class RemoveSauceFromKebabAction
{
public function execute(int $sauceId): void
{
KebabPlace::query()->whereJsonContains("sauces", $sauceId)->get()
->each(function (KebabPlace $kebabPlace) use ($sauceId): void {
$kebabPlace->sauces = array_values(array_diff($kebabPlace->sauces, [$sauceId]));
$kebabPlace->save();
});
}
}
7 changes: 4 additions & 3 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
Expand All @@ -9,13 +11,12 @@ class Kernel extends ConsoleKernel
{
protected function schedule(Schedule $schedule): void
{
// $schedule->command('inspire')->hourly();
}

protected function commands(): void
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . "/Commands");

require base_path('routes/console.php');
require base_path("routes/console.php");
}
}
21 changes: 21 additions & 0 deletions app/Enums/KebabPlaceLocationType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace App\Enums;

use Filament\Support\Contracts\HasLabel;

enum KebabPlaceLocationType: string implements HasLabel
{
case dineIn = "lokal";
case foodStand = "buda";

public function getLabel(): ?string
{
return match ($this) {
self::dineIn => "Lokal",
self::foodStand => "Buda",
};
}
}
23 changes: 23 additions & 0 deletions app/Enums/KebabPlaceStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace App\Enums;

use Filament\Support\Contracts\HasLabel;

enum KebabPlaceStatus: string implements HasLabel
{
case open = "otwarte";
case closed = "zamknięte";
case planned = "planowane";

public function getLabel(): ?string
{
return match ($this) {
self::open => "Otwarte",
self::closed => "Zamknięte",
self::planned => "Planowane",
};
}
}
16 changes: 7 additions & 9 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
*
* @var array<int, string>
*/
/** @var array<int, string> */
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
"current_password",
"password",
"password_confirmation",
];

public function register(): void
{
$this->reportable(function (Throwable $e) {

$this->reportable(function (Throwable $e): void {
});
}
}
82 changes: 82 additions & 0 deletions app/Filament/Resources/FillingResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources;

use App\Filament\Resources\FillingResource\Pages;
use App\Models\Filling;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\ColorPicker;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\ColorColumn;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class FillingResource extends Resource
{
public static function form(Form $form): Form
{
return $form
->schema([
Section::make([
TextInput::make("name")
->label("Nazwa")
->required()
->maxLength(255),
ColorPicker::make("hex_color")
->label("Kolor")
->required(),
Checkbox::make("is_vege")
->label("Czy wege?")
->default(false),
]),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make("name")
->label("Nazwa")
->sortable()
->searchable(),
IconColumn::make("is_vege")
->label("Wege")
->boolean()
->sortable(),
ColorColumn::make("hex_color")
->label("Kolor")
->sortable(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getPages(): array
{
return [
"index" => Pages\ListFillings::route("/"),
"create" => Pages\CreateFilling::route("/create"),
"edit" => Pages\EditFilling::route("/{record}/edit"),
];
}

protected static ?string $model = Filling::class;
protected static ?string $label = "główny składnik";
protected static ?string $pluralLabel = "Główne składniki";
protected static ?string $navigationIcon = "heroicon-o-circle-stack";
}
13 changes: 13 additions & 0 deletions app/Filament/Resources/FillingResource/Pages/CreateFilling.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\FillingResource\Pages;

use App\Filament\Resources\FillingResource;
use Filament\Resources\Pages\CreateRecord;

class CreateFilling extends CreateRecord
{
protected static string $resource = FillingResource::class;
}
21 changes: 21 additions & 0 deletions app/Filament/Resources/FillingResource/Pages/EditFilling.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\FillingResource\Pages;

use App\Filament\Resources\FillingResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditFilling extends EditRecord
{
protected static string $resource = FillingResource::class;

protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
21 changes: 21 additions & 0 deletions app/Filament/Resources/FillingResource/Pages/ListFillings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\FillingResource\Pages;

use App\Filament\Resources\FillingResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListFillings extends ListRecords
{
protected static string $resource = FillingResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
Loading

0 comments on commit 572a18d

Please sign in to comment.