Skip to content
Draft
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
145 changes: 145 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: CI

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
tests:
name: Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo
coverage: none

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

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

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

- name: Setup environment
run: |
cp .env.example .env
sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/' .env
sed -i 's/DB_HOST=127.0.0.1/#DB_HOST=127.0.0.1/' .env
sed -i 's/DB_PORT=3306/#DB_PORT=3306/' .env
sed -i 's/DB_DATABASE=laravel/#DB_DATABASE=laravel/' .env
sed -i 's/DB_USERNAME=root/#DB_USERNAME=root/' .env
sed -i 's/DB_PASSWORD=/#DB_PASSWORD=/' .env
touch database/opengrc.sqlite

- name: Generate application key
run: php artisan key:generate

- name: Run migrations
run: php artisan migrate --force

- name: Run tests
run: php artisan test

formatting:
name: Formatting (Pint)
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

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

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

- name: Run Pint
run: vendor/bin/pint

- name: Check for changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "::error::Code formatting issues detected. Please run 'vendor/bin/pint' locally and commit the changes."
git diff --name-only
exit 1
fi

linting:
name: Linting (PHPStan)
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

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

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

- name: Setup environment for PHPStan
run: |
cp .env.example .env
sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/' .env
sed -i 's/DB_HOST=127.0.0.1/#DB_HOST=127.0.0.1/' .env
sed -i 's/DB_PORT=3306/#DB_PORT=3306/' .env
sed -i 's/DB_DATABASE=laravel/#DB_DATABASE=laravel/' .env
sed -i 's/DB_USERNAME=root/#DB_USERNAME=root/' .env
sed -i 's/DB_PASSWORD=/#DB_PASSWORD=/' .env
touch database/opengrc.sqlite

- name: Generate application key
run: php artisan key:generate

- name: Run migrations
run: php artisan migrate --force

