laravel 8
This commit is contained in:
26
app/Abstracts/Factory.php
Normal file
26
app/Abstracts/Factory.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts;
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Traits\Jobs;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory as BaseFactory;
|
||||
|
||||
abstract class Factory extends BaseFactory
|
||||
{
|
||||
use Jobs;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->user = User::first();
|
||||
$this->company = $this->user->companies()->first();
|
||||
|
||||
session(['company_id' => $this->company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $this->company->id]);
|
||||
}
|
||||
|
||||
public function getCompanyUsers()
|
||||
{
|
||||
return $this->company->users()->enabled()->get()->pluck('id')->toArray();
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ class $NAME$ extends Provider
|
||||
$this->loadViews();
|
||||
$this->loadTranslations();
|
||||
$this->loadMigrations();
|
||||
$this->loadFactories();
|
||||
//$this->loadConfig();
|
||||
}
|
||||
|
||||
@ -60,20 +59,6 @@ class $NAME$ extends Provider
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../$MIGRATIONS_PATH$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load factories.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadFactories()
|
||||
{
|
||||
if (app()->environment('production') || !app()->runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->loadFactoriesFrom(__DIR__ . '/../$FACTORIES_PATH$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load config.
|
||||
*
|
||||
|
@ -12,7 +12,7 @@ use Throwable;
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -14,7 +14,9 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
\MisterPhilip\MaintenanceMode\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
@ -51,7 +53,7 @@ class Kernel extends HttpKernel
|
||||
'api' => [
|
||||
'api.auth',
|
||||
'auth.disabled',
|
||||
'throttle:60,1',
|
||||
'throttle:api',
|
||||
'permission:read-api',
|
||||
'api.company',
|
||||
'bindings',
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
@ -11,19 +12,23 @@ class RedirectIfAuthenticated
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @param string|null ...$guards
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
if (auth()->guard($guard)->check()) {
|
||||
$user = user();
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
if ($user->contact) {
|
||||
return redirect()->route('portal.dashboard');
|
||||
foreach ($guards as $guard) {
|
||||
if (auth()->guard($guard)->check()) {
|
||||
$user = user();
|
||||
|
||||
if ($user->contact) {
|
||||
return redirect()->route('portal.dashboard');
|
||||
}
|
||||
|
||||
return redirect()->route($user->landing_page);
|
||||
}
|
||||
|
||||
return redirect()->route($user->landing_page);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ class AddAdminItems
|
||||
}
|
||||
|
||||
// Sales
|
||||
if ($user->can(['read-sales-invoices', 'read-sales-revenues', 'read-sales-customers'])) {
|
||||
if ($user->canAny(['read-sales-invoices', 'read-sales-revenues', 'read-sales-customers'])) {
|
||||
$menu->dropdown(trim(trans_choice('general.sales', 2)), function ($sub) use ($user, $attr) {
|
||||
if ($user->can('read-sales-invoices')) {
|
||||
$sub->route('invoices.index', trans_choice('general.invoices', 2), [], 10, $attr);
|
||||
@ -73,7 +73,7 @@ class AddAdminItems
|
||||
}
|
||||
|
||||
// Purchases
|
||||
if ($user->can(['read-purchases-bills', 'read-purchases-payments', 'read-purchases-vendors'])) {
|
||||
if ($user->canAny(['read-purchases-bills', 'read-purchases-payments', 'read-purchases-vendors'])) {
|
||||
$menu->dropdown(trim(trans_choice('general.purchases', 2)), function ($sub) use ($user, $attr) {
|
||||
if ($user->can('read-purchases-bills')) {
|
||||
$sub->route('bills.index', trans_choice('general.bills', 2), [], 10, $attr);
|
||||
@ -93,7 +93,7 @@ class AddAdminItems
|
||||
}
|
||||
|
||||
// Banking
|
||||
if ($user->can(['read-banking-accounts', 'read-banking-transfers', 'read-banking-transactions', 'read-banking-reconciliations'])) {
|
||||
if ($user->canAny(['read-banking-accounts', 'read-banking-transfers', 'read-banking-transactions', 'read-banking-reconciliations'])) {
|
||||
$menu->dropdown(trim(trans('general.banking')), function ($sub) use ($user, $attr) {
|
||||
if ($user->can('read-banking-accounts')) {
|
||||
$sub->route('accounts.index', trans_choice('general.accounts', 2), [], 10, $attr);
|
||||
|
29
app/Listeners/Update/V21/Version210.php
Normal file
29
app/Listeners/Update/V21/Version210.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\Update\V20;
|
||||
|
||||
use App\Abstracts\Listeners\Update as Listener;
|
||||
use App\Events\Install\UpdateFinished as Event;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class Version210 extends Listener
|
||||
{
|
||||
const ALIAS = 'core';
|
||||
|
||||
const VERSION = '2.1.0';
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Event $event)
|
||||
{
|
||||
if ($this->skipThisUpdate($event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use App\Traits\Tenants;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Laratrust\Models\LaratrustPermission;
|
||||
use Laratrust\Traits\LaratrustPermissionTrait;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
@ -10,7 +11,7 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class Permission extends LaratrustPermission
|
||||
{
|
||||
use LaratrustPermissionTrait, SearchString, Sortable, Tenants;
|
||||
use HasFactory, LaratrustPermissionTrait, SearchString, Sortable, Tenants;
|
||||
|
||||
protected $table = 'permissions';
|
||||
|
||||
@ -80,4 +81,14 @@ class Permission extends LaratrustPermission
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Permission::new();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use App\Traits\Tenants;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Laratrust\Models\LaratrustRole;
|
||||
use Laratrust\Traits\LaratrustRoleTrait;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
@ -10,7 +11,7 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class Role extends LaratrustRole
|
||||
{
|
||||
use LaratrustRoleTrait, SearchString, Sortable, Tenants;
|
||||
use HasFactory, LaratrustRoleTrait, SearchString, Sortable, Tenants;
|
||||
|
||||
protected $table = 'roles';
|
||||
|
||||
@ -40,4 +41,14 @@ class Role extends LaratrustRole
|
||||
|
||||
return $query->usingSearchString($search)->sortable($sort)->paginate($limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Role::new();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use App\Traits\Tenants;
|
||||
use App\Notifications\Auth\Reset;
|
||||
use App\Traits\Media;
|
||||
use Date;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
@ -15,7 +16,7 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use LaratrustUserTrait, Notifiable, SearchString, SoftDeletes, Sortable, Media, Tenants;
|
||||
use HasFactory, LaratrustUserTrait, Notifiable, SearchString, SoftDeletes, Sortable, Media, Tenants;
|
||||
|
||||
protected $table = 'users';
|
||||
|
||||
@ -205,4 +206,14 @@ class User extends Authenticatable
|
||||
{
|
||||
$this->offsetUnset('company_ids');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\User::new();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Models\Banking;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Account extends Model
|
||||
{
|
||||
use Transactions;
|
||||
use HasFactory, Transactions;
|
||||
|
||||
protected $table = 'accounts';
|
||||
|
||||
@ -91,4 +92,14 @@ class Account extends Model
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Account::new();
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,12 @@ use App\Traits\Media;
|
||||
use App\Traits\Recurring;
|
||||
use App\Traits\Transactions;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
use Cloneable, Currencies, DateTime, Media, Recurring, Transactions;
|
||||
use Cloneable, Currencies, DateTime, HasFactory, Media, Recurring, Transactions;
|
||||
|
||||
protected $table = 'transactions';
|
||||
|
||||
@ -323,4 +324,14 @@ class Transaction extends Model
|
||||
{
|
||||
return $value ?? $this->document_id ?? $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Transaction::new();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Models\Banking;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Traits\Currencies;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Transfer extends Model
|
||||
{
|
||||
use Currencies;
|
||||
use HasFactory, Currencies;
|
||||
|
||||
protected $table = 'transfers';
|
||||
|
||||
@ -44,4 +45,14 @@ class Transfer extends Model
|
||||
{
|
||||
return $this->belongsTo('App\Models\Banking\Account', 'income_transaction.account_id', 'id')->withDefault(['name' => trans('general.na')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Transfer::new();
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,12 @@ use App\Traits\Contacts;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\Media;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class Contact extends Model
|
||||
{
|
||||
use Cloneable, Contacts, Currencies, Media, Notifiable, Transactions;
|
||||
use Cloneable, Contacts, Currencies, HasFactory, Media, Notifiable, Transactions;
|
||||
|
||||
protected $table = 'contacts';
|
||||
|
||||
@ -144,4 +145,14 @@ class Contact extends Model
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Contact::new();
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,11 @@ use App\Abstracts\Model;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\Media;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Item extends Model
|
||||
{
|
||||
use Cloneable, Currencies, Media;
|
||||
use Cloneable, Currencies, HasFactory, Media;
|
||||
|
||||
protected $table = 'items';
|
||||
|
||||
@ -137,4 +138,14 @@ class Item extends Model
|
||||
|
||||
return $this->getMedia('picture')->last();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Item::new();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Models\Purchase;
|
||||
|
||||
use App\Abstracts\DocumentModel;
|
||||
use App\Traits\Purchases;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Bill extends DocumentModel
|
||||
{
|
||||
use Purchases;
|
||||
use HasFactory, Purchases;
|
||||
|
||||
protected $table = 'bills';
|
||||
|
||||
@ -108,4 +109,14 @@ class Bill extends DocumentModel
|
||||
|
||||
return ($received) ? $received->created_at : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Bill::new();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Models\Sale;
|
||||
|
||||
use App\Abstracts\DocumentModel;
|
||||
use App\Traits\Sales;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Invoice extends DocumentModel
|
||||
{
|
||||
use Sales;
|
||||
use HasFactory, Sales;
|
||||
|
||||
protected $table = 'invoices';
|
||||
|
||||
@ -115,4 +116,14 @@ class Invoice extends DocumentModel
|
||||
|
||||
return ($sent) ? $sent->created_at : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Invoice::new();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Models\Setting;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use Transactions;
|
||||
use HasFactory, Transactions;
|
||||
|
||||
protected $table = 'categories';
|
||||
|
||||
@ -130,4 +131,14 @@ class Category extends Model
|
||||
{
|
||||
return (int) $query->other()->pluck('id')->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Category::new();
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,11 @@ namespace App\Models\Setting;
|
||||
use App\Abstracts\Model;
|
||||
use App\Traits\Contacts;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Currency extends Model
|
||||
{
|
||||
use Contacts, Transactions;
|
||||
use Contacts, HasFactory, Transactions;
|
||||
|
||||
protected $table = 'currencies';
|
||||
|
||||
@ -163,4 +164,14 @@ class Currency extends Model
|
||||
{
|
||||
return $query->where($this->table . '.code', $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Currency::new();
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,12 @@
|
||||
namespace App\Models\Setting;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Tax extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'taxes';
|
||||
|
||||
/**
|
||||
@ -127,4 +130,14 @@ class Tax extends Model
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Tax::new();
|
||||
}
|
||||
}
|
||||
|
@ -2,28 +2,12 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Blade;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider as Provider;
|
||||
use Schema;
|
||||
|
||||
class App extends Provider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// Laravel db fix
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
// @todo Remove the if control after 1.3 update
|
||||
if (method_exists('Blade', 'withoutDoubleEncoding')) {
|
||||
Blade::withoutDoubleEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
@ -39,4 +23,17 @@ class App extends Provider
|
||||
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// Laravel db fix
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
Paginator::useBootstrap();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Contracts\Auth\Access\Authorizable;
|
||||
use Illuminate\Contracts\Auth\Access\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as Provider;
|
||||
|
||||
class Auth extends Provider
|
||||
@ -12,7 +14,7 @@ class Auth extends Provider
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
//'App\Model' => 'App\Policies\ModelPolicy',
|
||||
//'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -24,6 +26,11 @@ class Auth extends Provider
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
// Register permissions to Laravel Gate
|
||||
app(Gate::class)->before(function (Authorizable $user, string $ability) {
|
||||
if (method_exists($user, 'hasPermission')) {
|
||||
return $user->hasPermission($ability) ?: null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ class Event extends Provider
|
||||
'App\Listeners\Update\V20\Version2020',
|
||||
'App\Listeners\Update\V20\Version2023',
|
||||
'App\Listeners\Update\V20\Version2024',
|
||||
'App\Listeners\Update\V21\Version210',
|
||||
],
|
||||
'Illuminate\Auth\Events\Login' => [
|
||||
'App\Listeners\Auth\Login',
|
||||
|
@ -2,11 +2,23 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route as Facade;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as Provider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route as Facade;
|
||||
|
||||
class Route extends Provider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* This is used by Laravel authentication to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/';
|
||||
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
@ -64,6 +76,8 @@ class Route extends Provider
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
Facade::prefix('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
@ -155,4 +169,16 @@ class Route extends Provider
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/signed.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user