Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions workflows.yml → .github/workflows/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.4.11'
extensions: mbstring, bcmath, pdo_mysql
coverage: none

Expand All @@ -50,18 +50,23 @@ jobs:

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

- name: Run PHP-CS-Fixer and commit changes
- name: Check style (dry run)
run: |
composer require --dev friendsofphp/php-cs-fixer
vendor/bin/php-cs-fixer fix app
if [ -n "$(git status --porcelain)" ]; then
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add app
git commit -m "Apply PHP-CS-Fixer formatting"
git push
fi
vendor/bin/php-cs-fixer fix app --diff --dry-run

# - name: Run PHP-CS-Fixer and commit changes
# run: |
# composer require --dev friendsofphp/php-cs-fixer
# vendor/bin/php-cs-fixer fix app
# if [ -n "$(git status --porcelain)" ]; then
# git config --global user.name "github-actions[bot]"
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
# git add app
# git commit -m "Apply PHP-CS-Fixer formatting"
# git push
# fi

- name: Prepare environment file
run: cp .env.example .env
Expand Down
1 change: 0 additions & 1 deletion .php-cs-fixer.cache

This file was deleted.

4 changes: 3 additions & 1 deletion app/Exports/InventoryExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class InventoryExport implements FromCollection, WithHeadings, WithMapping, With
{
use Exportable;

public function __construct(public Request $request) {}
public function __construct(public Request $request)
{
}

public function collection(): Collection
{
Expand Down
7 changes: 5 additions & 2 deletions app/Http/Controllers/SalesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ protected function beforeStore(Request $request, $model)

protected function afterStore(RequestsRequest $request, Model $entity)
{
$entity->product->inventory->quantity -= $entity->quantity;
$entity->product->inventory->save();
$inventory = $entity->product->inventory;
if ($inventory) {
$inventory->quantity -= $entity->quantity;
$inventory->save();
}
}
}
2 changes: 1 addition & 1 deletion app/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public function purchases(): HasMany
*/
public function inventory(): HasOne
{
return $this->hasOne(Inventory::class);
return $this->hasOne(Inventory::class, 'product_id', 'id');
}
}
Loading