Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions Workflow for Code Formatting #178

Closed
wants to merge 3 commits into from
Closed
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
32 changes: 32 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: pint

on:
push:
branches:
- main
- 3.x
pull_request:
branches: [ main ]

jobs:
pint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
- name: Install dependencies
run: composer install --no-interaction
- name: Run Laravel Pint
run: ./vendor/bin/pint
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: >
chore: fix code formatting
11 changes: 7 additions & 4 deletions app/Console/Commands/CreateRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Validator;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;

class CreateRole extends Command
{
protected $signature = 'app:create-role';

protected $description = 'Create a new role with optional permissions';

public function handle()
Expand All @@ -26,6 +27,7 @@ public function handle()
foreach ($validator->errors()->all() as $error) {
$this->line($error);
}

return 1;
}

Expand All @@ -34,7 +36,7 @@ public function handle()
// Create the role
$role = Role::create([
'name' => $name,
'description' => $description
'description' => $description,
]);

// Ask if user wants to assign permissions
Expand All @@ -43,6 +45,7 @@ public function handle()
}

$this->info("Role '{$name}' created successfully.");

return 0;
}

Expand All @@ -52,6 +55,7 @@ protected function assignPermissions(Role $role)

if ($allPermissions->isEmpty()) {
$this->warn('No permissions found in the database.');

return;
}

Expand All @@ -67,9 +71,8 @@ protected function assignPermissions(Role $role)

$selectedPermissions = $allPermissions->whereIn('id', $selectedPermissionIds);


$role->syncPermissions($selectedPermissions);

$this->info('Permissions assigned successfully.');
}
}
}
7 changes: 5 additions & 2 deletions app/Console/Commands/CreateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class CreateUser extends Command
{
protected $signature = 'app:create-user';

protected $description = 'Create a new user with role assignment';

public function handle()
Expand Down Expand Up @@ -39,6 +40,7 @@ public function handle()
foreach ($validator->errors()->all() as $error) {
$this->line($error);
}

return 1;
}

Expand All @@ -48,7 +50,7 @@ public function handle()
'email' => $email,
'username' => $username,
'password' => Hash::make($password),
'verified' => 1
'verified' => 1,
]);

// Get roles and let user select
Expand All @@ -64,6 +66,7 @@ public function handle()
$user->assignRole($selectedRole);

$this->info("User created successfully with role: {$selectedRole}");

return 0;
}
}
}
1 change: 0 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
6 changes: 3 additions & 3 deletions app/Filament/Pages/Dashboard.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace App\Filament\Pages;

use Filament\Panel;

class Dashboard extends \Filament\Pages\Dashboard
{
protected static ?string $navigationIcon = 'phosphor-house-duotone';
Expand All @@ -13,4 +13,4 @@ public function panel(Panel $panel): Panel
return $panel
->pages([]);
}
}
}
7 changes: 2 additions & 5 deletions app/Filament/Pages/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
use Filament\Pages\Page;
use Filament\Support\Enums\MaxWidth;


class Media extends Page
{

protected static ?string $navigationIcon = 'heroicon-o-photo';

protected static string $view = 'wave::media.index';

protected static ?int $navigationSort = 5;

public function getMaxContentWidth(): MaxWidth
{
return MaxWidth::Full;
}

}
34 changes: 19 additions & 15 deletions app/Filament/Pages/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace App\Filament\Pages;

use Filament\Pages\Page;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Artisan;

class Plugins extends Page
{
Expand All @@ -33,18 +33,20 @@ private function getPluginsFromFolder()
$plugins = [];
$plugins_folder = resource_path('plugins');

if (!file_exists($plugins_folder)) {
if (! file_exists($plugins_folder)) {
mkdir($plugins_folder);
}

$scandirectory = scandir($plugins_folder);

foreach ($scandirectory as $folder) {
if ($folder === '.' || $folder === '..') continue;
if ($folder === '.' || $folder === '..') {
continue;
}

$studlyFolderName = Str::studly($folder);
$pluginFile = $plugins_folder . '/' . $folder . '/' . $studlyFolderName . 'Plugin.php';
$pluginFile = $plugins_folder.'/'.$folder.'/'.$studlyFolderName.'Plugin.php';

if (file_exists($pluginFile)) {
$pluginClass = "Wave\\Plugins\\{$studlyFolderName}\\{$studlyFolderName}Plugin";
if (class_exists($pluginClass) && method_exists($pluginClass, 'getPluginInfo')) {
Expand All @@ -63,12 +65,14 @@ private function getPluginsFromFolder()
private function isPluginActive($folder)
{
$installedPlugins = $this->getInstalledPlugins();

return in_array($folder, $installedPlugins);
}

private function getInstalledPlugins()
{
$path = resource_path('plugins/installed.json');

return File::exists($path) ? File::json($path) : [];
}

Expand All @@ -81,14 +85,14 @@ private function updateInstalledPlugins($plugins)
public function activate($pluginFolder)
{
$installedPlugins = $this->getInstalledPlugins();
if (!in_array($pluginFolder, $installedPlugins)) {
if (! in_array($pluginFolder, $installedPlugins)) {
$installedPlugins[] = $pluginFolder;
$this->updateInstalledPlugins($installedPlugins);

$this->runPostActivationCommands($pluginFolder);

Notification::make()
->title('Successfully activated ' . $pluginFolder . ' plugin')
->title('Successfully activated '.$pluginFolder.' plugin')
->success()
->send();
}
Expand All @@ -100,13 +104,13 @@ private function runPostActivationCommands($pluginFolder)
{
$studlyFolderName = Str::studly($pluginFolder);
$pluginClass = "Wave\\Plugins\\{$studlyFolderName}\\{$studlyFolderName}Plugin";

if (class_exists($pluginClass)) {
$plugin = new $pluginClass(app());

if (method_exists($plugin, 'getPostActivationCommands')) {
$commands = $plugin->getPostActivationCommands();

foreach ($commands as $command) {
if (is_string($command)) {
Artisan::call($command);
Expand Down Expand Up @@ -134,7 +138,7 @@ public function deactivate($pluginFolder)
$this->updateInstalledPlugins($installedPlugins);

Notification::make()
->title('Successfully deactivated ' . $pluginFolder . ' plugin')
->title('Successfully deactivated '.$pluginFolder.' plugin')
->success()
->send();

Expand All @@ -145,16 +149,16 @@ public function deletePlugin($pluginFolder)
{
$this->deactivate($pluginFolder);

$pluginPath = resource_path('plugins') . '/' . $pluginFolder;
$pluginPath = resource_path('plugins').'/'.$pluginFolder;
if (file_exists($pluginPath)) {
File::deleteDirectory($pluginPath);
}

Notification::make()
->title('Successfully deleted ' . $pluginFolder . ' plugin')
->title('Successfully deleted '.$pluginFolder.' plugin')
->success()
->send();

$this->refreshPlugins();
}
}
}
Loading