- name: Run PHPStan
run: vendor/bin/phpstan analyse --memory-limit=512M
2 changes: 1 addition & 1 deletion app/Filament/Admin/Pages/QueueMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class QueueMonitor extends Page implements HasTable
public function table(Table $table): Table
{
return $table
->query(QueueJob::query())
->query(QueueJob::query())
->columns([
TextColumn::make('id')
->label('ID')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ protected function getHeaderActions(): array
protected function getSaveFormAction(): Actions\Action
{
return parent::getSaveFormAction()
->label(fn () => 'Save ' . ($this->record->name ?? 'Taxonomy'));
->label(fn () => 'Save '.($this->record->name ?? 'Taxonomy'));
}

protected function getSavedNotificationTitle(): ?string
{
return $this->record->name . ' saved successfully';
return $this->record->name.' saved successfully';
}
}
3 changes: 2 additions & 1 deletion app/Filament/Admin/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UserResource extends Resource

protected static ?string $navigationLabel = null;

protected static ?string $navigationGroup = "System";
protected static ?string $navigationGroup = 'System';

protected static ?int $navigationSort = 10;

Expand Down Expand Up @@ -164,6 +164,7 @@ public static function getEloquentQuery(): Builder
public static function createDefaultPassword(): string
{
$words = collect(range(1, 4))->map(fn () => Str::random(6))->implode('-');

return $words;
}

Expand Down
8 changes: 3 additions & 5 deletions app/Filament/Admin/Resources/VendorUserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Filament\Admin\Resources\VendorUserResource\Pages;
use App\Mail\VendorInvitationMail;
use App\Mail\VendorMagicLinkMail;
use App\Models\Vendor;
use App\Models\VendorUser;
use Filament\Forms;
use Filament\Forms\Form;
Expand All @@ -17,7 +16,6 @@
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Facades\URL;

class VendorUserResource extends Resource
{
Expand Down Expand Up @@ -209,7 +207,7 @@ public static function resendInvitation(VendorUser $record, bool $notify = true)

if ($notify) {
Notification::make()
->title('Invitation sent to ' . $record->email)
->title('Invitation sent to '.$record->email)
->success()
->send();
}
Expand All @@ -230,7 +228,7 @@ public static function sendMagicLink(VendorUser $record): void
Mail::send(new VendorMagicLinkMail($record));

Notification::make()
->title('Magic link sent to ' . $record->email)
->title('Magic link sent to '.$record->email)
->success()
->send();
} catch (\Exception $e) {
Expand All @@ -251,7 +249,7 @@ public static function sendPasswordReset(VendorUser $record): void

if ($status === Password::RESET_LINK_SENT) {
Notification::make()
->title('Password reset sent to ' . $record->email)
->title('Password reset sent to '.$record->email)
->success()
->send();
} else {
Expand Down
34 changes: 20 additions & 14 deletions app/Filament/Concerns/HasTaxonomyFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ trait HasTaxonomyFields
* This handles cases where slugs might have been changed.
*
* @param string $type The taxonomy type (e.g., 'department', 'scope')
* @return Taxonomy|null
*/
protected static function getParentTaxonomy(string $type): ?Taxonomy
{
Expand All @@ -52,7 +51,7 @@ protected static function getParentTaxonomy(string $type): ?Taxonomy
}

// Try plural version
$taxonomy = Taxonomy::where('slug', $type . 's')
$taxonomy = Taxonomy::where('slug', $type.'s')
->whereNull('parent_id')
->first();

Expand All @@ -70,7 +69,7 @@ protected static function getParentTaxonomy(string $type): ?Taxonomy
}

// Try plural type
$taxonomy = Taxonomy::where('type', $type . 's')
$taxonomy = Taxonomy::where('type', $type.'s')
->whereNull('parent_id')
->first();

Expand Down Expand Up @@ -101,7 +100,7 @@ public static function taxonomySelect(
// Find the root taxonomy
$taxonomy = self::getParentTaxonomy($taxonomyType);

if (!$taxonomy) {
if (! $taxonomy) {
return [];
}

Expand All @@ -112,12 +111,16 @@ public static function taxonomySelect(
->toArray();
})
->afterStateHydrated(function (Select $component, $state, $record) use ($taxonomyType) {
if (!$record) return;
if (! $record) {
return;
}

// Find the taxonomy type
$taxonomy = self::getParentTaxonomy($taxonomyType);

if (!$taxonomy) return;
if (! $taxonomy) {
return;
}

// Get the current taxonomy term for this type
$currentTerm = $record->taxonomies()
Expand All @@ -128,12 +131,16 @@ public static function taxonomySelect(
})
->saveRelationshipsUsing(function (Select $component, $state) use ($taxonomyType) {
$record = $component->getRecord();
if (!$record || !$state) return;
if (! $record || ! $state) {
return;
}

// Find the taxonomy type
$taxonomy = self::getParentTaxonomy($taxonomyType);

if (!$taxonomy) return;
if (! $taxonomy) {
return;
}

// Detach any existing terms of this taxonomy type
$existingTermIds = Taxonomy::where('parent_id', $taxonomy->id)->pluck('id');
Expand Down Expand Up @@ -184,7 +191,7 @@ public static function hierarchicalTaxonomySelect(
// Find the root taxonomy
$taxonomy = self::getParentTaxonomy($taxonomyType);

if (!$taxonomy) {
if (! $taxonomy) {
return $query->whereRaw('1 = 0'); // Return empty result
}

Expand All @@ -197,7 +204,7 @@ public static function hierarchicalTaxonomySelect(
->getOptionLabelFromRecordUsing(function (Taxonomy $record) {
// Show hierarchical format: Parent → Child
return $record->parent
? $record->parent->name . ' → ' . $record->name
? $record->parent->name.' → '.$record->name
: $record->name;
})
->searchable()
Expand Down Expand Up @@ -230,7 +237,7 @@ public static function saveTaxonomyRelationships($record, array $data): void
];

foreach ($taxonomyFields as $fieldName => $taxonomyType) {
if (!isset($data[$fieldName]) || !$data[$fieldName]) {
if (! isset($data[$fieldName]) || ! $data[$fieldName]) {
continue;
}

Expand All @@ -239,7 +246,7 @@ public static function saveTaxonomyRelationships($record, array $data): void
// Find the root taxonomy
$taxonomy = self::getParentTaxonomy($taxonomyType);

if (!$taxonomy) {
if (! $taxonomy) {
continue;
}

Expand All @@ -261,13 +268,12 @@ public static function saveTaxonomyRelationships($record, array $data): void
*
* @param Model $record The model instance
* @param string $taxonomyType The type identifier of the parent taxonomy
* @return Taxonomy|null
*/
public static function getTaxonomyTerm($record, string $taxonomyType): ?Taxonomy
{
$parent = self::getParentTaxonomy($taxonomyType);

if (!$parent) {
if (! $parent) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Pages/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ public function preProcessData(): bool
$standard = null;
if ($standardCode) {
$standard = Standard::where('code', $standardCode)->first();
if (!$standard) {
if (! $standard) {
$has_errors = true;
$error_array[] = "Row ".($index + 1).": Standard code '{$standardCode}' not found";
$error_array[] = 'Row '.($index + 1).": Standard code '{$standardCode}' not found";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Filament\Resources\ApplicationResource\Pages;

use App\Filament\Resources\ApplicationResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;

class ViewApplication extends ViewRecord
Expand Down
1 change: 0 additions & 1 deletion app/Filament/Resources/AssetResource/Pages/CreateAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Filament\Resources\AssetResource\Pages;

use App\Filament\Resources\AssetResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateAsset extends CreateRecord
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/AssetResource/Pages/ViewAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ViewAsset extends ViewRecord

public function getTitle(): string
{
return $this->record->asset_tag . ': ' . $this->record->name;
return $this->record->asset_tag.': '.$this->record->name;
}

protected function getHeaderActions(): array
Expand Down
Loading