mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-06-05 09:59:00 +00:00
Laravel 11 (#84)
* Convert string references to `::class` PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP. * Use Faker methods Accessing Faker properties was deprecated in Faker 1.14. * Convert route options to fluent methods Laravel 8 adopts the tuple syntax for controller actions. Since the old options array is incompatible with this syntax, Shift converted them to use modern, fluent methods. * Adopt class based routes * Remove default `app` files * Shift core files * Streamline config files * Set new `ENV` variables * Default new `bootstrap/app.php` * Re-register HTTP middleware * Consolidate service providers * Re-register service providers * Re-register routes * Re-register scheduled commands * Bump Composer dependencies * Use `<env>` tags for configuration `<env>` tags have a lower precedence than system environment variables making it easier to overwrite PHPUnit configuration values in additional environments, such a CI. Review this blog post for more details on configuration precedence when testing Laravel: https://jasonmccreary.me/articles/laravel-testing-configuration-precedence/ * Adopt anonymous migrations * Rename `password_resets` table * Convert `$casts` property to method * Adopt Laravel type hints * Mark base controller as `abstract` * Remove `CreatesApplication` testing trait * Shift cleanup * Fix shift first issues * Updating Rules for laravel 11, sanctum config and pint * Fix Carbon issue on dashboard * Temporary fix for tests while migration is issue fixed on laravel side * Carbon needs numerical values, not strings * Minimum php version * Fix domain installation step not fetching the correct company_id * Fix Role Policy wasn't properly registered ---------
This commit is contained in:
@@ -1,35 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Providers;
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use App\Bouncer\Scopes\DefaultScope;
|
||||
use App\Policies\CompanyPolicy;
|
||||
use App\Policies\CustomerPolicy;
|
||||
use App\Policies\DashboardPolicy;
|
||||
use App\Policies\EstimatePolicy;
|
||||
use App\Policies\ExpensePolicy;
|
||||
use App\Policies\InvoicePolicy;
|
||||
use App\Policies\ItemPolicy;
|
||||
use App\Policies\ModulesPolicy;
|
||||
use App\Policies\NotePolicy;
|
||||
use App\Policies\OwnerPolicy;
|
||||
use App\Policies\PaymentPolicy;
|
||||
use App\Policies\RecurringInvoicePolicy;
|
||||
use App\Policies\ReportPolicy;
|
||||
use App\Policies\RolePolicy;
|
||||
use App\Policies\SettingsPolicy;
|
||||
use App\Policies\UserPolicy;
|
||||
use App\Space\InstallUtils;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use InvoiceShelf\Bouncer\Scopes\DefaultScope;
|
||||
use InvoiceShelf\Space\InstallUtils;
|
||||
use Silber\Bouncer\Database\Models as BouncerModels;
|
||||
use Silber\Bouncer\Database\Role;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
* The path to your application's "home" route.
|
||||
*
|
||||
* @return void
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public function boot()
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Paginator::useBootstrapThree();
|
||||
|
||||
if (InstallUtils::isDbCreated()) {
|
||||
$this->addMenus();
|
||||
}
|
||||
|
||||
Gate::policy(Role::class, RolePolicy::class);
|
||||
|
||||
$this->bootAuth();
|
||||
$this->bootBroadcast();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
public function register(): void
|
||||
{
|
||||
BouncerModels::scope(new DefaultScope);
|
||||
}
|
||||
@@ -67,4 +94,46 @@ class AppServiceProvider extends ServiceProvider
|
||||
->data('model', $data['model'])
|
||||
->data('group', $data['group']);
|
||||
}
|
||||
|
||||
public function bootAuth()
|
||||
{
|
||||
|
||||
Gate::define('create company', [CompanyPolicy::class, 'create']);
|
||||
Gate::define('transfer company ownership', [CompanyPolicy::class, 'transferOwnership']);
|
||||
Gate::define('delete company', [CompanyPolicy::class, 'delete']);
|
||||
|
||||
Gate::define('manage modules', [ModulesPolicy::class, 'manageModules']);
|
||||
|
||||
Gate::define('manage settings', [SettingsPolicy::class, 'manageSettings']);
|
||||
Gate::define('manage company', [SettingsPolicy::class, 'manageCompany']);
|
||||
Gate::define('manage backups', [SettingsPolicy::class, 'manageBackups']);
|
||||
Gate::define('manage file disk', [SettingsPolicy::class, 'manageFileDisk']);
|
||||
Gate::define('manage email config', [SettingsPolicy::class, 'manageEmailConfig']);
|
||||
Gate::define('manage notes', [NotePolicy::class, 'manageNotes']);
|
||||
Gate::define('view notes', [NotePolicy::class, 'viewNotes']);
|
||||
|
||||
Gate::define('send invoice', [InvoicePolicy::class, 'send']);
|
||||
Gate::define('send estimate', [EstimatePolicy::class, 'send']);
|
||||
Gate::define('send payment', [PaymentPolicy::class, 'send']);
|
||||
|
||||
Gate::define('delete multiple items', [ItemPolicy::class, 'deleteMultiple']);
|
||||
Gate::define('delete multiple customers', [CustomerPolicy::class, 'deleteMultiple']);
|
||||
Gate::define('delete multiple users', [UserPolicy::class, 'deleteMultiple']);
|
||||
Gate::define('delete multiple invoices', [InvoicePolicy::class, 'deleteMultiple']);
|
||||
Gate::define('delete multiple estimates', [EstimatePolicy::class, 'deleteMultiple']);
|
||||
Gate::define('delete multiple expenses', [ExpensePolicy::class, 'deleteMultiple']);
|
||||
Gate::define('delete multiple payments', [PaymentPolicy::class, 'deleteMultiple']);
|
||||
Gate::define('delete multiple recurring invoices', [RecurringInvoicePolicy::class, 'deleteMultiple']);
|
||||
|
||||
Gate::define('view dashboard', [DashboardPolicy::class, 'view']);
|
||||
|
||||
Gate::define('view report', [ReportPolicy::class, 'viewReport']);
|
||||
|
||||
Gate::define('owner only', [OwnerPolicy::class, 'managedByOwner']);
|
||||
}
|
||||
|
||||
public function bootBroadcast()
|
||||
{
|
||||
Broadcast::routes(['middleware' => 'api.auth']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user