2018-10-04 19:10:43 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2019-09-27 06:31:13 +02:00
|
|
|
use App\Models\Activity;
|
2019-01-16 10:28:06 +01:00
|
|
|
use App\Models\Client;
|
2019-06-20 08:20:14 +02:00
|
|
|
use App\Models\Company;
|
2019-10-05 00:58:51 +02:00
|
|
|
use App\Models\CompanyGateway;
|
|
|
|
use App\Models\GroupSetting;
|
2019-04-15 02:10:54 +02:00
|
|
|
use App\Models\Invoice;
|
2019-05-03 09:57:55 +02:00
|
|
|
use App\Models\Payment;
|
2019-04-03 03:17:21 +02:00
|
|
|
use App\Models\Product;
|
2019-05-02 13:07:38 +02:00
|
|
|
use App\Models\Quote;
|
2019-05-03 00:29:04 +02:00
|
|
|
use App\Models\RecurringInvoice;
|
2019-05-05 02:49:01 +02:00
|
|
|
use App\Models\RecurringQuote;
|
2019-10-30 03:41:18 +01:00
|
|
|
use App\Models\TaxRate;
|
2019-04-27 11:20:03 +02:00
|
|
|
use App\Models\User;
|
2019-09-27 06:31:13 +02:00
|
|
|
use App\Policies\ActivityPolicy;
|
2019-01-16 10:28:06 +01:00
|
|
|
use App\Policies\ClientPolicy;
|
2019-10-05 00:58:51 +02:00
|
|
|
use App\Policies\CompanyGatewayPolicy;
|
2019-06-20 08:20:14 +02:00
|
|
|
use App\Policies\CompanyPolicy;
|
2019-10-05 00:58:51 +02:00
|
|
|
use App\Policies\GroupSettingPolicy;
|
2019-04-15 02:10:54 +02:00
|
|
|
use App\Policies\InvoicePolicy;
|
2019-05-03 09:57:55 +02:00
|
|
|
use App\Policies\PaymentPolicy;
|
2019-04-03 03:17:21 +02:00
|
|
|
use App\Policies\ProductPolicy;
|
2019-05-02 13:07:38 +02:00
|
|
|
use App\Policies\QuotePolicy;
|
2019-05-03 00:29:04 +02:00
|
|
|
use App\Policies\RecurringInvoicePolicy;
|
2019-05-05 02:49:01 +02:00
|
|
|
use App\Policies\RecurringQuotePolicy;
|
2019-10-30 03:41:18 +01:00
|
|
|
use App\Policies\TaxRatePolicy;
|
2019-06-11 05:20:23 +02:00
|
|
|
use App\Policies\UserPolicy;
|
2018-10-15 07:00:48 +02:00
|
|
|
use Auth;
|
2019-01-16 10:28:06 +01:00
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The policy mappings for the application.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $policies = [
|
2019-09-27 06:31:13 +02:00
|
|
|
Activity::class => ActivityPolicy::class,
|
2019-01-16 10:28:06 +01:00
|
|
|
Client::class => ClientPolicy::class,
|
2019-06-20 08:20:14 +02:00
|
|
|
Company::class => CompanyPolicy::class,
|
2019-04-03 03:17:21 +02:00
|
|
|
Product::class => ProductPolicy::class,
|
2019-04-15 02:10:54 +02:00
|
|
|
Invoice::class => InvoicePolicy::class,
|
2019-05-03 09:57:55 +02:00
|
|
|
Payment::class => PaymentPolicy::class,
|
2019-05-03 00:29:04 +02:00
|
|
|
RecurringInvoice::class => RecurringInvoicePolicy::class,
|
2019-05-05 02:49:01 +02:00
|
|
|
RecurringQuote::class => RecurringQuotePolicy::class,
|
2019-05-02 13:07:38 +02:00
|
|
|
Quote::class => QuotePolicy::class,
|
2019-04-27 11:20:03 +02:00
|
|
|
User::class => UserPolicy::class,
|
2019-10-05 00:58:51 +02:00
|
|
|
GroupSetting::class => GroupSettingPolicy::class,
|
|
|
|
CompanyGateway::class => CompanyGatewayPolicy::class,
|
2019-10-30 03:41:18 +01:00
|
|
|
TaxRate::class => TaxRatePolicy::class,
|
2018-10-04 19:10:43 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any authentication / authorization services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-11-03 02:01:40 +01:00
|
|
|
|
2018-10-04 19:10:43 +02:00
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
$this->registerPolicies();
|
2019-08-14 07:40:22 +02:00
|
|
|
/*
|
2018-10-15 11:06:57 +02:00
|
|
|
Auth::provider('users', function ($app, array $config) {
|
|
|
|
return new MultiDatabaseUserProvider($this->app['hash'], $config['model']);
|
|
|
|
});
|
|
|
|
|
2018-11-03 02:01:40 +01:00
|
|
|
Auth::provider('contacts', function ($app, array $config) {
|
|
|
|
return new MultiDatabaseUserProvider($this->app['hash'], $config['model']);
|
|
|
|
|
|
|
|
});
|
2019-08-14 07:40:22 +02:00
|
|
|
*/
|
2019-01-20 06:00:50 +01:00
|
|
|
Gate::define('view-list', function ($user, $entity) {
|
|
|
|
|
|
|
|
$entity = strtolower(class_basename($entity));
|
|
|
|
|
|
|
|
return $user->hasPermission('view_' . $entity) || $user->isAdmin();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-11-03 02:01:40 +01:00
|
|
|
}
|
|
|
|
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|