admin crud account, business, company, country

This commit is contained in:
ilmedova 2022-06-28 16:28:57 +05:00
parent eae5595a43
commit 7de44537a0
77 changed files with 7212 additions and 23 deletions

View File

@ -0,0 +1,195 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\AccountRequest;
use App\Models\Business;
use App\Models\Company;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class AccountCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class AccountCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\Account::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/account');
CRUD::setEntityNameStrings('account', 'accounts');
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
CRUD::addColumn([
'name' => 'contacts',
'type' => 'json',
'label' => 'Contacts'
]);
CRUD::addColumn([
'name' => 'bank',
'type' => 'json',
'label' => 'Bank'
]);
//CRUD::column('profileable_id');
CRUD::addColumn([
// 1-n relationship
'label' => 'Profile ID', // Table column heading
'type' => 'closure',
'function' => function ($entry) {
if ($entry->profileable_type == 'App\Models\Business') {
$data = Business::find($entry->profileable_id);
if($data){
return json_decode($data->personal)[0]['name'];
}
else{
return '-';
}
}
else{
$data = Company::find($entry->profileable_id);
if($data){
return $data->name;
}
else{
return '-';
}
}
},
]);
CRUD::addColumn([
// 1-n relationship
'label' => 'Profile type', // Table column heading
'type' => 'closure',
'function' => function ($entry) {
if ($entry->profileable_type == 'App\Models\Business') {
$data = Business::find($entry->profileable_id);
if($data){
return 'App\Models\Business';
}
else{
return '-';
}
}
else{
$data = Company::find($entry->profileable_id);
if($data){
return 'App\Models\Company';
}
else{
return '-';
}
}
},
]);
CRUD::column('vat');
CRUD::column('country_id');
CRUD::column('legalization_number');
// dropdown filter
$this->crud->addFilter([
'name' => 'status',
'type' => 'dropdown',
'label' => 'Account type'
], [
'App\Models\Company' => 'Company',
'App\Models\Business' => 'Business'
], function($value) { // if the filter is active
$this->crud->addClause('where', 'profileable_type', $value);
});
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(AccountRequest::class);
$this->crud->addFields([
[
'name' => 'contacts',
'label' => 'Contacts',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'address' => 'Address',
'phone' => 'Phone',
'email' => 'Email',
'fax' => 'Fax'
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
],
[
'name' => 'bank',
'label' => 'Bank',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'account_number' => 'Account number',
'account_date' => 'Account date',
'currency' => 'Currency',
'iban' => 'IBAN',
'bank_name' => 'Bank name',
'country' => 'Country'
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
]
]);
CRUD::field('profileable_id');
CRUD::field('profileable_type');
CRUD::field('vat');
CRUD::field('country_id');
CRUD::field('legalization_number');
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}

View File

@ -0,0 +1,211 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\BusinessRequest;
use App\Models\Account;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use Illuminate\Http\Request;
/**
* Class BusinessCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class BusinessCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\Business::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/business');
CRUD::setEntityNameStrings('business', 'businesses');
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
CRUD::addColumn([
'name' => 'personal',
'type' => 'json',
'label' => 'Personal'
]);
CRUD::addColumn([
'name' => 'document',
'type' => 'json',
'label' => 'Document'
]);
CRUD::addColumn([
'name' => 'job',
'type' => 'json',
'label' => 'Job'
]);
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(BusinessRequest::class);
$this->crud->addFields([
[
'name' => 'personal',
'label' => 'Personal',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'name' => 'Name',
'surname' => 'Surname',
'patronomic_name' => 'Patronomic name',
'date_of_birth' => 'Date of birth',
'birth_place' => 'Birth place',
'citizenship_id' => 'Citizenship ID',
'registration_address' => 'Registration address'
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
],
[
'name' => 'document',
'label' => 'Document',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'doc_name' => 'Doc name',
'doc_series' => 'Doc series',
'doc_number' => 'Doc number',
'doc_date' => 'Doc date',
'doc_given_by' => 'Doc given by'
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
],
[
'name' => 'job',
'label' => 'Job',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'work_place' => 'Work place',
'position' => 'Position',
'business_type' => 'Business type',
'licenses' => 'Licenses',
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
],
[
'label' => "profile",
'type' => 'morphic_select',
'name' => 'profile.profile_id', // the method that defines the relationship in your Model
'entity' => 'profile', // the method that defines the relationship in your Model
'attribute' => 'legalization_number', // foreign key attribute that is shown to user
'model' => "App\Models\Account", // foreign key model
]
]);
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
CRUD::setValidation(BusinessRequest::class);
$this->crud->addFields([
[
'name' => 'personal',
'label' => 'Personal',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'name' => 'Name',
'surname' => 'Surname',
'patronomic_name' => 'Patronomic name',
'date_of_birth' => 'Date of birth',
'birth_place' => 'Birth place',
'citizenship_id' => 'Citizenship ID',
'registration_address' => 'Registration address'
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
],
[
'name' => 'document',
'label' => 'Document',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'doc_name' => 'Doc name',
'doc_series' => 'Doc series',
'doc_number' => 'Doc number',
'doc_date' => 'Doc date',
'doc_given_by' => 'Doc given by'
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
],
[
'name' => 'job',
'label' => 'Job',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'work_place' => 'Work place',
'position' => 'Position',
'business_type' => 'Business type',
'licenses' => 'Licenses',
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
],
]);
}
public function store()
{
$data = $this->crud->getRequest()->all();
$profile_id = $data['profile']['profile_id'];
$this->crud->getRequest()->request->remove('profile');
$response = $this->traitStore();
$current_id = $this->data['entry']['id'];
$account = Account::find($profile_id);
$account->profileable_id = $current_id;
$account->profileable_type = 'App\Models\Business';
$account->save();
return $response;
}
}

View File

@ -21,7 +21,7 @@ class ClientCrudController extends CrudController
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
*
* @return void
*/
public function setup()
@ -33,32 +33,24 @@ public function setup()
/**
* Define what happens when the List operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
CRUD::column('id');
CRUD::column('firstname');
CRUD::column('lastname');
CRUD::column('email');
CRUD::column('password');
CRUD::column('status');
CRUD::column('account_id');
CRUD::column('created_at');
CRUD::column('updated_at');
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
@ -66,26 +58,18 @@ protected function setupCreateOperation()
{
CRUD::setValidation(ClientRequest::class);
CRUD::field('id');
CRUD::field('firstname');
CRUD::field('lastname');
CRUD::field('email');
CRUD::field('password');
CRUD::field('status');
CRUD::field('account_id');
CRUD::field('created_at');
CRUD::field('updated_at');
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/

View File

@ -0,0 +1,152 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\CompanyRequest;
use App\Models\Account;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class CompanyCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class CompanyCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\Company::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/company');
CRUD::setEntityNameStrings('company', 'companies');
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
CRUD::column('name');
CRUD::column('short_name');
CRUD::column('registration_number');
CRUD::addColumn([ // Date
'name' => 'registration_date',
'label' => 'Regitration date',
'type' => 'date'
]);
CRUD::column('state_registration_agency');
CRUD::column('registration_place');
CRUD::column('registration_address');
CRUD::column('fond_capital');
CRUD::column('management_types');
CRUD::column('signers');
CRUD::column('share_holders');
CRUD::column('organizational_form');
CRUD::column('is_agent');
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(CompanyRequest::class);
CRUD::field('name');
CRUD::field('short_name');
CRUD::field('registration_number');
CRUD::addField([ // Date
'name' => 'registration_date',
'label' => 'Regitration date',
'type' => 'date'
]);
CRUD::field('state_registration_agency');
CRUD::field('registration_place');
CRUD::field('registration_address');
CRUD::field('fond_capital');
CRUD::field('management_types');
CRUD::field('signers');
CRUD::field('share_holders');
CRUD::field('organizational_form');
CRUD::field('is_agent');
CRUD::addField([
'label' => "profile",
'type' => 'morphic_select',
'name' => 'profile.profile_id', // the method that defines the relationship in your Model
'entity' => 'profile', // the method that defines the relationship in your Model
'attribute' => 'legalization_number', // foreign key attribute that is shown to user
'model' => "App\Models\Account", // foreign key model
]);
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
CRUD::setValidation(CompanyRequest::class);
CRUD::field('name');
CRUD::field('short_name');
CRUD::field('registration_number');
CRUD::addField([ // Date
'name' => 'registration_date',
'label' => 'Regitration date',
'type' => 'date'
]);
CRUD::field('state_registration_agency');
CRUD::field('registration_place');
CRUD::field('registration_address');
CRUD::field('fond_capital');
CRUD::field('management_types');
CRUD::field('signers');
CRUD::field('share_holders');
CRUD::field('organizational_form');
CRUD::field('is_agent');
}
public function store()
{
$data = $this->crud->getRequest()->all();
$profile_id = $data['profile']['profile_id'];
$this->crud->getRequest()->request->remove('profile');
$response = $this->traitStore();
$current_id = $this->data['entry']['id'];
$account = Account::find($profile_id);
$account->profileable_id = $current_id;
$account->profileable_type = 'App\Models\Company';
$account->save();
return $response;
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\CountryRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class CountryCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class CountryCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\Country::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/country');
CRUD::setEntityNameStrings('country', 'countries');
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
CRUD::column('name');
CRUD::column('code');
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(CountryRequest::class);
CRUD::field('name');
CRUD::field('code');
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class AccountRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class BusinessRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CompanyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CountryRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

73
app/Models/Account.php Normal file
View File

@ -0,0 +1,73 @@
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
class Account extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'accounts';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
protected $fillable = [
'contacts', 'bank', 'profileable_id', 'profileable_type', 'vat', 'country_id', 'legalization_number'
];
protected $casts = [
'contacts' => 'array',
'bank' => 'array'
];
// protected $hidden = [];
// protected $dates = [];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function profileable()
{
return $this->morphTo();
}
public function country(){
return $this->belongsTo(Country::class, 'country_id');
}
public function account(){
return $this->hasMany(Client::class);
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}

66
app/Models/Business.php Normal file
View File

@ -0,0 +1,66 @@
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
class Business extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'businesses';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
protected $fillable = [
'personal', 'document', 'job'
];
// protected $hidden = [];
// protected $dates = [];
protected $casts = [
'personal' => 'array',
'document' => 'array',
'job' => 'array',
];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function profile()
{
return $this->morphOne(Account::class, 'profileable');
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}

View File

@ -25,7 +25,7 @@ class Client extends Authenticatable
// public $timestamps = false;
protected $guarded = ['id'];
protected $fillable = [
'firstname', 'lastname', 'email', 'password', 'status', 'account_id'
'firstname', 'lastname', 'email', 'password', 'status', 'account_id', 'email_verified'
];
protected $hidden = [
'password',
@ -43,6 +43,9 @@ class Client extends Authenticatable
| RELATIONS
|--------------------------------------------------------------------------
*/
public function account(){
return $this->belongsTo(Account::class, 'account_id');
}
/*
|--------------------------------------------------------------------------

78
app/Models/Company.php Normal file
View File

@ -0,0 +1,78 @@
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'companies';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
protected $fillable = [
'name',
'short_name',
'registration_number',
'registration_date',
'state_registration_agency',
'registration_place',
'registration_address',
'fond_capital',
'management_types',
'signers',
'share_holders',
'organizational_form',
'is_agent'
];
// protected $hidden = [];
// protected $dates = [];
protected $casts = [
'management_types' => 'array',
'signers' => 'array',
'share_holders' => 'array',
];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function profile()
{
return $this->morphOne(Account::class, 'profileable');
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}

60
app/Models/Country.php Normal file
View File

@ -0,0 +1,60 @@
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
class Country extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'countries';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
protected $fillable = [
'name', 'code'
];
// protected $hidden = [];
// protected $dates = [];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function accounts(){
return $this->hasMany(Account::class);
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}

View File

@ -222,7 +222,7 @@
// "ga" => "Irish",
// "it_IT" => "Italian (Italy)",
// "it_CH" => "Italian (Switzerland)",
'it' => 'Italian',
//'it' => 'Italian',
// "ja_JP" => "Japanese (Japan)",
// "ja" => "Japanese",
// "kea_CV" => "Kabuverdianu (Cape Verde)",
@ -327,7 +327,7 @@
// "pa" => "Punjabi",
// "ro_MD" => "Romanian (Moldova)",
// "ro_RO" => "Romanian (Romania)",
'ro' => 'Romanian',
//'ro' => 'Romanian',
// "rm_CH" => "Romansh (Switzerland)",
// "rm" => "Romansh",
// "rof_TZ" => "Rombo (Tanzania)",
@ -428,6 +428,7 @@
// "to" => "Tonga",
// "tr_TR" => "Turkish (Turkey)",
// "tr" => "Turkish",
"tm" => "Turkmen",
// "uk_UA" => "Ukrainian (Ukraine)",
// "uk" => "Ukrainian",
// "ur_IN" => "Urdu (India)",

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('countries', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('countries');
}
};

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('companies', function (Blueprint $table) {
$table->id();
$table->text('name');
$table->string('short_name');
$table->string('registration_number');
$table->string('registration_date');
$table->string('state_registration_agency');
$table->string('registration_place');
$table->text('registration_address');
$table->string('fond_capital');
$table->text('management_types');
$table->text('signers');
$table->text('share_holders');
$table->text('organizational_form');
$table->boolean('is_agent')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('companies');
}
};

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('businesses', function (Blueprint $table) {
$table->id();
$table->text('personal');
$table->text('document');
$table->text('job');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('businesses');
}
};

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('clients', function (Blueprint $table) {
$table->boolean('email_verified')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('clients', function (Blueprint $table) {
//
});
}
};

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('accounts', function (Blueprint $table) {
$table->id();
$table->text('contacts')->nullable();
$table->text('bank')->nullable();
$table->integer('profileable_id')->nullable();
$table->string('profileable_type')->nullable();
$table->string('vat');
$table->integer('country_id');
$table->string('legalization_number');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('accounts');
}
};

217
public/config/app.php Normal file
View File

@ -0,0 +1,217 @@
<?php
use Illuminate\Support\Facades\Facade;
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'tm',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'locales' => ['tm', 'en'],
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/
'faker_locale' => 'en_US',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => 'file',
// 'store' => 'redis',
],
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => Facade::defaultAliases()->merge([
// 'ExampleClass' => App\Example\ExampleClass::class,
])->toArray(),
];

120
public/config/auth.php Normal file
View File

@ -0,0 +1,120 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'sanctum',
'provider' => 'clients', // default
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'clients' => [
'driver' => 'eloquent',
'model' => App\Models\Client::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
];

View File

@ -0,0 +1,332 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Look & feel customizations
|--------------------------------------------------------------------------
|
| Make it yours.
|
*/
// Date & Datetime Format Syntax: https://carbon.nesbot.com/docs/#api-localization
'default_date_format' => 'D MMM YYYY',
'default_datetime_format' => 'D MMM YYYY, HH:mm',
// Direction, according to language
// (left-to-right vs right-to-left)
'html_direction' => 'ltr',
// ----
// HEAD
// ----
// Project name. Shown in the window title.
'project_name' => 'Admin Panel',
// When clicking on the admin panel's top-left logo/name,
// where should the user be redirected?
// The string below will be passed through the url() helper.
// - default: '' (project root)
// - alternative: 'admin' (the admin's dashboard)
'home_link' => '',
// Content of the HTML meta robots tag to prevent indexing and link following
'meta_robots_content' => 'noindex, nofollow',
// ------
// STYLES
// ------
// CSS files that are loaded in all pages, using Laravel's asset() helper
'styles' => [
'packages/backpack/base/css/bundle.css', // has primary color electric purple (backpack default)
// 'packages/backpack/base/css/blue-bundle.css', // has primary color blue
// Here's what's inside the bundle:
// 'packages/@digitallyhappy/backstrap/css/style.min.css',
// 'packages/animate.css/animate.min.css',
// 'packages/noty/noty.css',
// Load the fonts separately (so that you can replace them at will):
'packages/source-sans-pro/source-sans-pro.css',
'packages/line-awesome/css/line-awesome.min.css',
// Example (the fonts above, loaded from CDN instead)
// 'https://maxcdn.icons8.com/fonts/line-awesome/1.1/css/line-awesome-font-awesome.min.css',
// 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic',
// Example (load font-awesome instead of line-awesome):
// 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.min.css',
],
// CSS files that are loaded in all pages, using Laravel's mix() helper
'mix_styles' => [ // file_path => manifest_directory_path
// 'css/app.css' => '',
],
// ------
// HEADER
// ------
// Menu logo. You can replace this with an <img> tag if you have a logo.
'project_logo' => '<b>Admin</b> Panel',
// Show / hide breadcrumbs on admin panel pages.
'breadcrumbs' => true,
// Horizontal navbar classes. Helps make the admin panel look similar to your project's design.
'header_class' => 'app-header bg-light border-0 navbar',
// For background colors use: bg-dark, bg-primary, bg-secondary, bg-danger, bg-warning, bg-success, bg-info, bg-blue, bg-light-blue, bg-indigo, bg-purple, bg-pink, bg-red, bg-orange, bg-yellow, bg-green, bg-teal, bg-cyan, bg-white
// For links to be visible on different background colors use: "navbar-dark", "navbar-light", "navbar-color"
// ----
// BODY
// ----
// Body element classes.
'body_class' => 'app aside-menu-fixed sidebar-lg-show',
// Try sidebar-hidden, sidebar-fixed, sidebar-compact, sidebar-lg-show
// Sidebar element classes.
'sidebar_class' => 'sidebar sidebar-pills bg-light',
// Remove "sidebar-transparent" for standard sidebar look
// Try "sidebar-light" or "sidebar-dark" for dark/light links
// You can also add a background class like bg-dark, bg-primary, bg-secondary, bg-danger, bg-warning, bg-success, bg-info, bg-blue, bg-light-blue, bg-indigo, bg-purple, bg-pink, bg-red, bg-orange, bg-yellow, bg-green, bg-teal, bg-cyan
// ------
// FOOTER
// ------
// Footer element classes.
'footer_class' => 'app-footer d-print-none',
// hide it with d-none
// change background color with bg-dark, bg-primary, bg-secondary, bg-danger, bg-warning, bg-success, bg-info, bg-blue, bg-light-blue, bg-indigo, bg-purple, bg-pink, bg-red, bg-orange, bg-yellow, bg-green, bg-teal, bg-cyan, bg-white
// Developer or company name. Shown in footer.
'developer_name' => 'TPS Digital',
// Developer website. Link in footer. Type false if you want to hide it.
'developer_link' => 'https://tpsadvertising.com',
// Show powered by Laravel Backpack in the footer? true/false
'show_powered_by' => false,
// -------
// SCRIPTS
// -------
// JS files that are loaded in all pages, using Laravel's asset() helper
'scripts' => [
// Backstrap includes jQuery, Bootstrap, CoreUI, PNotify, Popper
'packages/backpack/base/js/bundle.js',
// examples (everything inside the bundle, loaded from CDN)
// 'https://code.jquery.com/jquery-3.4.1.min.js',
// 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js',
// 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js',
// 'https://unpkg.com/@coreui/coreui/dist/js/coreui.min.js',
// 'https://cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js',
// 'https://unpkg.com/sweetalert/dist/sweetalert.min.js',
// 'https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.js'
// examples (VueJS or React)
// 'https://unpkg.com/vue@2.4.4/dist/vue.min.js',
// 'https://unpkg.com/react@16/umd/react.production.min.js',
// 'https://unpkg.com/react-dom@16/umd/react-dom.production.min.js',
],
// JS files that are loaded in all pages, using Laravel's mix() helper
'mix_scripts' => [// file_path => manifest_directory_path
// 'js/app.js' => '',
],
// -------------
// CACHE-BUSTING
// -------------
// All JS and CSS assets defined above have this string appended as query string (?v=string).
// If you want to manually trigger cachebusting for all styles and scripts,
// append or prepend something to the string below, so that it's different.
'cachebusting_string' => \PackageVersions\Versions::getVersion('backpack/crud'),
/*
|--------------------------------------------------------------------------
| Registration Open
|--------------------------------------------------------------------------
|
| Choose whether new users/admins are allowed to register.
| This will show the Register button on the login page and allow access to the
| Register functions in AuthController.
|
| By default the registration is open only on localhost.
*/
'registration_open' => env('BACKPACK_REGISTRATION_OPEN', env('APP_ENV') === 'local'),
/*
|--------------------------------------------------------------------------
| Routing
|--------------------------------------------------------------------------
*/
// The prefix used in all base routes (the 'admin' in admin/dashboard)
// You can make sure all your URLs use this prefix by using the backpack_url() helper instead of url()
'route_prefix' => 'admin',
// The web middleware (group) used in all base & CRUD routes
// If you've modified your "web" middleware group (ex: removed sessions), you can use a different
// route group, that has all the the middleware listed below in the comments.
'web_middleware' => 'web',
// Or you can comment the above, and uncomment the complete list below.
// 'web_middleware' => [
// \App\Http\Middleware\EncryptCookies::class,
// \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
// \Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\View\Middleware\ShareErrorsFromSession::class,
// \App\Http\Middleware\VerifyCsrfToken::class,
// ],
// Set this to false if you would like to use your own AuthController and PasswordController
// (you then need to setup your auth routes manually in your routes.php file)
// Warning: if you disable this, the password recovery routes (below) will be disabled too!
'setup_auth_routes' => true,
// Set this to false if you would like to skip adding the dashboard routes
// (you then need to overwrite the login route on your AuthController)
'setup_dashboard_routes' => true,
// Set this to false if you would like to skip adding "my account" routes
// (you then need to manually define the routes in your web.php)
'setup_my_account_routes' => true,
// Set this to false if you would like to skip adding the password recovery routes
// (you then need to manually define the routes in your web.php)
'setup_password_recovery_routes' => true,
/*
|--------------------------------------------------------------------------
| Security
|--------------------------------------------------------------------------
*/
// Backpack will prevent visitors from requesting password recovery too many times
// for a certain email, to make sure they cannot be spammed that way.
// How many seconds should a visitor wait, after they've requested a
// password reset, before they can try again for the same email?
'password_recovery_throttle_notifications' => 600, // time in seconds
// Backpack will prevent an IP from trying to reset the password too many times,
// so that a malicious actor cannot try too many emails, too see if they have
// accounts or to increase the AWS/SendGrid/etc bill.
//
// How many times in any given time period should the user be allowed to
// attempt a password reset? Take into account that user might wrongly
// type an email at first, so at least allow one more try.
// Defaults to 3,10 - 3 times in 10 minutes.
'password_recovery_throttle_access' => '3,10',
/*
|--------------------------------------------------------------------------
| Authentication
|--------------------------------------------------------------------------
*/
// Fully qualified namespace of the User model
'user_model_fqn' => config('auth.providers.users.model'),
// 'user_model_fqn' => App\User::class, // works on Laravel <= 7
// 'user_model_fqn' => App\Models\User::class, // works on Laravel >= 8
// The classes for the middleware to check if the visitor is an admin
// Can be a single class or an array of classes
'middleware_class' => [
App\Http\Middleware\CheckIfAdmin::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
// \Backpack\CRUD\app\Http\Middleware\UseBackpackAuthGuardInsteadOfDefaultAuthGuard::class,
],
// Alias for that middleware
'middleware_key' => 'admin',
// Note: It's recommended to use the backpack_middleware() helper everywhere, which pulls this key for you.
// Username column for authentication
// The Backpack default is the same as the Laravel default (email)
// If you need to switch to username, you also need to create that column in your db
'authentication_column' => 'email',
'authentication_column_name' => 'Email',
// The guard that protects the Backpack admin panel.
// If null, the config.auth.defaults.guard value will be used.
'guard' => 'backpack',
// The password reset configuration for Backpack.
// If null, the config.auth.defaults.passwords value will be used.
'passwords' => 'backpack',
// What kind of avatar will you like to show to the user?
// Default: gravatar (automatically use the gravatar for their email)
// Other options:
// - null (generic image with their first letter)
// - example_method_name (specify the method on the User model that returns the URL)
'avatar_type' => 'gravatar',
// Gravatar fallback options are 'identicon', 'monsterid', 'wavatar', 'retro', 'robohash', 'blank'
// 'blank' will keep the generic image with the user first letter
'gravatar_fallback' => 'blank',
/*
|--------------------------------------------------------------------------
| Theme (User Interface)
|--------------------------------------------------------------------------
*/
// Change the view namespace in order to load a different theme than the one Backpack provides.
// You can create child themes yourself, by creating a view folder anywhere in your resources/views
// and choosing that view_namespace instead of the default one. Backpack will load a file from there
// if it exists, otherwise it will load it from the default namespace ("backpack::").
'view_namespace' => 'backpack::',
// EXAMPLE: if you create a new folder in resources/views/vendor/myname/mypackage,
// your namespace would be the one below. IMPORTANT: in this case the namespace ends with a dot.
// 'view_namespace' => 'vendor.myname.mypackage.',
// Tell Backpack to look in more places for component views (like widgets)
'component_view_namespaces' => [
'widgets' => [
'backpack::widgets', // falls back to 'resources/views/vendor/backpack/base/widgets'
],
],
/*
|--------------------------------------------------------------------------
| File System
|--------------------------------------------------------------------------
*/
// Backpack\Base sets up its own filesystem disk, just like you would by
// adding an entry to your config/filesystems.php. It points to the root
// of your project and it's used throughout all Backpack packages.
//
// You can rename this disk here. Default: root
'root_disk_name' => 'root',
/*
|--------------------------------------------------------------------------
| Backpack Token Username
|--------------------------------------------------------------------------
|
| If you have access to closed-source Backpack add-ons, please provide
| your token username here, if you're getting yellow alerts on your
| admin panel's pages. Normally this is not needed, it is
| preferred to add this as an environment variable
| (most likely in your .env file).
|
| More info and payment form on:
| https://www.backpackforlaravel.com
|
*/
'token_username' => env('BACKPACK_TOKEN_USERNAME', false),
];

View File

@ -0,0 +1,470 @@
<?php
/**
* Backpack\CRUD preferences.
*/
return [
/*
|-------------------
| TRANSLATABLE CRUDS
|-------------------
*/
'show_translatable_field_icon' => true,
'translatable_field_icon_position' => 'right', // left or right
'locales' => [
// "af_NA" => "Afrikaans (Namibia)",
// "af_ZA" => "Afrikaans (South Africa)",
// "af" => "Afrikaans",
// "ak_GH" => "Akan (Ghana)",
// "ak" => "Akan",
// "sq_AL" => "Albanian (Albania)",
// "sq" => "Albanian",
// "am_ET" => "Amharic (Ethiopia)",
// "am" => "Amharic",
// "ar_DZ" => "Arabic (Algeria)",
// "ar_BH" => "Arabic (Bahrain)",
// "ar_EG" => "Arabic (Egypt)",
// "ar_IQ" => "Arabic (Iraq)",
// "ar_JO" => "Arabic (Jordan)",
// "ar_KW" => "Arabic (Kuwait)",
// "ar_LB" => "Arabic (Lebanon)",
// "ar_LY" => "Arabic (Libya)",
// "ar_MA" => "Arabic (Morocco)",
// "ar_OM" => "Arabic (Oman)",
// "ar_QA" => "Arabic (Qatar)",
// "ar_SA" => "Arabic (Saudi Arabia)",
// "ar_SD" => "Arabic (Sudan)",
// "ar_SY" => "Arabic (Syria)",
// "ar_TN" => "Arabic (Tunisia)",
// "ar_AE" => "Arabic (United Arab Emirates)",
// "ar_YE" => "Arabic (Yemen)",
// "ar" => "Arabic",
// "hy_AM" => "Armenian (Armenia)",
// "hy" => "Armenian",
// "as_IN" => "Assamese (India)",
// "as" => "Assamese",
// "asa_TZ" => "Asu (Tanzania)",
// "asa" => "Asu",
// "az_Cyrl" => "Azerbaijani (Cyrillic)",
// "az_Cyrl_AZ" => "Azerbaijani (Cyrillic, Azerbaijan)",
// "az_Latn" => "Azerbaijani (Latin)",
// "az_Latn_AZ" => "Azerbaijani (Latin, Azerbaijan)",
// "az" => "Azerbaijani",
// "bm_ML" => "Bambara (Mali)",
// "bm" => "Bambara",
// "eu_ES" => "Basque (Spain)",
// "eu" => "Basque",
// "be_BY" => "Belarusian (Belarus)",
// "be" => "Belarusian",
// "bem_ZM" => "Bemba (Zambia)",
// "bem" => "Bemba",
// "bez_TZ" => "Bena (Tanzania)",
// "bez" => "Bena",
// "bn_BD" => "Bengali (Bangladesh)",
// "bn_IN" => "Bengali (India)",
// "bn" => "Bengali",
// "bs_BA" => "Bosnian (Bosnia and Herzegovina)",
// "bs" => "Bosnian",
// "bg_BG" => "Bulgarian (Bulgaria)",
// "bg" => "Bulgarian",
// "my_MM" => "Burmese (Myanmar [Burma])",
// "my" => "Burmese",
// "ca_ES" => "Catalan (Spain)",
// "ca" => "Catalan",
// "tzm_Latn" => "Central Morocco Tamazight (Latin)",
// "tzm_Latn_MA" => "Central Morocco Tamazight (Latin, Morocco)",
// "tzm" => "Central Morocco Tamazight",
// "chr_US" => "Cherokee (United States)",
// "chr" => "Cherokee",
// "cgg_UG" => "Chiga (Uganda)",
// "cgg" => "Chiga",
// "zh_Hans" => "Chinese (Simplified Han)",
// "zh_Hans_CN" => "Chinese (Simplified Han, China)",
// "zh_Hans_HK" => "Chinese (Simplified Han, Hong Kong SAR China)",
// "zh_Hans_MO" => "Chinese (Simplified Han, Macau SAR China)",
// "zh_Hans_SG" => "Chinese (Simplified Han, Singapore)",
// "zh_Hant" => "Chinese (Traditional Han)",
// "zh_Hant_HK" => "Chinese (Traditional Han, Hong Kong SAR China)",
// "zh_Hant_MO" => "Chinese (Traditional Han, Macau SAR China)",
// "zh_Hant_TW" => "Chinese (Traditional Han, Taiwan)",
// "zh" => "Chinese",
// "kw_GB" => "Cornish (United Kingdom)",
// "kw" => "Cornish",
// "hr_HR" => "Croatian (Croatia)",
// "hr" => "Croatian",
// "cs_CZ" => "Czech (Czech Republic)",
// "cs" => "Czech",
// "da_DK" => "Danish (Denmark)",
// "da" => "Danish",
// "nl_BE" => "Dutch (Belgium)",
// "nl_NL" => "Dutch (Netherlands)",
// "nl" => "Dutch",
// "ebu_KE" => "Embu (Kenya)",
// "ebu" => "Embu",
// "en_AS" => "English (American Samoa)",
// "en_AU" => "English (Australia)",
// "en_BE" => "English (Belgium)",
// "en_BZ" => "English (Belize)",
// "en_BW" => "English (Botswana)",
// "en_CA" => "English (Canada)",
// "en_GU" => "English (Guam)",
// "en_HK" => "English (Hong Kong SAR China)",
// "en_IN" => "English (India)",
// "en_IE" => "English (Ireland)",
// "en_JM" => "English (Jamaica)",
// "en_MT" => "English (Malta)",
// "en_MH" => "English (Marshall Islands)",
// "en_MU" => "English (Mauritius)",
// "en_NA" => "English (Namibia)",
// "en_NZ" => "English (New Zealand)",
// "en_MP" => "English (Northern Mariana Islands)",
// "en_PK" => "English (Pakistan)",
// "en_PH" => "English (Philippines)",
// "en_SG" => "English (Singapore)",
// "en_ZA" => "English (South Africa)",
// "en_TT" => "English (Trinidad and Tobago)",
// "en_UM" => "English (U.S. Minor Outlying Islands)",
// "en_VI" => "English (U.S. Virgin Islands)",
// "en_GB" => "English (United Kingdom)",
// "en_US" => "English (United States)",
// "en_ZW" => "English (Zimbabwe)",
'en' => 'English',
// "eo" => "Esperanto",
// "et_EE" => "Estonian (Estonia)",
// "et" => "Estonian",
// "ee_GH" => "Ewe (Ghana)",
// "ee_TG" => "Ewe (Togo)",
// "ee" => "Ewe",
// "fo_FO" => "Faroese (Faroe Islands)",
// "fo" => "Faroese",
// "fil_PH" => "Filipino (Philippines)",
// "fil" => "Filipino",
// "fi_FI" => "Finnish (Finland)",
// "fi" => "Finnish",
// "fr_BE" => "French (Belgium)",
// "fr_BJ" => "French (Benin)",
// "fr_BF" => "French (Burkina Faso)",
// "fr_BI" => "French (Burundi)",
// "fr_CM" => "French (Cameroon)",
// "fr_CA" => "French (Canada)",
// "fr_CF" => "French (Central African Republic)",
// "fr_TD" => "French (Chad)",
// "fr_KM" => "French (Comoros)",
// "fr_CG" => "French (Congo - Brazzaville)",
// "fr_CD" => "French (Congo - Kinshasa)",
// "fr_CI" => "French (Côte dIvoire)",
// "fr_DJ" => "French (Djibouti)",
// "fr_GQ" => "French (Equatorial Guinea)",
// "fr_FR" => "French (France)",
// "fr_GA" => "French (Gabon)",
// "fr_GP" => "French (Guadeloupe)",
// "fr_GN" => "French (Guinea)",
// "fr_LU" => "French (Luxembourg)",
// "fr_MG" => "French (Madagascar)",
// "fr_ML" => "French (Mali)",
// "fr_MQ" => "French (Martinique)",
// "fr_MC" => "French (Monaco)",
// "fr_NE" => "French (Niger)",
// "fr_RW" => "French (Rwanda)",
// "fr_RE" => "French (Réunion)",
// "fr_BL" => "French (Saint Barthélemy)",
// "fr_MF" => "French (Saint Martin)",
// "fr_SN" => "French (Senegal)",
// "fr_CH" => "French (Switzerland)",
// "fr_TG" => "French (Togo)",
'fr' => 'French',
// "ff_SN" => "Fulah (Senegal)",
// "ff" => "Fulah",
// "gl_ES" => "Galician (Spain)",
// "gl" => "Galician",
// "lg_UG" => "Ganda (Uganda)",
// "lg" => "Ganda",
// "ka_GE" => "Georgian (Georgia)",
// "ka" => "Georgian",
// "de_AT" => "German (Austria)",
// "de_BE" => "German (Belgium)",
// "de_DE" => "German (Germany)",
// "de_LI" => "German (Liechtenstein)",
// "de_LU" => "German (Luxembourg)",
// "de_CH" => "German (Switzerland)",
// "de" => "German",
// "el_CY" => "Greek (Cyprus)",
// "el_GR" => "Greek (Greece)",
// "el" => "Greek",
// "gu_IN" => "Gujarati (India)",
// "gu" => "Gujarati",
// "guz_KE" => "Gusii (Kenya)",
// "guz" => "Gusii",
// "ha_Latn" => "Hausa (Latin)",
// "ha_Latn_GH" => "Hausa (Latin, Ghana)",
// "ha_Latn_NE" => "Hausa (Latin, Niger)",
// "ha_Latn_NG" => "Hausa (Latin, Nigeria)",
// "ha" => "Hausa",
// "haw_US" => "Hawaiian (United States)",
// "haw" => "Hawaiian",
// "he_IL" => "Hebrew (Israel)",
// "he" => "Hebrew",
// "hi_IN" => "Hindi (India)",
// "hi" => "Hindi",
// "hu_HU" => "Hungarian (Hungary)",
// "hu" => "Hungarian",
// "is_IS" => "Icelandic (Iceland)",
// "is" => "Icelandic",
// "ig_NG" => "Igbo (Nigeria)",
// "ig" => "Igbo",
// "id_ID" => "Indonesian (Indonesia)",
// "id" => "Indonesian",
// "ga_IE" => "Irish (Ireland)",
// "ga" => "Irish",
// "it_IT" => "Italian (Italy)",
// "it_CH" => "Italian (Switzerland)",
'it' => 'Italian',
// "ja_JP" => "Japanese (Japan)",
// "ja" => "Japanese",
// "kea_CV" => "Kabuverdianu (Cape Verde)",
// "kea" => "Kabuverdianu",
// "kab_DZ" => "Kabyle (Algeria)",
// "kab" => "Kabyle",
// "kl_GL" => "Kalaallisut (Greenland)",
// "kl" => "Kalaallisut",
// "kln_KE" => "Kalenjin (Kenya)",
// "kln" => "Kalenjin",
// "kam_KE" => "Kamba (Kenya)",
// "kam" => "Kamba",
// "kn_IN" => "Kannada (India)",
// "kn" => "Kannada",
// "kk_Cyrl" => "Kazakh (Cyrillic)",
// "kk_Cyrl_KZ" => "Kazakh (Cyrillic, Kazakhstan)",
// "kk" => "Kazakh",
// "km_KH" => "Khmer (Cambodia)",
// "km" => "Khmer",
// "ki_KE" => "Kikuyu (Kenya)",
// "ki" => "Kikuyu",
// "rw_RW" => "Kinyarwanda (Rwanda)",
// "rw" => "Kinyarwanda",
// "kok_IN" => "Konkani (India)",
// "kok" => "Konkani",
// "ko_KR" => "Korean (South Korea)",
// "ko" => "Korean",
// "khq_ML" => "Koyra Chiini (Mali)",
// "khq" => "Koyra Chiini",
// "ses_ML" => "Koyraboro Senni (Mali)",
// "ses" => "Koyraboro Senni",
// "lag_TZ" => "Langi (Tanzania)",
// "lag" => "Langi",
// "lv_LV" => "Latvian (Latvia)",
// "lv" => "Latvian",
// "lt_LT" => "Lithuanian (Lithuania)",
// "lt" => "Lithuanian",
// "luo_KE" => "Luo (Kenya)",
// "luo" => "Luo",
// "luy_KE" => "Luyia (Kenya)",
// "luy" => "Luyia",
// "mk_MK" => "Macedonian (Macedonia)",
// "mk" => "Macedonian",
// "jmc_TZ" => "Machame (Tanzania)",
// "jmc" => "Machame",
// "kde_TZ" => "Makonde (Tanzania)",
// "kde" => "Makonde",
// "mg_MG" => "Malagasy (Madagascar)",
// "mg" => "Malagasy",
// "ms_BN" => "Malay (Brunei)",
// "ms_MY" => "Malay (Malaysia)",
// "ms" => "Malay",
// "ml_IN" => "Malayalam (India)",
// "ml" => "Malayalam",
// "mt_MT" => "Maltese (Malta)",
// "mt" => "Maltese",
// "gv_GB" => "Manx (United Kingdom)",
// "gv" => "Manx",
// "mr_IN" => "Marathi (India)",
// "mr" => "Marathi",
// "mas_KE" => "Masai (Kenya)",
// "mas_TZ" => "Masai (Tanzania)",
// "mas" => "Masai",
// "mer_KE" => "Meru (Kenya)",
// "mer" => "Meru",
// "mfe_MU" => "Morisyen (Mauritius)",
// "mfe" => "Morisyen",
// "naq_NA" => "Nama (Namibia)",
// "naq" => "Nama",
// "ne_IN" => "Nepali (India)",
// "ne_NP" => "Nepali (Nepal)",
// "ne" => "Nepali",
// "nd_ZW" => "North Ndebele (Zimbabwe)",
// "nd" => "North Ndebele",
// "nb_NO" => "Norwegian Bokmål (Norway)",
// "nb" => "Norwegian Bokmål",
// "nn_NO" => "Norwegian Nynorsk (Norway)",
// "nn" => "Norwegian Nynorsk",
// "nyn_UG" => "Nyankole (Uganda)",
// "nyn" => "Nyankole",
// "or_IN" => "Oriya (India)",
// "or" => "Oriya",
// "om_ET" => "Oromo (Ethiopia)",
// "om_KE" => "Oromo (Kenya)",
// "om" => "Oromo",
// "ps_AF" => "Pashto (Afghanistan)",
// "ps" => "Pashto",
// "fa_AF" => "Persian (Afghanistan)",
// "fa_IR" => "Persian (Iran)",
// "fa" => "Persian",
// "pl_PL" => "Polish (Poland)",
// "pl" => "Polish",
// "pt_BR" => "Portuguese (Brazil)",
// "pt_GW" => "Portuguese (Guinea-Bissau)",
// "pt_MZ" => "Portuguese (Mozambique)",
// "pt_PT" => "Portuguese (Portugal)",
// "pt" => "Portuguese",
// "pa_Arab" => "Punjabi (Arabic)",
// "pa_Arab_PK" => "Punjabi (Arabic, Pakistan)",
// "pa_Guru" => "Punjabi (Gurmukhi)",
// "pa_Guru_IN" => "Punjabi (Gurmukhi, India)",
// "pa" => "Punjabi",
// "ro_MD" => "Romanian (Moldova)",
// "ro_RO" => "Romanian (Romania)",
'ro' => 'Romanian',
// "rm_CH" => "Romansh (Switzerland)",
// "rm" => "Romansh",
// "rof_TZ" => "Rombo (Tanzania)",
// "rof" => "Rombo",
// "ru_MD" => "Russian (Moldova)",
// "ru_RU" => "Russian (Russia)",
// "ru_UA" => "Russian (Ukraine)",
// "ru" => "Russian",
// "rwk_TZ" => "Rwa (Tanzania)",
// "rwk" => "Rwa",
// "saq_KE" => "Samburu (Kenya)",
// "saq" => "Samburu",
// "sg_CF" => "Sango (Central African Republic)",
// "sg" => "Sango",
// "seh_MZ" => "Sena (Mozambique)",
// "seh" => "Sena",
// "sr_Cyrl" => "Serbian (Cyrillic)",
// "sr_Cyrl_BA" => "Serbian (Cyrillic, Bosnia and Herzegovina)",
// "sr_Cyrl_ME" => "Serbian (Cyrillic, Montenegro)",
// "sr_Cyrl_RS" => "Serbian (Cyrillic, Serbia)",
// "sr_Latn" => "Serbian (Latin)",
// "sr_Latn_BA" => "Serbian (Latin, Bosnia and Herzegovina)",
// "sr_Latn_ME" => "Serbian (Latin, Montenegro)",
// "sr_Latn_RS" => "Serbian (Latin, Serbia)",
// "sr" => "Serbian",
// "sn_ZW" => "Shona (Zimbabwe)",
// "sn" => "Shona",
// "ii_CN" => "Sichuan Yi (China)",
// "ii" => "Sichuan Yi",
// "si_LK" => "Sinhala (Sri Lanka)",
// "si" => "Sinhala",
// "sk_SK" => "Slovak (Slovakia)",
// "sk" => "Slovak",
// "sl_SI" => "Slovenian (Slovenia)",
// "sl" => "Slovenian",
// "xog_UG" => "Soga (Uganda)",
// "xog" => "Soga",
// "so_DJ" => "Somali (Djibouti)",
// "so_ET" => "Somali (Ethiopia)",
// "so_KE" => "Somali (Kenya)",
// "so_SO" => "Somali (Somalia)",
// "so" => "Somali",
// "es_AR" => "Spanish (Argentina)",
// "es_BO" => "Spanish (Bolivia)",
// "es_CL" => "Spanish (Chile)",
// "es_CO" => "Spanish (Colombia)",
// "es_CR" => "Spanish (Costa Rica)",
// "es_DO" => "Spanish (Dominican Republic)",
// "es_EC" => "Spanish (Ecuador)",
// "es_SV" => "Spanish (El Salvador)",
// "es_GQ" => "Spanish (Equatorial Guinea)",
// "es_GT" => "Spanish (Guatemala)",
// "es_HN" => "Spanish (Honduras)",
// "es_419" => "Spanish (Latin America)",
// "es_MX" => "Spanish (Mexico)",
// "es_NI" => "Spanish (Nicaragua)",
// "es_PA" => "Spanish (Panama)",
// "es_PY" => "Spanish (Paraguay)",
// "es_PE" => "Spanish (Peru)",
// "es_PR" => "Spanish (Puerto Rico)",
// "es_ES" => "Spanish (Spain)",
// "es_US" => "Spanish (United States)",
// "es_UY" => "Spanish (Uruguay)",
// "es_VE" => "Spanish (Venezuela)",
// "es" => "Spanish",
// "sw_KE" => "Swahili (Kenya)",
// "sw_TZ" => "Swahili (Tanzania)",
// "sw" => "Swahili",
// "sv_FI" => "Swedish (Finland)",
// "sv_SE" => "Swedish (Sweden)",
// "sv" => "Swedish",
// "gsw_CH" => "Swiss German (Switzerland)",
// "gsw" => "Swiss German",
// "shi_Latn" => "Tachelhit (Latin)",
// "shi_Latn_MA" => "Tachelhit (Latin, Morocco)",
// "shi_Tfng" => "Tachelhit (Tifinagh)",
// "shi_Tfng_MA" => "Tachelhit (Tifinagh, Morocco)",
// "shi" => "Tachelhit",
// "dav_KE" => "Taita (Kenya)",
// "dav" => "Taita",
// "ta_IN" => "Tamil (India)",
// "ta_LK" => "Tamil (Sri Lanka)",
// "ta" => "Tamil",
// "te_IN" => "Telugu (India)",
// "te" => "Telugu",
// "teo_KE" => "Teso (Kenya)",
// "teo_UG" => "Teso (Uganda)",
// "teo" => "Teso",
// "th_TH" => "Thai (Thailand)",
// "th" => "Thai",
// "bo_CN" => "Tibetan (China)",
// "bo_IN" => "Tibetan (India)",
// "bo" => "Tibetan",
// "ti_ER" => "Tigrinya (Eritrea)",
// "ti_ET" => "Tigrinya (Ethiopia)",
// "ti" => "Tigrinya",
// "to_TO" => "Tonga (Tonga)",
// "to" => "Tonga",
// "tr_TR" => "Turkish (Turkey)",
// "tr" => "Turkish",
// "uk_UA" => "Ukrainian (Ukraine)",
// "uk" => "Ukrainian",
// "ur_IN" => "Urdu (India)",
// "ur_PK" => "Urdu (Pakistan)",
// "ur" => "Urdu",
// "uz_Arab" => "Uzbek (Arabic)",
// "uz_Arab_AF" => "Uzbek (Arabic, Afghanistan)",
// "uz_Cyrl" => "Uzbek (Cyrillic)",
// "uz_Cyrl_UZ" => "Uzbek (Cyrillic, Uzbekistan)",
// "uz_Latn" => "Uzbek (Latin)",
// "uz_Latn_UZ" => "Uzbek (Latin, Uzbekistan)",
// "uz" => "Uzbek",
// "vi_VN" => "Vietnamese (Vietnam)",
// "vi" => "Vietnamese",
// "vun_TZ" => "Vunjo (Tanzania)",
// "vun" => "Vunjo",
// "cy_GB" => "Welsh (United Kingdom)",
// "cy" => "Welsh",
// "yo_NG" => "Yoruba (Nigeria)",
// "yo" => "Yoruba",
// "zu_ZA" => "Zulu (South Africa)",
// "zu" => "Zulu"
],
'view_namespaces' => [
'buttons' => [
'crud::buttons', // falls back to 'resources/views/vendor/backpack/crud/buttons'
],
'columns' => [
'crud::columns', // falls back to 'resources/views/vendor/backpack/crud/columns'
],
'fields' => [
'crud::fields', // falls back to 'resources/views/vendor/backpack/crud/fields'
],
'filters' => [
'crud::filters', // falls back to 'resources/views/vendor/backpack/crud/filters'
],
],
];

View File

@ -0,0 +1,10 @@
<?php
return [
// DO NOT ALLOW EDITS ON THESE LANGUAGE FILES
// Language files to NOT show in the LangFile Manager
//
'language_ignore' => [],
];

View File

@ -0,0 +1,49 @@
<?php
/**
* Configurations for Backpack's CreateOperation.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
*/
return [
// Define the size/looks of the content div for all CRUDs
// To override per view use $this->crud->setCreateContentClass('class-string')
'contentClass' => 'col-md-8 bold-labels',
// When using tabbed forms (create & update), what kind of tabs would you like?
'tabsType' => 'horizontal', //options: horizontal, vertical
// How would you like the validation errors to be shown?
'groupedErrors' => true,
'inlineErrors' => true,
// when the page loads, put the cursor on the first input?
'autoFocusOnFirstField' => true,
// Where do you want to redirect the user by default, save?
// options: save_and_back, save_and_edit, save_and_new
'defaultSaveAction' => 'save_and_back',
// When the user chooses "save and back" or "save and new", show a bubble
// for the fact that the default save action has been changed?
'showSaveActionChange' => true, //options: true, false
// Should we show a cancel button to the user?
'showCancelButton' => true,
// Should we warn a user before leaving the page with unsaved changes?
'warnBeforeLeaving' => false,
/**
* Before saving the entry, how would you like the request to be stripped?
* - false - fall back to Backpack's default (ONLY save inputs that have fields)
* - closure - process your own request (example removes all inputs that begin with underscode).
*
* @param \Illuminate\Http\Request $request
* @return array
*/
// 'strippedRequest' => (function ($request) {
// return $request->except('_token', '_method', '_http_referrer', '_current_tab', '_save_action');
// }),
];

View File

@ -0,0 +1,60 @@
<?php
/**
* Configurations for Backpack's ListOperation.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list
*/
return [
// Define the size/looks of the content div for all CRUDs
// To override per view use $this->crud->setListContentClass('class-string')
'contentClass' => 'col-md-12',
// enable the datatables-responsive plugin, which hides columns if they don't fit?
// if not, a horizontal scrollbar will be shown instead
'responsiveTable' => true,
// stores pagination and filters in localStorage for two hours
// whenever the user tries to see that page, backpack loads the previous pagination and filtration
'persistentTable' => true,
// show search bar in the top-right corner?
'searchableTable' => true,
// the time the table will be persisted in minutes
// after this the table info is cleared from localStorage.
// use false to never force localStorage clear. (default)
// keep in mind: User can clear their localStorage whenever they want.
'persistentTableDuration' => false,
// How many items should be shown by default by the Datatable?
// This value can be overwritten on a specific CRUD by calling
// $this->crud->setDefaultPageLength(50);
'defaultPageLength' => 10,
// A 1D array of options which will be used for both the displayed option and the value, or
// A 2D array in which the first array is used to define the value options and the second array the displayed options
// If a 2D array is used, strings in the right hand array will be automatically run through trans()
'pageLengthMenu' => [[10, 25, 50, 100, -1], [10, 25, 50, 100, 'backpack::crud.all']],
// How important is it for the action buttons to be visible?
// - 0 - most important
// - 1 - as important as bulk buttons
// - 2-3 - more important than the rest of the columns
// - 4 - less important than most columns
'actionsColumnPriority' => 1,
// Show a "Reset" button next to the List operation subheading
// (Showing 1 to 25 of 9999 entries. Reset)
// that allows the user to erase local storage for that datatable,
// thus clearing any searching, filtering or pagination that has been
// remembered and persisted using persistentTable
'resetButton' => true,
// The query operator that is used to search on the table.
// If you are using PostgreSQL you might want to change
// to `ilike` for case-insensitive search
'searchOperator' => 'like',
];

View File

@ -0,0 +1,13 @@
<?php
/**
* Configurations for Backpack's ReorderOperation.
*
* @see https://backpackforlaravel.com/docs/crud-operation-reorder
*/
return [
// Define the size/looks of the content div for all CRUDs
// To override per Controller use $this->crud->setReorderContentClass('class-string')
'contentClass' => 'col-md-8 col-md-offset-2',
];

View File

@ -0,0 +1,24 @@
<?php
/**
* Configurations for Backpack's ShowOperation.
*
* @see https://backpackforlaravel.com/docs/crud-operation-show
*/
return [
// Define the size/looks of the content div for all CRUDs
// To override per Controller use $this->crud->setShowContentClass('class-string')
'contentClass' => 'col-md-8',
// Automatically add all columns from the db table?
'setFromDb' => true,
// Automatically add created_at and updated_at columns, if model has timestamps?
'timestamps' => true,
// If model has SoftDeletes, allow the admin to access the Show page for
// soft deleted items & add a deleted_at column to ShowOperation?
'softDeletes' => false,
];

View File

@ -0,0 +1,49 @@
<?php
/**
* Configurations for Backpack's UpdateOperation.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
*/
return [
// Define the size/looks of the content div for all CRUDs
// To override per view use $this->crud->setEditContentClass('class-string')
'contentClass' => 'col-md-8 bold-labels',
// When using tabbed forms (create & update), what kind of tabs would you like?
'tabsType' => 'horizontal', //options: horizontal, vertical
// How would you like the validation errors to be shown?
'groupedErrors' => true,
'inlineErrors' => true,
// when the page loads, put the cursor on the first input?
'autoFocusOnFirstField' => true,
// Where do you want to redirect the user by default, save?
// options: save_and_back, save_and_edit, save_and_new
'defaultSaveAction' => 'save_and_back',
// When the user chooses "save and back" or "save and new", show a bubble
// for the fact that the default save action has been changed?
'showSaveActionChange' => true, //options: true, false
// Should we show a cancel button to the user?
'showCancelButton' => true,
// Should we warn a user before leaving the page with unsaved changes?
'warnBeforeLeaving' => false,
/**
* Before saving the entry, how would you like the request to be stripped?
* - false - fall back to Backpack's default (ONLY save inputs that have fields)
* - closure - process your own request (example removes all inputs that begin with underscode).
*
* @param \Illuminate\Http\Request $request
* @return array
*/
// 'strippedRequest' => (function ($request) {
// return $request->except('_token', '_method', '_http_referrer', '_current_tab', '_save_action');
// }),
];

View File

@ -0,0 +1,48 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Models
|--------------------------------------------------------------------------
|
| Models used in the User, Role and Permission CRUDs.
|
*/
'models' => [
'user' => config('backpack.base.user_model_fqn', \App\Models\User::class),
'permission' => Backpack\PermissionManager\app\Models\Permission::class,
'role' => Backpack\PermissionManager\app\Models\Role::class,
],
/*
|--------------------------------------------------------------------------
| Disallow the user interface for creating/updating permissions or roles.
|--------------------------------------------------------------------------
| Roles and permissions are used in code by their name
| - ex: $user->hasPermissionTo('edit articles');
|
| So after the developer has entered all permissions and roles, the administrator should either:
| - not have access to the panels
| or
| - creating and updating should be disabled
*/
'allow_permission_create' => true,
'allow_permission_update' => true,
'allow_permission_delete' => true,
'allow_role_create' => true,
'allow_role_update' => true,
'allow_role_delete' => true,
/*
|--------------------------------------------------------------------------
| Multiple-guards functionality
|--------------------------------------------------------------------------
|
*/
'multiple_guards' => false,
];

View File

@ -0,0 +1,70 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "ably", "redis", "log", "null"
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => env('PUSHER_HOST', 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com'),
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];

110
public/config/cache.php Normal file
View File

@ -0,0 +1,110 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb", "octane", "null"
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
'lock_connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
'lock_connection' => 'default',
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing the APC, database, memcached, Redis, or DynamoDB cache
| stores there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
];

34
public/config/cors.php Normal file
View File

@ -0,0 +1,34 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your settings for cross-origin resource sharing
| or "CORS". This determines what cross-origin operations may execute
| in web browsers. You are free to adjust these settings as needed.
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
*/
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];

151
public/config/database.php Normal file
View File

@ -0,0 +1,151 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
];

View File

@ -0,0 +1,81 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Upload dir
|--------------------------------------------------------------------------
|
| The dir where to store the images (relative from public).
|
*/
'dir' => ['uploads'],
/*
|--------------------------------------------------------------------------
| Filesystem disks (Flysytem)
|--------------------------------------------------------------------------
|
| Define an array of Filesystem disks, which use Flysystem.
| You can set extra options, example:
|
| 'my-disk' => [
| 'URL' => url('to/disk'),
| 'alias' => 'Local storage',
| ]
*/
'disks' => [
// 'uploads',
],
/*
|--------------------------------------------------------------------------
| Routes group config
|--------------------------------------------------------------------------
|
| The default group settings for the elFinder routes.
|
*/
'route' => [
'prefix' => config('backpack.base.route_prefix', 'admin').'/elfinder',
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')], //Set to null to disable middleware filter
],
/*
|--------------------------------------------------------------------------
| Access filter
|--------------------------------------------------------------------------
|
| Filter callback to check the files
|
*/
'access' => 'Barryvdh\Elfinder\Elfinder::checkAccess',
/*
|--------------------------------------------------------------------------
| Roots
|--------------------------------------------------------------------------
|
| By default, the roots file is LocalFileSystem, with the above public dir.
| If you want custom options, you can set your own roots below.
|
*/
'roots' => null,
/*
|--------------------------------------------------------------------------
| Options
|--------------------------------------------------------------------------
|
| These options are merged, together with 'roots' and passed to the Connector.
| See https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1
|
*/
'options' => [],
];

View File

@ -0,0 +1,76 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been set up for each driver as an example of the required values.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];

View File

@ -0,0 +1,34 @@
<?php
return [
'default' => [
// By default, images are presented at 80px by 80px if no size parameter is supplied.
// You may request a specific image size, which will be dynamically delivered from Gravatar
// by passing a single pixel dimension (since the images are square):
'size' => 80,
// the fallback image, can be a string or a url
// for more info, visit: http://en.gravatar.com/site/implement/images/#default-image
'fallback' => 'mp',
// would you like to return a https://... image
'secure' => false,
// Gravatar allows users to self-rate their images so that they can indicate if an image
// is appropriate for a certain audience. By default, only 'G' rated images are displayed
// unless you indicate that you would like to see higher ratings.
// Available options:
// g: suitable for display on all websites with any audience type.
// pg: may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.
// r: may contain such things as harsh profanity, intense violence, nudity, or hard drug use.
// x: may contain hardcore sexual imagery or extremely disturbing violence.
'maximumRating' => 'g',
// If for some reason you wanted to force the default image to always load, you can do that setting this to true
'forceDefault' => false,
// If you require a file-type extension (some places do) then you may also add an (optional) .jpg extension to that URL
'forceExtension' => 'jpg',
]
];

52
public/config/hashing.php Normal file
View File

@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon", "argon2id"
|
*/
'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 10),
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [
'memory' => 65536,
'threads' => 1,
'time' => 4,
],
];

View File

@ -0,0 +1,287 @@
<?php
return [
'default' => 'default',
'documentations' => [
'default' => [
'api' => [
'title' => 'Legalization API',
],
'routes' => [
/*
* Route for accessing api documentation interface
*/
'api' => 'api/documentation',
],
'paths' => [
/*
* Edit to include full URL in ui for assets
*/
'use_absolute_path' => env('L5_SWAGGER_USE_ABSOLUTE_PATH', true),
/*
* File name of the generated json documentation file
*/
'docs_json' => 'api-docs.json',
/*
* File name of the generated YAML documentation file
*/
'docs_yaml' => 'api-docs.yaml',
/*
* Set this to `json` or `yaml` to determine which documentation file to use in UI
*/
'format_to_use_for_docs' => env('L5_FORMAT_TO_USE_FOR_DOCS', 'json'),
/*
* Absolute paths to directory containing the swagger annotations are stored.
*/
'annotations' => [
base_path('app'),
],
],
],
],
'defaults' => [
'routes' => [
/*
* Route for accessing parsed swagger annotations.
*/
'docs' => 'docs',
/*
* Route for Oauth2 authentication callback.
*/
'oauth2_callback' => 'api/oauth2-callback',
/*
* Middleware allows to prevent unexpected access to API documentation
*/
'middleware' => [
'api' => [],
'asset' => [],
'docs' => [],
'oauth2_callback' => [],
],
/*
* Route Group options
*/
'group_options' => [],
],
'paths' => [
/*
* Absolute path to location where parsed annotations will be stored
*/
'docs' => storage_path('api-docs'),
/*
* Absolute path to directory where to export views
*/
'views' => base_path('resources/views/vendor/l5-swagger'),
/*
* Edit to set the api's base path
*/
'base' => env('L5_SWAGGER_BASE_PATH', null),
/*
* Edit to set path where swagger ui assets should be stored
*/
'swagger_ui_assets_path' => env('L5_SWAGGER_UI_ASSETS_PATH', 'vendor/swagger-api/swagger-ui/dist/'),
/*
* Absolute path to directories that should be exclude from scanning
* @deprecated Please use `scanOptions.exclude`
* `scanOptions.exclude` overwrites this
*/
'excludes' => [],
],
'scanOptions' => [
/**
* analyser: defaults to \OpenApi\StaticAnalyser .
*
* @see \OpenApi\scan
*/
'analyser' => null,
/**
* analysis: defaults to a new \OpenApi\Analysis .
*
* @see \OpenApi\scan
*/
'analysis' => null,
/**
* Custom query path processors classes.
*
* @link https://github.com/zircote/swagger-php/tree/master/Examples/schema-query-parameter-processor
* @see \OpenApi\scan
*/
'processors' => [
// new \App\SwaggerProcessors\SchemaQueryParameter(),
],
/**
* pattern: string $pattern File pattern(s) to scan (default: *.php) .
*
* @see \OpenApi\scan
*/
'pattern' => null,
/*
* Absolute path to directories that should be exclude from scanning
* @note This option overwrites `paths.excludes`
* @see \OpenApi\scan
*/
'exclude' => [],
],
/*
* API security definitions. Will be generated into documentation file.
*/
'securityDefinitions' => [
'securitySchemes' => [
/*
* Examples of Security schemes
*/
/*
'api_key_security_example' => [ // Unique name of security
'type' => 'apiKey', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
'description' => 'A short description for security scheme',
'name' => 'api_key', // The name of the header or query parameter to be used.
'in' => 'header', // The location of the API key. Valid values are "query" or "header".
],
'oauth2_security_example' => [ // Unique name of security
'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
'description' => 'A short description for oauth2 security scheme.',
'flow' => 'implicit', // The flow used by the OAuth2 security scheme. Valid values are "implicit", "password", "application" or "accessCode".
'authorizationUrl' => 'http://example.com/auth', // The authorization URL to be used for (implicit/accessCode)
//'tokenUrl' => 'http://example.com/auth' // The authorization URL to be used for (password/application/accessCode)
'scopes' => [
'read:projects' => 'read your projects',
'write:projects' => 'modify projects in your account',
]
],
*/
/* Open API 3.0 support
'passport' => [ // Unique name of security
'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
'description' => 'Laravel passport oauth2 security.',
'in' => 'header',
'scheme' => 'https',
'flows' => [
"password" => [
"authorizationUrl" => config('app.url') . '/oauth/authorize',
"tokenUrl" => config('app.url') . '/oauth/token',
"refreshUrl" => config('app.url') . '/token/refresh',
"scopes" => []
],
],
],
'sanctum' => [ // Unique name of security
'type' => 'apiKey', // Valid values are "basic", "apiKey" or "oauth2".
'description' => 'Enter token in format (Bearer <token>)',
'name' => 'Authorization', // The name of the header or query parameter to be used.
'in' => 'header', // The location of the API key. Valid values are "query" or "header".
],
*/
],
'security' => [
/*
* Examples of Securities
*/
[
/*
'oauth2_security_example' => [
'read',
'write'
],
'passport' => []
*/
],
],
],
/*
* Set this to `true` in development mode so that docs would be regenerated on each request
* Set this to `false` to disable swagger generation on production
*/
'generate_always' => env('L5_SWAGGER_GENERATE_ALWAYS', false),
/*
* Set this to `true` to generate a copy of documentation in yaml format
*/
'generate_yaml_copy' => env('L5_SWAGGER_GENERATE_YAML_COPY', false),
/*
* Edit to trust the proxy's ip address - needed for AWS Load Balancer
* string[]
*/
'proxy' => false,
/*
* Configs plugin allows to fetch external configs instead of passing them to SwaggerUIBundle.
* See more at: https://github.com/swagger-api/swagger-ui#configs-plugin
*/
'additional_config_url' => null,
/*
* Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically),
* 'method' (sort by HTTP method).
* Default is the order returned by the server unchanged.
*/
'operations_sort' => env('L5_SWAGGER_OPERATIONS_SORT', null),
/*
* Pass the validatorUrl parameter to SwaggerUi init on the JS side.
* A null value here disables validation.
*/
'validator_url' => null,
/*
* Swagger UI configuration parameters
*/
'ui' => [
'display' => [
/*
* Controls the default expansion setting for the operations and tags. It can be :
* 'list' (expands only the tags),
* 'full' (expands the tags and operations),
* 'none' (expands nothing).
*/
'doc_expansion' => env('L5_SWAGGER_UI_DOC_EXPANSION', 'none'),
/**
* If set, enables filtering. The top bar will show an edit box that
* you can use to filter the tagged operations that are shown. Can be
* Boolean to enable or disable, or a string, in which case filtering
* will be enabled using that string as the filter expression. Filtering
* is case-sensitive matching the filter expression anywhere inside
* the tag.
*/
'filter' => env('L5_SWAGGER_UI_FILTERS', true), // true | false
],
'authorization' => [
/*
* If set to true, it persists authorization data, and it would not be lost on browser close/refresh
*/
'persist_authorization' => env('L5_SWAGGER_UI_PERSIST_AUTHORIZATION', false),
],
],
/*
* Constants which can be used in annotations
*/
'constants' => [
'L5_SWAGGER_CONST_HOST' => env('L5_SWAGGER_CONST_HOST', 'http://my-default-host.com'),
],
],
];

122
public/config/logging.php Normal file
View File

@ -0,0 +1,122 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => false,
],
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => env('LOG_LEVEL', 'critical'),
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];

118
public/config/mail.php Normal file
View File

@ -0,0 +1,118 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send any email
| messages sent by your application. Alternative mailers may be setup
| and used as needed; however, this mailer will be used by default.
|
*/
'default' => env('MAIL_MAILER', 'smtp'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers to be used while
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| "postmark", "log", "array", "failover"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];

View File

@ -0,0 +1,161 @@
<?php
return [
'models' => [
/*
* When using the "HasPermissions" trait from this package, we need to know which
* Eloquent model should be used to retrieve your permissions. Of course, it
* is often just the "Permission" model but you may use whatever you like.
*
* The model you want to use as a Permission model needs to implement the
* `Spatie\Permission\Contracts\Permission` contract.
*/
'permission' => Spatie\Permission\Models\Permission::class,
/*
* When using the "HasRoles" trait from this package, we need to know which
* Eloquent model should be used to retrieve your roles. Of course, it
* is often just the "Role" model but you may use whatever you like.
*
* The model you want to use as a Role model needs to implement the
* `Spatie\Permission\Contracts\Role` contract.
*/
'role' => Spatie\Permission\Models\Role::class,
],
'table_names' => [
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'roles' => 'roles',
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your permissions. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'permissions' => 'permissions',
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your models permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_permissions' => 'model_has_permissions',
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your models roles. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_roles' => 'model_has_roles',
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'role_has_permissions' => 'role_has_permissions',
],
'column_names' => [
/*
* Change this if you want to name the related pivots other than defaults
*/
'role_pivot_key' => null, //default 'role_id',
'permission_pivot_key' => null, //default 'permission_id',
/*
* Change this if you want to name the related model primary key other than
* `model_id`.
*
* For example, this would be nice if your primary keys are all UUIDs. In
* that case, name this `model_uuid`.
*/
'model_morph_key' => 'model_id',
/*
* Change this if you want to use the teams feature and your related model's
* foreign key is other than `team_id`.
*/
'team_foreign_key' => 'team_id',
],
/*
* When set to true, the method for checking permissions will be registered on the gate.
* Set this to false, if you want to implement custom logic for checking permissions.
*/
'register_permission_check_method' => true,
/*
* When set to true the package implements teams using the 'team_foreign_key'. If you want
* the migrations to register the 'team_foreign_key', you must set this to true
* before doing the migration. If you already did the migration then you must make a new
* migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and
* 'model_has_permissions'(view the latest version of package's migration file)
*/
'teams' => false,
/*
* When set to true, the required permission names are added to the exception
* message. This could be considered an information leak in some contexts, so
* the default setting is false here for optimum safety.
*/
'display_permission_in_exception' => false,
/*
* When set to true, the required role names are added to the exception
* message. This could be considered an information leak in some contexts, so
* the default setting is false here for optimum safety.
*/
'display_role_in_exception' => false,
/*
* By default wildcard permission lookups are disabled.
*/
'enable_wildcard_permission' => false,
'cache' => [
/*
* By default all permissions are cached for 24 hours to speed up performance.
* When permissions or roles are updated the cache is flushed automatically.
*/
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
/*
* The cache key used to store all permissions.
*/
'key' => 'spatie.permission.cache',
/*
* You may optionally indicate a specific cache driver to use for permission and
* role caching using any of the `store` drivers listed in the cache.php config
* file. Using 'default' here means to use the `default` set in cache.php.
*/
'store' => 'default',
],
];

93
public/config/queue.php Normal file
View File

@ -0,0 +1,93 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/
'default' => env('QUEUE_CONNECTION', 'sync'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
'after_commit' => false,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];

67
public/config/sanctum.php Normal file
View File

@ -0,0 +1,67 @@
<?php
use Laravel\Sanctum\Sanctum;
return [
/*
|--------------------------------------------------------------------------
| Stateful Domains
|--------------------------------------------------------------------------
|
| Requests from the following domains / hosts will receive stateful API
| authentication cookies. Typically, these should include your local
| and production domains which access your API via a frontend SPA.
|
*/
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
Sanctum::currentApplicationUrlWithPort()
))),
/*
|--------------------------------------------------------------------------
| Sanctum Guards
|--------------------------------------------------------------------------
|
| This array contains the authentication guards that will be checked when
| Sanctum is trying to authenticate a request. If none of these guards
| are able to authenticate the request, Sanctum will use the bearer
| token that's present on an incoming request for authentication.
|
*/
'guard' => ['web'],
/*
|--------------------------------------------------------------------------
| Expiration Minutes
|--------------------------------------------------------------------------
|
| This value controls the number of minutes until an issued token will be
| considered expired. If this value is null, personal access tokens do
| not expire. This won't tweak the lifetime of first-party sessions.
|
*/
'expiration' => null,
/*
|--------------------------------------------------------------------------
| Sanctum Middleware
|--------------------------------------------------------------------------
|
| When authenticating your first-party SPA with Sanctum you may need to
| customize some of the middleware Sanctum uses while processing the
| request. You may change the middleware listed below as required.
|
*/
'middleware' => [
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
],
];

View File

@ -0,0 +1,34 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Mailgun, Postmark, AWS and more. This file provides the de facto
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
'scheme' => 'https',
],
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
];

201
public/config/session.php Normal file
View File

@ -0,0 +1,201 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it is stored. All encryption will be run
| automatically by Laravel and you can use the Session like normal.
|
*/
'encrypt' => false,
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION'),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table we
| should use to manage the sessions. Of course, a sensible default is
| provided for you; however, you are free to change this as needed.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| While using one of the framework's cache driven session backends you may
| list a cache store that should be used for these sessions. This value
| must match with one of the application's configured cache "stores".
|
| Affects: "apc", "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE'),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the cookie used to identify a session
| instance by ID. The name specified here will get used every time a
| new session cookie is created by the framework for every driver.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application but you are free to change this when necessary.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => env('SESSION_DOMAIN'),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you when it can't be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. You are free to modify this option if needed.
|
*/
'http_only' => true,
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" since this is a secure default value.
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => 'lax',
];

36
public/config/view.php Normal file
View File

@ -0,0 +1,36 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
resource_path('views'),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => env(
'VIEW_COMPILED_PATH',
realpath(storage_path('framework/views'))
),
];

View File

@ -21,3 +21,8 @@
</ul>
</li>
<li class='nav-item'><a class='nav-link' href='{{ backpack_url('client') }}'><i class='nav-icon la la-question'></i> Clients</a></li>
<li class='nav-item'><a class='nav-link' href='{{ backpack_url('company') }}'><i class='nav-icon la la-question'></i> Companies</a></li>
<li class='nav-item'><a class='nav-link' href='{{ backpack_url('business') }}'><i class='nav-icon la la-question'></i> Businesses</a></li>
<li class='nav-item'><a class='nav-link' href='{{ backpack_url('account') }}'><i class='nav-icon la la-question'></i> Accounts</a></li>
<li class='nav-item'><a class='nav-link' href='{{ backpack_url('country') }}'><i class='nav-icon la la-question'></i> Countries</a></li>

View File

@ -0,0 +1,10 @@
@php
$field['attributes'] = $field['attributes'] ?? [];
$field['attributes']['class'] = $field['attributes']['class'] ?? $default_class ?? 'form-control';
@endphp
@foreach ($field['attributes'] as $attribute => $value)
@if (is_string($attribute))
{{ $attribute }}="{{ $value }}"
@endif
@endforeach

View File

@ -0,0 +1,20 @@
@php
// if field name is array we check if any of the arrayed fields is translatable
$translatable = false;
if($crud->model->translationEnabled()) {
foreach((array) $field['name'] as $field_name){
if($crud->model->isTranslatableAttribute($field_name)) {
$translatable = true;
}
}
// if the field is a fake one (value is stored in a JSON column instead of a direct db column)
// and that JSON column is translatable, then the field itself should be translatable
if(isset($field['store_in']) && $crud->model->isTranslatableAttribute($field['store_in'])) {
$translatable = true;
}
}
@endphp
@if ($translatable && config('backpack.crud.show_translatable_field_icon'))
<i class="la la-flag-checkered pull-{{ config('backpack.crud.translatable_field_icon_position') }}" style="margin-top: 3px;" title="This field is translatable."></i>
@endif

View File

@ -0,0 +1 @@
</{{ $field['wrapper']['element'] ?? 'div' }}>

View File

@ -0,0 +1,34 @@
@php
$field['wrapper'] = $field['wrapper'] ?? $field['wrapperAttributes'] ?? [];
// each wrapper attribute can be a callback or a string
// for those that are callbacks, run the callbacks to get the final string to use
foreach($field['wrapper'] as $attributeKey => $value) {
$field['wrapper'][$attributeKey] = !is_string($value) && $value instanceof \Closure ? $value($crud, $field, $entry ?? null) : $value ?? '';
}
// if the field is required in any of the crud validators (FormRequest, controller validation or field validation)
// we add an astherisc for it. Case it's a subfield, that check is done upstream in repeatable_row.
// the reason for that is that here the field name is already the repeatable name: parent[row][fieldName]
if(!isset($field['parentFieldName']) || !$field['parentFieldName']) {
$fieldName = is_array($field['name']) ? current($field['name']) : $field['name'];
$required = (isset($action) && $crud->isRequired($fieldName)) ? ' required' : '';
}
// if the developer has intentionally set the required attribute on the field
// forget whatever is in the FormRequest, do what the developer wants
// subfields also get here with `showAsterisk` already set.
$required = isset($field['showAsterisk']) ? ($field['showAsterisk'] ? ' required' : '') : ($required ?? '');
$field['wrapper']['class'] = $field['wrapper']['class'] ?? "form-group col-sm-12";
$field['wrapper']['class'] = $field['wrapper']['class'].$required;
$field['wrapper']['element'] = $field['wrapper']['element'] ?? 'div';
$field['wrapper']['bp-field-wrapper'] = 'true';
$field['wrapper']['bp-field-name'] = square_brackets_to_dots(implode(',', (array)$field['name']));
$field['wrapper']['bp-field-type'] = $field['type'];
@endphp
<{{ $field['wrapper']['element'] }}
@foreach($field['wrapper'] as $attribute => $value)
{{ $attribute }}="{{ $value }}"
@endforeach
>

View File

@ -0,0 +1,49 @@
<!-- select -->
@php
$current_value = old_empty_or_null($field['name'], '') ?? $field['value'] ?? $field['default'] ?? '';
$entity_model = $crud->getRelationModel($field['entity'], - 1);
$field['allows_null'] = $field['allows_null'] ?? $entity_model::isColumnNullable($field['name']);
//if it's part of a relationship here we have the full related model, we want the key.
if (is_object($current_value) && is_subclass_of(get_class($current_value), 'Illuminate\Database\Eloquent\Model') ) {
$current_value = $current_value->getKey();
}
if (!isset($field['options'])) {
$options = $field['model']::all();
} else {
$options = call_user_func($field['options'], $field['model']::query());
}
@endphp
@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
@include('crud::fields.inc.translatable_icon')
<select
name="{{ $field['name'] }}"
@include('crud::fields.inc.attributes')
>
@if ($field['allows_null'])
<option value="">-</option>
@endif
@if (count($options))
@foreach ($options as $connected_entity_entry)
@if($current_value == $connected_entity_entry->getKey())
<option value="{{ $connected_entity_entry->getKey() }}" selected>{{ $connected_entity_entry->{$field['attribute']} }}</option>
@else
<option value="{{ $connected_entity_entry->getKey() }}">{{ $connected_entity_entry->{$field['attribute']} }}</option>
@endif
@endforeach
@endif
</select>
{{-- HINT --}}
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
@include('crud::fields.inc.wrapper_end')

View File

@ -0,0 +1,391 @@
@php
//in case entity is superNews we want the url friendly super-news
$entityWithoutAttribute = $crud->getOnlyRelationEntity($field);
$routeEntity = Str::kebab($entityWithoutAttribute);
$connected_entity = new $field['model'];
$connected_entity_key_name = $connected_entity->getKeyName();
// we need to re-ensure field type here because relationship is a `switchboard` and not actually
// a crud field like this one.
$field['type'] = 'fetch';
$field['multiple'] = $field['multiple'] ?? $crud->guessIfFieldHasMultipleFromRelationType($field['relation_type']);
$field['data_source'] = $field['data_source'] ?? url($crud->route.'/fetch/'.$routeEntity);
$field['attribute'] = $field['attribute'] ?? $connected_entity->identifiableAttribute();
$field['placeholder'] = $field['placeholder'] ?? ($field['multiple'] ? trans('backpack::crud.select_entries') : trans('backpack::crud.select_entry'));
$field['include_all_form_fields'] = $field['include_all_form_fields'] ?? true;
// Note: isColumnNullable returns true if column is nullable in database, also true if column does not exist.
$field['allows_null'] = $field['allows_null'] ?? $crud->model::isColumnNullable($field['name']);
// this is the time we wait before send the query to the search endpoint, after the user as stopped typing.
$field['delay'] = $field['delay'] ?? 500;
// make sure the $field['value'] takes the proper value
// and format it to JSON, so that select2 can parse it
$current_value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '';
if ($current_value != false) {
switch (gettype($current_value)) {
case 'array':
$current_value = $connected_entity
->whereIn($connected_entity_key_name, $current_value)
->get()
->pluck($field['attribute'], $connected_entity_key_name);
break;
case 'object':
if (is_subclass_of(get_class($current_value), 'Illuminate\Database\Eloquent\Model') ) {
$current_value = [$current_value->{$connected_entity_key_name} => $current_value->{$field['attribute']}];
}else{
if(! $current_value->isEmpty()) {
$current_value = $current_value
->pluck($field['attribute'], $connected_entity_key_name)
->toArray();
}
}
break;
default:
$current_value = $connected_entity
->where($connected_entity_key_name, $current_value)
->get()
->pluck($field['attribute'], $connected_entity_key_name);
break;
}
}
$field['value'] = json_encode($current_value);
@endphp
@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
<select
style="width:100%"
name="{{ $field['name'].($field['multiple']?'[]':'') }}"
data-init-function="bpFieldInitFetchElement"
data-column-nullable="{{ var_export($field['allows_null']) }}"
data-dependencies="{{ isset($field['dependencies'])?json_encode(Arr::wrap($field['dependencies'])): json_encode([]) }}"
data-model-local-key="{{$crud->model->getKeyName()}}"
data-placeholder="{{ $field['placeholder'] }}"
data-minimum-input-length="{{ isset($field['minimum_input_length']) ? $field['minimum_input_length'] : 2 }}"
data-method="{{ $field['method'] ?? 'POST' }}"
data-data-source="{{ $field['data_source']}}"
data-field-attribute="{{ $field['attribute'] }}"
data-connected-entity-key-name="{{ $connected_entity_key_name }}"
data-include-all-form-fields="{{ var_export($field['include_all_form_fields']) }}"
data-current-value="{{ $field['value'] }}"
data-app-current-lang="{{ app()->getLocale() }}"
data-ajax-delay="{{ $field['delay'] }}"
@include('crud::fields.inc.attributes', ['default_class' => 'form-control'])
@if($field['multiple'])
multiple
@endif
>
</select>
{{-- HINT --}}
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
@include('crud::fields.inc.wrapper_end')
{{-- ########################################## --}}
{{-- Extra CSS and JS for this particular field --}}
{{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}}
@if ($crud->fieldTypeNotLoaded($field))
@php
$crud->markFieldTypeAsLoaded($field);
@endphp
{{-- FIELD CSS - will be loaded in the after_styles section --}}
@push('crud_fields_styles')
<!-- include select2 css-->
<link href="{{ asset('packages/select2/dist/css/select2.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
{{-- FIELD JS - will be loaded in the after_scripts section --}}
@push('crud_fields_scripts')
<!-- include select2 js-->
<script src="{{ asset('packages/select2/dist/js/select2.full.min.js') }}"></script>
@if (app()->getLocale() !== 'en')
<script src="{{ asset('packages/select2/dist/js/i18n/' . app()->getLocale() . '.js') }}"></script>
@endif
@endpush
<!-- include field specific select2 js-->
@push('crud_fields_scripts')
<script>
// if nullable, make sure the Clear button uses the translated string
document.styleSheets[0].addRule('.select2-selection__clear::after','content: "{{ trans('backpack::crud.clear') }}";');
// if this function is not already on page, for example in fetch_create we add it.
// this function is responsible for query the ajax endpoint and fetch a default entry
// in case the field does not allow null
if (!window.fetchDefaultEntry) {
var fetchDefaultEntry = function (element) {
var $fetchUrl = element.attr('data-data-source');
var $relatedAttribute = element.attr('data-field-attribute');
var $relatedKeyName = element.attr('data-connected-entity-key-name');
var $return = {};
return new Promise(function (resolve, reject) {
$.ajax({
url: $fetchUrl,
data: {
'q': ''
},
type: 'POST',
success: function (result) {
// if data is available here it means a paginated collection has been returned.
// we want only the first to be default.
if (typeof result.data !== "undefined"){
$key = result.data[0][$relatedKeyName];
$value = processItemText(result.data[0], $relatedAttribute);
}else{
$key = result[0][$relatedKeyName];
$value = processItemText(result[0], $relatedAttribute);
}
$pair = { [$relatedKeyName] : $key, [$relatedAttribute] : $value}
$return = {...$return, ...$pair};
$(element).attr('data-current-value', JSON.stringify($return));
resolve($return);
},
error: function (result) {
reject(result);
}
});
});
};
}
/**
* Initialize Select2 on an element that wants the "Fetch" functionality.
* This method gets called automatically by Backpack:
* - after the Create/Update page loads
* - after a Fetch is inserted with JS somewhere (ex: in a modal)
*
* @param node element The jQuery-wrapped "select" element.
* @return void
*/
function bpFieldInitFetchElement(element) {
var form = element.closest('form');
var $placeholder = element.attr('data-placeholder');
var $minimumInputLength = element.attr('data-minimum-input-length');
var $dataSource = element.attr('data-data-source');
var $modelKey = element.attr('data-model-local-key');
var $method = element.attr('data-method');
var $fieldAttribute = element.attr('data-field-attribute');
var $connectedEntityKeyName = element.attr('data-connected-entity-key-name');
var $includeAllFormFields = element.attr('data-include-all-form-fields') == 'false' ? false : true;
var $dependencies = JSON.parse(element.attr('data-dependencies'));
var $allows_null = element.attr('data-column-nullable') == 'true' ? true : false;
var $selectedOptions = typeof element.attr('data-selected-options') === 'string' ? JSON.parse(element.attr('data-selected-options')) : JSON.parse(null);
var $multiple = element.prop('multiple');
var $ajaxDelay = element.attr('data-ajax-delay');
var FetchAjaxFetchSelectedEntry = function (element) {
return new Promise(function (resolve, reject) {
$.ajax({
url: $dataSource,
data: {
'keys': $selectedOptions
},
type: $method,
success: function (result) {
resolve(result);
},
error: function (result) {
reject(result);
}
});
});
};
if($allows_null && !$multiple) {
$(element).append('<option value="">'+$placeholder+'</option>');
}
if (typeof $selectedOptions !== typeof undefined &&
$selectedOptions !== false &&
$selectedOptions != '' &&
$selectedOptions != null &&
$selectedOptions != [])
{
var optionsForSelect = [];
FetchAjaxFetchSelectedEntry(element).then(result => {
result.forEach(function(item) {
$itemText = processItemText(item, $fieldAttribute);
$itemValue = item[$connectedEntityKeyName];
//add current key to be selected later.
optionsForSelect.push($itemValue);
//create the option in the select
$(element).append('<option value="'+$itemValue+'">'+$itemText+'</option>');
});
// set the option keys as selected.
$(element).val(optionsForSelect);
$(element).trigger('change');
});
}
var $item = false;
var $value = JSON.parse(element.attr('data-current-value'))
if(Object.keys($value).length > 0) {
$item = true;
}
var $currentValue = $item ? $value : '';
//we reselect the previously selected options if any.
var selectedOptions = [];
for (const [key, value] of Object.entries($currentValue)) {
selectedOptions.push(key);
var $option = new Option(value, key);
$(element).append($option);
}
$(element).val(selectedOptions);
if (!$allows_null && $item === false && $selectedOptions == null) {
fetchDefaultEntry(element).then(result => {
var $item = JSON.parse(element.attr('data-current-value'));
$(element).append('<option value="'+$item[$modelKey]+'">'+$item[$fieldAttribute]+'</option>');
$(element).val($item[$modelKey]);
$(element).trigger('change');
});
}
var $select2Settings = {
theme: 'bootstrap',
multiple: $multiple,
placeholder: $placeholder,
minimumInputLength: $minimumInputLength,
allowClear: $allows_null,
ajax: {
url: $dataSource,
type: $method,
dataType: 'json',
delay: $ajaxDelay,
data: function (params) {
if ($includeAllFormFields) {
return {
q: params.term, // search term
page: params.page, // pagination
form: form.serializeArray() // all other form inputs
};
} else {
return {
q: params.term, // search term
page: params.page, // pagination
};
}
},
processResults: function (data, params) {
params.page = params.page || 1;
//if we have data.data here it means we returned a paginated instance from controller.
//otherwise we returned one or more entries unpaginated.
if(data.data) {
var result = {
results: $.map(data.data, function (item) {
var $itemText = processItemText(item, $fieldAttribute);
return {
text: $itemText,
id: item[$connectedEntityKeyName]
}
}),
pagination: {
more: data.current_page < data.last_page
}
};
}else {
var result = {
results: $.map(data, function (item) {
var $itemText = processItemText(item, $fieldAttribute);
return {
text: $itemText,
id: item[$connectedEntityKeyName]
}
}),
pagination: {
more: false,
}
}
}
return result;
},
cache: true
},
};
if (!$(element).hasClass("select2-hidden-accessible"))
{
$(element).select2($select2Settings);
// if any dependencies have been declared
// when one of those dependencies changes value
// reset the select2 value
for (var i=0; i < $dependencies.length; i++) {
var $dependency = $dependencies[i];
//if element does not have a custom-selector attribute we use the name attribute
if(typeof element.attr('data-custom-selector') == 'undefined') {
form.find(`[name="${$dependency}"], [name="${$dependency}[]"]`).change(function(el) {
$(element.find('option:not([value=""])')).remove();
element.val(null).trigger("change");
});
}else{
// we get the row number and custom selector from where element is called
let rowNumber = element.attr('data-row-number');
let selector = element.attr('data-custom-selector');
// replace in the custom selector string the corresponding row and dependency name to match
selector = selector
.replaceAll('%DEPENDENCY%', $dependency)
.replaceAll('%ROW%', rowNumber);
$(selector).change(function (el) {
$(element.find('option:not([value=""])')).remove();
element.val(null).trigger("change");
});
}
}
}
}
if (typeof processItemText !== 'function') {
function processItemText(item, $fieldAttribute) {
var $appLang = '{{ app()->getLocale() }}';
var $appLangFallback = '{{ Lang::getFallback() }}';
var $emptyTranslation = '{{ trans("backpack::crud.empty_translations") }}';
var $itemField = item[$fieldAttribute];
// try to retreive the item in app language; then fallback language; then first entry; if nothing found empty translation string
return typeof $itemField === 'object' && $itemField !== null
? $itemField[$appLang] ?? $itemField[$appLangFallback] ?? Object.values($itemField)[0] ?? $emptyTranslation
: $itemField;
}
}
</script>
@endpush
@endif
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,719 @@
<!-- relationship -->
@php
//in case entity is superNews we want the url friendly super-news
$entityWithoutAttribute = $crud->getOnlyRelationEntity($field);
$routeEntity = Str::kebab($entityWithoutAttribute);
$connected_entity = new $field['model'];
$connected_entity_key_name = $connected_entity->getKeyName();
// make sure the $field['value'] takes the proper value
// and format it to JSON, so that select2 can parse it
$current_value = old(square_brackets_to_dots($field['name'])) ?? old($field['name']) ?? $field['value'] ?? $field['default'] ?? '';
if ($current_value != false) {
switch (gettype($current_value)) {
case 'array':
$current_value = $connected_entity
->whereIn($connected_entity_key_name, $current_value)
->get()
->pluck($field['attribute'], $connected_entity_key_name)
->toArray();
break;
case 'object':
if (is_subclass_of(get_class($current_value), 'Illuminate\Database\Eloquent\Model') ) {
$current_value = [$current_value->{$connected_entity_key_name} => $current_value->{$field['attribute']}];
}else{
if(! $current_value->isEmpty()) {
$current_value = $current_value
->pluck($field['attribute'], $connected_entity_key_name)
->toArray();
}
}
break;
default:
$current_value = $connected_entity
->where($connected_entity_key_name, $current_value)
->get()
->pluck($field['attribute'], $connected_entity_key_name)
->toArray();
break;
}
}
$field['value'] = json_encode($current_value);
$field['data_source'] = $field['data_source'] ?? url($crud->route.'/fetch/'.$routeEntity);
$field['include_all_form_fields'] = $field['include_all_form_fields'] ?? true;
// this is the time we wait before send the query to the search endpoint, after the user as stopped typing.
$field['delay'] = $field['delay'] ?? 500;
$activeInlineCreate = !empty($field['inline_create']) ? true : false;
if($activeInlineCreate) {
//we check if this field is not beeing requested in some InlineCreate operation.
//this variable is setup by InlineCreate modal when loading the fields.
if(!isset($inlineCreate)) {
//by default, when creating an entity we want it to be selected/added to selection.
$field['inline_create']['force_select'] = $field['inline_create']['force_select'] ?? true;
$field['inline_create']['modal_class'] = $field['inline_create']['modal_class'] ?? 'modal-dialog';
//if user don't specify a different entity in inline_create we assume it's the same from $field['entity'] kebabed
$field['inline_create']['entity'] = $field['inline_create']['entity'] ?? $routeEntity;
//route to create a new entity
$field['inline_create']['create_route'] = route($field['inline_create']['entity']."-inline-create-save");
//route to modal
$field['inline_create']['modal_route'] = route($field['inline_create']['entity']."-inline-create");
//include main form fields in the request when asking for modal data,
//allow the developer to modify the inline create modal
//based on some field on the main form
$field['inline_create']['include_main_form_fields'] = $field['inline_create']['include_main_form_fields'] ?? false;
if(!is_bool($field['inline_create']['include_main_form_fields'])) {
if(is_array($field['inline_create']['include_main_form_fields'])) {
$field['inline_create']['include_main_form_fields'] = json_encode($field['inline_create']['include_main_form_fields']);
}else{
//it is a string or treat it like
$arrayed_field = array($field['inline_create']['include_main_form_fields']);
$field['inline_create']['include_main_form_fields'] = json_encode($arrayed_field);
}
}
}
}
@endphp
@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
@include('crud::fields.inc.translatable_icon')
@if($activeInlineCreate)
@include('crud::fields.relationship.inline_create_button', ['field' => $field])
@endif
<select
name="{{ $field['name'].($field['multiple']?'[]':'') }}"
data-original-name="{{ $field['name'] }}"
style="width: 100%"
data-force-select="{{ var_export($field['inline_create']['force_select']) }}"
data-init-function="bpFieldInitFetchOrCreateElement"
data-is-inline="{{ $inlineCreate ?? 'false' }}"
data-allows-null="{{var_export($field['allows_null'])}}"
data-dependencies="{{ isset($field['dependencies'])?json_encode(Arr::wrap($field['dependencies'])): json_encode([]) }}"
data-model-local-key="{{$crud->model->getKeyName()}}"
data-placeholder="{{ $field['placeholder'] }}"
data-data-source="{{ $field['data_source'] }}"
data-method="{{ $field['method'] ?? 'POST' }}"
data-minimum-input-length="{{ $field['minimum_input_length'] }}"
data-field-attribute="{{ $field['attribute'] }}"
data-connected-entity-key-name="{{ $connected_entity_key_name }}"
data-include-all-form-fields="{{ var_export($field['include_all_form_fields']) }}"
data-current-value="{{ $field['value'] }}"
data-field-ajax="{{var_export($field['ajax'])}}"
data-inline-modal-class="{{ $field['inline_create']['modal_class'] }}"
data-app-current-lang="{{ app()->getLocale() }}"
data-include-main-form-fields="{{ is_bool($field['inline_create']['include_main_form_fields']) ? var_export($field['inline_create']['include_main_form_fields']) : $field['inline_create']['include_main_form_fields'] }}"
data-ajax-delay="{{ $field['delay'] }}"
@if($activeInlineCreate)
@include('crud::fields.relationship.field_attributes')
@endif
@include('crud::fields.inc.attributes', ['default_class' => 'form-control select2_field'])
@if($field['multiple'])
multiple
@endif
>
</select>
{{-- HINT --}}
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
@include('crud::fields.inc.wrapper_end')
@if ($crud->fieldTypeNotLoaded($field))
@php
$crud->markFieldTypeAsLoaded($field);
@endphp
{{-- FIELD CSS - will be loaded in the after_styles section --}}
@push('crud_fields_styles')
<!-- include select2 css-->
<link href="{{ asset('packages/select2/dist/css/select2.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
{{-- FIELD JS - will be loaded in the after_scripts section --}}
@push('crud_fields_scripts')
<!-- include select2 js-->
<script src="{{ asset('packages/select2/dist/js/select2.full.min.js') }}"></script>
@if (app()->getLocale() !== 'en')
<script src="{{ asset('packages/select2/dist/js/i18n/' . app()->getLocale() . '.js') }}"></script>
@endif
<script>
document.styleSheets[0].addRule('.select2-selection__clear::after','content: "{{ trans('backpack::crud.clear') }}";');
// this is the function responsible for querying the ajax endpoint with our query string, emulating the select2
// ajax search mechanism.
var performAjaxSearch = function (element, $searchString) {
var $includeAllFormFields = element.attr('data-include-all-form-fields')=='false' ? false : true;
var $refreshUrl = element.attr('data-data-source');
var $method = element.attr('data-method');
var form = element.closest('form')
return new Promise(function (resolve, reject) {
$.ajax({
url: $refreshUrl,
data: (function() {
if ($includeAllFormFields) {
return {
q: $searchString, // search term
form: form.serializeArray() // all other form inputs
};
} else {
return {
q: $searchString, // search term
};
}
})(),
type: $method,
success: function (result) {
resolve(result);
},
error: function (result) {
reject(result);
}
});
});
};
// this function is responsible for fetching some default option when developer don't allow null on field
if (!window.fetchDefaultEntry) {
var fetchDefaultEntry = function (element) {
var $relatedAttribute = element.attr('data-field-attribute');
var $relatedKeyName = element.attr('data-connected-entity-key-name');
var $fetchUrl = element.attr('data-data-source');
var $return = {};
return new Promise(function (resolve, reject) {
$.ajax({
url: $fetchUrl,
data: {
'q': ''
},
type: 'POST',
success: function (result) {
// if data is available here it means a paginated collection has been returned.
// we want only the first to be default.
if (typeof result.data !== "undefined"){
$key = result.data[0][$relatedKeyName];
$value = processItemText(result.data[0], $relatedAttribute);
}else{
$key = result[0][$relatedKeyName];
$value = processItemText(result[0], $relatedAttribute);
}
$pair = { [$relatedKeyName] : $key, [$relatedAttribute] : $value}
$return = {...$return, ...$pair};
$(element).attr('data-current-value', JSON.stringify($return));
resolve($return);
},
error: function (result) {
reject(result);
}
});
});
};
}
//this setup the "+Add" button in page with corresponding click handler.
//when clicked, fetches the html for the modal to show
function setupInlineCreateButtons(element) {
var $fieldEntity = element.attr('data-field-related-name');
var $inlineCreateButtonElement = $(element).parent().find('.inline-create-button');
var $inlineModalRoute = element.attr('data-inline-modal-route');
var $inlineModalClass = element.attr('data-inline-modal-class');
var $parentLoadedFields = element.attr('data-parent-loaded-fields');
var $includeMainFormFields = element.attr('data-include-main-form-fields') == 'false' ? false : (element.attr('data-include-main-form-fields') == 'true' ? true : element.attr('data-include-main-form-fields'));
var $form = element.closest('form');
$inlineCreateButtonElement.on('click', function () {
//we change button state so users know something is happening.
var loadingText = '<span class="la la-spinner la-spin" style="font-size:18px;"></span>';
if ($inlineCreateButtonElement.html() !== loadingText) {
$inlineCreateButtonElement.data('original-text', $inlineCreateButtonElement.html());
$inlineCreateButtonElement.html(loadingText);
}
//prepare main form fields to be submited in case there are some.
if(typeof $includeMainFormFields === "boolean" && $includeMainFormFields === true) {
var $toPass = $form.serializeArray();
}else{
if(typeof $includeMainFormFields !== "boolean") {
var $fields = JSON.parse($includeMainFormFields);
var $serializedForm = $form.serializeArray();
var $toPass = [];
$fields.forEach(function(value, index) {
$valueFromForm = $serializedForm.filter(field => field.name === value);
$toPass.push($valueFromForm[0]);
});
$includeMainFormFields = true;
}
}
$.ajax({
url: $inlineModalRoute,
data: (function() {
if($includeMainFormFields) {
return {
'entity': $fieldEntity,
'modal_class' : $inlineModalClass,
'parent_loaded_fields' : $parentLoadedFields,
'main_form_fields' : $toPass
};
}else{
return {
'entity': $fieldEntity,
'modal_class' : $inlineModalClass,
'parent_loaded_fields' : $parentLoadedFields
};
}
})(),
type: 'POST',
success: function (result) {
$('body').append(result);
triggerModal(element);
},
error: function (result) {
// Show an alert with the result
swal({
title: "error",
text: "error",
icon: "error",
timer: 4000,
buttons: false,
});
}
});
});
}
// when an entity is created we query the ajax endpoint to check if the created option is returned.
function ajaxSearch(element, created) {
var $relatedAttribute = element.attr('data-field-attribute');
var $relatedKeyName = element.attr('data-connected-entity-key-name');
var $searchString = created[$relatedAttribute];
//we run the promise with ajax call to search endpoint to check if we got the created entity back
//in case we do, we add it to the selected options.
performAjaxSearch(element, $searchString).then(result => {
var inCreated = $.map(result.data, function (item) {
var $itemText = processItemText(item, $relatedAttribute);
var $createdText = processItemText(created, $relatedAttribute);
if($itemText == $createdText) {
return {
text: $itemText,
id: item[$relatedKeyName]
}
}
});
if(inCreated.length) {
selectOption(element, created);
}
});
}
//this is the function called when button to add is pressed,
//it triggers the modal on page and initialize the fields
function triggerModal(element) {
var $fieldName = element.attr('data-field-related-name');
var $modal = $('#inline-create-dialog');
var $modalSaveButton = $modal.find('#saveButton');
var $modalCancelButton = $modal.find('#cancelButton');
var $form = $(document.getElementById($fieldName+"-inline-create-form"));
var $inlineCreateRoute = element.attr('data-inline-create-route');
var $ajax = element.attr('data-field-ajax') == 'true' ? true : false;
var $force_select = (element.attr('data-force-select') == 'true') ? true : false;
$modal.modal();
initializeFieldsWithJavascript($form);
$modalCancelButton.on('click', function () {
$($modal).modal('hide');
});
//when you hit save on modal save button.
$modalSaveButton.on('click', function () {
$form = document.getElementById($fieldName+"-inline-create-form");
//this is needed otherwise fields like ckeditor don't post their value.
$($form).trigger('form-pre-serialize');
var $formData = new FormData($form);
//we change button state so users know something is happening.
//we also disable it to prevent double form submition
var loadingText = '<i class="la la-spinner la-spin"></i> saving...';
if ($modalSaveButton.html() !== loadingText) {
$modalSaveButton.data('original-text', $(this).html());
$modalSaveButton.html(loadingText);
$modalSaveButton.prop('disabled', true);
}
$.ajax({
url: $inlineCreateRoute,
data: $formData,
processData: false,
contentType: false,
type: 'POST',
success: function (result) {
$createdEntity = result.data;
if(!$force_select) {
//if developer did not force the created entity to be selected we first try to
//check if created is still available upon model re-search.
ajaxSearch(element, result.data);
}else{
selectOption(element, result.data);
}
$modal.modal('hide');
new Noty({
type: "info",
text: '{{ trans('backpack::crud.related_entry_created_success') }}',
}).show();
},
error: function (result) {
var $errors = result.responseJSON.errors;
let message = '';
for (var i in $errors) {
message += $errors[i] + ' \n';
}
new Noty({
type: "error",
text: '<strong>{{ trans('backpack::crud.related_entry_created_error') }}</strong><br> '+message,
}).show();
//revert save button back to normal
$modalSaveButton.prop('disabled', false);
$modalSaveButton.html($modalSaveButton.data('original-text'));
}
});
});
$modal.on('hidden.bs.modal', function (e) {
$modal.remove();
//when modal is closed (canceled or success submited) we revert the "+ Add" loading state back to normal.
var $inlineCreateButtonElement = $(element).parent().find('.inline-create-button');
$inlineCreateButtonElement.html($inlineCreateButtonElement.data('original-text'));
});
$modal.on('shown.bs.modal', function (e) {
$modal.on('keyup', function (e) {
if($modal.is(':visible')) {
var key = e.which;
if (key == 13) { //This is an ENTER
e.preventDefault();
$modalSaveButton.click();
}
}
return false;
});
});
}
//function responsible for adding an option to the select
//it parses any previous options in case of select multiple.
function selectOption(element, option) {
var $relatedAttribute = element.attr('data-field-attribute');
var $relatedKeyName = element.attr('data-connected-entity-key-name');
var $multiple = element.prop('multiple');
var $optionText = processItemText(option, $relatedAttribute);
var $option = new Option($optionText, option[$relatedKeyName]);
$(element).append($option);
if($multiple) {
//we get any options previously selected
var selectedOptions = $(element).val();
//we add the option to the already selected array.
selectedOptions.push(option[$relatedKeyName]);
$(element).val(selectedOptions);
}else{
$(element).val(option[$relatedKeyName]);
}
$(element).trigger('change');
}
function bpFieldInitFetchOrCreateElement(element) {
var form = element.closest('form');
var $inlineField = element.attr('data-is-inline');
var $ajax = element.attr('data-field-ajax') == 'true' ? true : false;
var $placeholder = element.attr('data-placeholder');
var $minimumInputLength = element.attr('data-minimum-input-length');
var $dataSource = element.attr('data-data-source');
var $method = element.attr('data-method');
var $fieldAttribute = element.attr('data-field-attribute');
var $connectedEntityKeyName = element.attr('data-connected-entity-key-name');
var $includeAllFormFields = element.attr('data-include-all-form-fields')=='false' ? false : true;
var $dependencies = JSON.parse(element.attr('data-dependencies'));
var $modelKey = element.attr('data-model-local-key');
var $allows_null = (element.attr('data-allows-null') == 'true') ? true : false;
var $selectedOptions = typeof element.attr('data-selected-options') === 'string' ? JSON.parse(element.attr('data-selected-options')) : JSON.parse(null);
var $multiple = element.prop('multiple');
var $ajaxDelay = element.attr('data-ajax-delay');
var FetchOrCreateAjaxFetchSelectedEntry = function (element) {
return new Promise(function (resolve, reject) {
$.ajax({
url: $dataSource,
data: {
'keys': $selectedOptions
},
type: $method,
success: function (result) {
resolve(result);
},
error: function (result) {
reject(result);
}
});
});
};
if($allows_null && !$multiple) {
$(element).append('<option value="">'+$placeholder+'</option>');
}
if (typeof $selectedOptions !== typeof undefined &&
$selectedOptions !== false &&
$selectedOptions != '' &&
$selectedOptions != null &&
$selectedOptions != [])
{
var optionsForSelect = [];
FetchOrCreateAjaxFetchSelectedEntry(element).then(result => {
result.forEach(function(item) {
$itemText = processItemText(item, $fieldAttribute);
$itemValue = item[$connectedEntityKeyName];
//add current key to be selected later.
optionsForSelect.push($itemValue);
//create the option in the select
$(element).append('<option value="'+$itemValue+'">'+$itemText+'</option>');
});
// set the option keys as selected.
$(element).val(optionsForSelect);
$(element).trigger('change');
});
}
var $item = false;
var $value = JSON.parse(element.attr('data-current-value'))
if(Object.keys($value).length > 0) {
$item = true;
}
var selectedOptions = [];
var $currentValue = $item ? $value : '';
//we reselect the previously selected options if any.
for (const [key, value] of Object.entries($currentValue)) {
selectedOptions.push(key);
var $option = new Option(value, key);
$(element).append($option);
}
$(element).val(selectedOptions);
//null is not allowed we fetch some default entry
if(!$allows_null && !$item && $selectedOptions == null) {
fetchDefaultEntry(element).then(result => {
$(element).append('<option value="'+result[$modelKey]+'">'+result[$fieldAttribute]+'</option>');
$(element).val(result[$modelKey]);
$(element).trigger('change');
});
}
//Checks if field is not beeing inserted in one inline create modal and setup buttons
if($inlineField == "false") {
setupInlineCreateButtons(element);
}
if (!element.hasClass("select2-hidden-accessible")) {
element.select2({
theme: "bootstrap",
placeholder: $placeholder,
minimumInputLength: $minimumInputLength,
allowClear: $allows_null,
ajax: {
url: $dataSource,
type: $method,
dataType: 'json',
delay: $ajaxDelay,
data: function (params) {
if ($includeAllFormFields) {
return {
q: params.term, // search term
page: params.page, // pagination
form: form.serializeArray() // all other form inputs
};
} else {
return {
q: params.term, // search term
page: params.page, // pagination
};
}
},
processResults: function (data, params) {
params.page = params.page || 1;
//if we have data.data here it means we returned a paginated instance from controller.
//otherwise we returned one or more entries unpaginated.
if(data.data) {
var result = {
results: $.map(data.data, function (item) {
var $itemText = processItemText(item, $fieldAttribute);
return {
text: $itemText,
id: item[$connectedEntityKeyName]
}
}),
pagination: {
more: data.current_page < data.last_page
}
};
}else {
var result = {
results: $.map(data, function (item) {
var $itemText = processItemText(item, $fieldAttribute);
return {
text: $itemText,
id: item[$connectedEntityKeyName]
}
}),
pagination: {
more: false,
}
}
}
return result;
},
cache: true
},
});
// if any dependencies have been declared
// when one of those dependencies changes value
// reset the select2 value
for (var i=0; i < $dependencies.length; i++) {
var $dependency = $dependencies[i];
//if element does not have a custom-selector attribute we use the name attribute
if(typeof element.attr('data-custom-selector') === 'undefined') {
form.find(`[name="${$dependency}"], [name="${$dependency}[]"]`).change(function(el) {
$(element.find('option:not([value=""])')).remove();
element.val(null).trigger("change");
});
}else{
// we get the row number and custom selector from where element is called
let rowNumber = element.attr('data-row-number');
let selector = element.attr('data-custom-selector');
// replace in the custom selector string the corresponding row and dependency name to match
selector = selector
.replaceAll('%DEPENDENCY%', $dependency)
.replaceAll('%ROW%', rowNumber);
$(selector).change(function (el) {
$(element.find('option:not([value=""])')).remove();
element.val(null).trigger("change");
});
}
}
}
}
if (typeof processItemText !== 'function') {
function processItemText(item, $fieldAttribute) {
var $appLang = '{{ app()->getLocale() }}';
var $appLangFallback = '{{ Lang::getFallback() }}';
var $emptyTranslation = '{{ trans("backpack::crud.empty_translations") }}';
var $itemField = item[$fieldAttribute];
// try to retreive the item in app language; then fallback language; then first entry; if nothing found empty translation string
return typeof $itemField === 'object' && $itemField !== null
? $itemField[$appLang] ?? $itemField[$appLangFallback] ?? Object.values($itemField)[0] ?? $emptyTranslation
: $itemField;
}
}
</script>
@endpush
@endif
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,7 @@
data-inline-create-route="{{$field['inline_create']['create_route'] ?? false}}"
data-inline-modal-route="{{$field['inline_create']['modal_route'] ?? false}}"
data-field-related-name="{{$field['inline_create']['entity']}}"
data-inline-create-button="{{ $field['inline_create']['entity'] }}-inline-create-{{$field['name']}}"
data-inline-allow-create="{{var_export($activeInlineCreate)}}"
data-parent-loaded-fields="{{json_encode(array_unique(array_column($crud->fields(),'type')))}}"

View File

@ -0,0 +1,15 @@
<input type="hidden" name="http_referrer" value={{ old('http_referrer') ?? \URL::previous() ?? url($crud->route) }}>
{{-- See if we're using tabs --}}
@if ($crud->tabsEnabled() && count($crud->getTabs()))
@include('crud::fields.relationship.show_tabbed_fields')
<input type="hidden" name="current_tab" value="{{ Str::slug($crud->getTabs()[0], "") }}" />
@else
<div class="card">
<div class="card-body row">
@include('crud::fields.relationship.show_fields', ['fields' => $crud->fields()])
</div>
</div>
@endif

View File

@ -0,0 +1 @@
<button type="button" class="btn btn-sm btn-link float-right inline-create-button"><span class="la la-plus"></span>{{trans('backpack::crud.add')}}</span></button>

View File

@ -0,0 +1,52 @@
@php
$loadedFields = json_decode($parentLoadedFields);
//mark parent crud fields as loaded.
foreach($loadedFields as $loadedField) {
$crud->markFieldTypeAsLoaded($loadedField);
}
@endphp
<div class="modal fade" id="inline-create-dialog" tabindex="0" role="dialog" aria-labelledby="{{$entity}}-inline-create-dialog-label" aria-hidden="true">
<div class="{{ $modalClass }}" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="{{ $entity }}-inline-create-dialog-label">
{!! $crud->getSubheading() ?? trans('backpack::crud.add').' '.$crud->entity_name !!}
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body bg-light">
<form method="post"
id="{{$entity}}-inline-create-form"
action="#"
onsubmit="return false"
@if ($crud->hasUploadFields('create'))
enctype="multipart/form-data"
@endif
>
{!! csrf_field() !!}
<!-- load the view from the application if it exists, otherwise load the one in the package -->
@if(view()->exists('vendor.backpack.crud.fields.relationship.form_content'))
@include('vendor.backpack.crud.fields.relationship.form_content', [ 'fields' => $fields, 'action' => $action])
@else
@include('crud::fields.relationship.form_content', [ 'fields' => $fields, 'action' => $action])
@endif
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id="cancelButton">{{trans('backpack::crud.cancel')}}</button>
<button type="button" class="btn btn-primary" id="saveButton">{{trans('backpack::crud.save')}}</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,186 @@
@php
$connected_entity = new $field['model'];
$connected_entity_key_name = $connected_entity->getKeyName();
$field['multiple'] = $field['multiple'] ?? $crud->relationAllowsMultiple($field['relation_type']);
$field['attribute'] = $field['attribute'] ?? $connected_entity->identifiableAttribute();
$field['include_all_form_fields'] = $field['include_all_form_fields'] ?? true;
$field['allows_null'] = $field['allows_null'] ?? $crud->model::isColumnNullable($field['name']);
// Note: isColumnNullable returns true if column is nullable in database, also true if column does not exist.
if (!isset($field['options'])) {
$field['options'] = $connected_entity::all()->pluck($field['attribute'],$connected_entity_key_name);
} else {
$field['options'] = call_user_func($field['options'], $field['model']::query())->pluck($field['attribute'],$connected_entity_key_name);
}
// make sure the $field['value'] takes the proper value
// and format it to JSON, so that select2 can parse it
$current_value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '';
if ($current_value != false) {
switch (gettype($current_value)) {
case 'array':
$current_value = $connected_entity
->whereIn($connected_entity_key_name, $current_value)
->get()
->pluck($field['attribute'], $connected_entity_key_name);
break;
case 'object':
if (is_subclass_of(get_class($current_value), 'Illuminate\Database\Eloquent\Model') ) {
$current_value = [$current_value->{$connected_entity_key_name} => $current_value->{$field['attribute']}];
}else{
$current_value = $current_value
->pluck($field['attribute'], $connected_entity_key_name);
}
break;
default:
$current_value = $connected_entity
->where($connected_entity_key_name, $current_value)
->get()
->pluck($field['attribute'], $connected_entity_key_name);
break;
}
}
$field['value'] = json_encode($current_value);
@endphp
@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
<select
style="width:100%"
name="{{ $field['name'].($field['multiple']?'[]':'') }}"
data-init-function="bpFieldInitRelationshipSelectElement"
data-column-nullable="{{ var_export($field['allows_null']) }}"
data-dependencies="{{ isset($field['dependencies'])?json_encode(Arr::wrap($field['dependencies'])): json_encode([]) }}"
data-model-local-key="{{$crud->model->getKeyName()}}"
data-placeholder="{{ $field['placeholder'] }}"
data-field-attribute="{{ $field['attribute'] }}"
data-connected-entity-key-name="{{ $connected_entity_key_name }}"
data-include-all-form-fields="{{ var_export($field['include_all_form_fields']) }}"
data-current-value="{{ $field['value'] }}"
data-field-multiple="{{var_export($field['multiple'])}}"
@include('crud::fields.inc.attributes', ['default_class' => 'form-control'])
@if($field['multiple'])
multiple
@endif
>
@if ($field['allows_null'])
<option value="">-</option>
@endif
@if (count($field['options']))
@foreach ($field['options'] as $key => $option)
<option value="{{ $key }}">{{ $option }}</option>
@endforeach
@endif
</select>
{{-- HINT --}}
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
@include('crud::fields.inc.wrapper_end')
{{-- ########################################## --}}
{{-- Extra CSS and JS for this particular field --}}
{{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}}
@if ($crud->fieldTypeNotLoaded($field))
@php
$crud->markFieldTypeAsLoaded($field);
@endphp
{{-- FIELD CSS - will be loaded in the after_styles section --}}
@push('crud_fields_styles')
<!-- include select2 css-->
<link href="{{ asset('packages/select2/dist/css/select2.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
{{-- FIELD JS - will be loaded in the after_scripts section --}}
@push('crud_fields_scripts')
<!-- include select2 js-->
<script src="{{ asset('packages/select2/dist/js/select2.full.min.js') }}"></script>
@if (app()->getLocale() !== 'en')
<script src="{{ asset('packages/select2/dist/js/i18n/' . app()->getLocale() . '.js') }}"></script>
@endif
@endpush
<!-- include field specific select2 js-->
@push('crud_fields_scripts')
<script>
// if nullable, make sure the Clear button uses the translated string
document.styleSheets[0].addRule('.select2-selection__clear::after','content: "{{ trans('backpack::crud.clear') }}";');
/**
*
* This method gets called automatically by Backpack:
*
* @param node element The jQuery-wrapped "select" element.
* @return void
*/
function bpFieldInitRelationshipSelectElement(element) {
var form = element.closest('form');
var $placeholder = element.attr('data-placeholder');
var $modelKey = element.attr('data-model-local-key');
var $fieldAttribute = element.attr('data-field-attribute');
var $connectedEntityKeyName = element.attr('data-connected-entity-key-name');
var $includeAllFormFields = element.attr('data-include-all-form-fields') == 'false' ? false : true;
var $dependencies = JSON.parse(element.attr('data-dependencies'));
var $multiple = element.attr('data-field-multiple') == 'false' ? false : true;
var $selectedOptions = typeof element.attr('data-selected-options') === 'string' ? JSON.parse(element.attr('data-selected-options')) : JSON.parse(null);
var $allows_null = (element.attr('data-column-nullable') == 'true') ? true : false;
var $allowClear = $allows_null;
var $item = false;
var $value = JSON.parse(element.attr('data-current-value'))
if(Object.keys($value).length > 0) {
$item = true;
}
var selectedOptions = [];
var $currentValue = $item ? $value : '';
for (const [key, value] of Object.entries($currentValue)) {
selectedOptions.push(key);
$(element).val(selectedOptions);
}
if (!$allows_null && $item === false) {
element.find('option:eq(0)').prop('selected', true);
}
$(element).attr('data-current-value',$(element).val());
$(element).trigger('change');
var $select2Settings = {
theme: 'bootstrap',
multiple: $multiple,
placeholder: $placeholder,
allowClear: $allowClear,
};
if (!$(element).hasClass("select2-hidden-accessible"))
{
$(element).select2($select2Settings);
}
}
</script>
@endpush
@endif
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,21 @@
{{-- Show the inputs --}}
@foreach ($fields as $field)
<!-- load the view from type and view_namespace attribute if set -->
@php
$fieldsViewNamespace = $field['view_namespace'] ?? 'crud::fields';
@endphp
@include($fieldsViewNamespace.'.'.$field['type'], ['field' => $field, 'inlineCreate' => true])
@endforeach
<!-- This is where modal fields assets are pushed.
We bind the modal content including what fields pushed to this stacks to the end of the body tag,
so we make sure all backpack assets are previously loaded, like jquery etc.
We can give the same stack name because backpack `crud_fields_scripts` is already rendered and
this is the only available when rendering the modal html.
-->
@stack('crud_fields_scripts')
@stack('crud_fields_styles')

View File

@ -0,0 +1,62 @@
@php
$horizontalTabs = $crud->getTabsType()=='horizontal' ? true : false;
if ($errors->any() && array_key_exists(array_keys($errors->messages())[0], $crud->getCurrentFields()) &&
array_key_exists('tab', $crud->getCurrentFields()[array_keys($errors->messages())[0]])) {
$tabWithError = ($crud->getCurrentFields()[array_keys($errors->messages())[0]]['tab']);
}
@endphp
@push('crud_fields_styles')
<style>
.nav-tabs-custom {
box-shadow: none;
}
.nav-tabs-custom > .nav-tabs.nav-stacked > li {
margin-right: 0;
}
.tab-pane .form-group h1:first-child,
.tab-pane .form-group h2:first-child,
.tab-pane .form-group h3:first-child {
margin-top: 0;
}
</style>
@endpush
@if ($crud->getFieldsWithoutATab()->filter(function ($value, $key) { return $value['type'] != 'hidden'; })->count())
<div class="card">
<div class="card-body row">
@include('crud::fields.relationship.show_fields', ['fields' => $crud->getFieldsWithoutATab()])
</div>
</div>
@else
@include('crud::fields.relationship.show_fields', ['fields' => $crud->getFieldsWithoutATab()])
@endif
<div class="tab-container {{ $horizontalTabs ? '' : 'container'}} mb-2">
<div class="nav-tabs-custom {{ $horizontalTabs ? '' : 'row'}}" id="inline_form_tabs">
<ul class="nav {{ $horizontalTabs ? 'nav-tabs' : 'flex-column nav-pills'}} {{ $horizontalTabs ? '' : 'col-md-3' }}" role="tablist">
@foreach ($crud->getTabs() as $k => $tab)
<li role="presentation" class="nav-item">
<a href="#inline_tab_{{ Str::slug($tab, "") }}" aria-controls="inline_tab_{{ Str::slug($tab, "") }}" role="tab" tab_name="inline_{{ Str::slug($tab, "") }}" data-toggle="tab" class="nav-link {{ isset($tabWithError) ? ($tab == $tabWithError ? 'active' : '') : ($k == 0 ? 'active' : '') }}">{{ $tab }}</a>
</li>
@endforeach
</ul>
<div class="tab-content p-0 {{$horizontalTabs ? '' : 'col-md-9'}}">
@foreach ($crud->getTabs() as $k => $tab)
<div role="tabpanel" class="tab-pane {{ isset($tabWithError) ? ($tab == $tabWithError ? ' active' : '') : ($k == 0 ? ' active' : '') }}" id="inline_tab_{{ Str::slug($tab, "") }}">
<div class="row">
@include('crud::fields.relationship.show_fields', ['fields' => $crud->getTabFields($tab)])
</div>
</div>
@endforeach
</div>
</div>
</div>

View File

@ -0,0 +1,2 @@
{{-- Formula Backpack CRUD filter --}}
// TODO

View File

@ -0,0 +1 @@
{{-- Select2 Multiple Ajax Backpack CRUD filter --}}

View File

@ -0,0 +1,105 @@
{{-- Date Range Backpack CRUD filter --}}
<li filter-name="{{ $filter->name }}"
filter-type="{{ $filter->type }}"
filter-key="{{ $filter->key }}"
class="nav-item dropdown {{ Request::get($filter->name)?'active':'' }}">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ $filter->label }} <span class="caret"></span></a>
<div class="dropdown-menu p-0">
<div class="form-group backpack-filter mb-0">
<div class="input-group date">
<div class="input-group-prepend">
<span class="input-group-text"><i class="la la-calendar"></i></span>
</div>
<input class="form-control pull-right"
id="datepicker-{{ $filter->key }}"
type="text"
@if ($filter->currentValue)
value="{{ $filter->currentValue }}"
@endif
>
<div class="input-group-append datepicker-{{ $filter->key }}-clear-button">
<a class="input-group-text" href=""><i class="la la-times"></i></a>
</div>
</div>
</div>
</div>
</li>
{{-- ########################################### --}}
{{-- Extra CSS and JS for this particular filter --}}
{{-- FILTERS EXTRA CSS --}}
{{-- push things in the after_styles section --}}
@push('crud_list_styles')
<link rel="stylesheet" href="{{ asset('packages/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css') }}">
<style>
.input-group.date {
width: 320px;
max-width: 100%;
}
</style>
@endpush
{{-- FILTERS EXTRA JS --}}
{{-- push things in the after_scripts section --}}
@push('crud_list_scripts')
<!-- include select2 js-->
<script src="{{ asset('packages/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js') }}"></script>
<script>
jQuery(document).ready(function($) {
var dateInput = $('#datepicker-{{ $filter->key }}').datepicker({
autoclose: true,
format: 'yyyy-mm-dd',
todayHighlight: true
})
.on('changeDate', function(e) {
var d = new Date(e.date);
// console.log(e);
// console.log(d);
if (isNaN(d.getFullYear())) {
var value = '';
} else {
var value = d.getFullYear() + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2);
}
var parameter = '{{ $filter->name }}';
// behaviour for ajax table
var ajax_table = $('#crudTable').DataTable();
var current_url = ajax_table.ajax.url();
var new_url = addOrUpdateUriParameter(current_url, parameter, value);
// replace the datatables ajax url with new_url and reload it
new_url = normalizeAmpersand(new_url.toString());
ajax_table.ajax.url(new_url).load();
// add filter to URL
crud.updateUrl(new_url);
// mark this filter as active in the navbar-filters
if (URI(new_url).hasQuery('{{ $filter->name }}', true)) {
$('li[filter-key={{ $filter->key }}]').removeClass('active').addClass('active');
}
});
$('li[filter-key={{ $filter->key }}]').on('filter:clear', function(e) {
// console.log('date filter cleared');
$('li[filter-key={{ $filter->key }}]').removeClass('active');
$('#datepicker-{{ $filter->key }}').datepicker('update', '');
$('#datepicker-{{ $filter->key }}').trigger('changeDate');
});
// datepicker clear button
$(".datepicker-{{ $filter->key }}-clear-button").click(function(e) {
e.preventDefault();
$('li[filter-key={{ $filter->key }}]').trigger('filter:clear');
})
});
</script>
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,171 @@
{{-- Date Range Backpack CRUD filter --}}
@php
$filter->options['date_range_options'] = array_replace_recursive([
'timePicker' => false,
'alwaysShowCalendars' => true,
'autoUpdateInput' => true,
'startDate' => \Carbon\Carbon::now()->toDateTimeString(),
'endDate' => \Carbon\Carbon::now()->toDateTimeString(),
'ranges' => [
trans('backpack::crud.today') => [\Carbon\Carbon::now()->startOfDay()->toDateTimeString(), \Carbon\Carbon::now()->endOfDay()->toDateTimeString()],
trans('backpack::crud.yesterday') => [\Carbon\Carbon::now()->subDay()->startOfDay()->toDateTimeString(), \Carbon\Carbon::now()->subDay()->endOfDay()->toDateTimeString()],
trans('backpack::crud.last_7_days') => [\Carbon\Carbon::now()->subDays(6)->startOfDay()->toDateTimeString(), \Carbon\Carbon::now()->toDateTimeString()],
trans('backpack::crud.last_30_days') => [\Carbon\Carbon::now()->subDays(29)->startOfDay()->toDateTimeString(), \Carbon\Carbon::now()->toDateTimeString()],
trans('backpack::crud.this_month') => [\Carbon\Carbon::now()->startOfMonth()->toDateTimeString(), \Carbon\Carbon::now()->endOfMonth()->toDateTimeString()],
trans('backpack::crud.last_month') => [\Carbon\Carbon::now()->subMonth()->startOfMonth()->toDateTimeString(), \Carbon\Carbon::now()->subMonth()->endOfMonth()->toDateTimeString()]
],
'locale' => [
'firstDay' => 0,
'format' => config('backpack.base.default_date_format'),
'applyLabel'=> trans('backpack::crud.apply'),
'cancelLabel'=> trans('backpack::crud.cancel'),
'customRangeLabel' => trans('backpack::crud.custom_range')
],
], $filter->options['date_range_options'] ?? []);
//if filter is active we override developer init values
if($filter->currentValue) {
$dates = (array)json_decode($filter->currentValue);
$filter->options['date_range_options']['startDate'] = $dates['from'];
$filter->options['date_range_options']['endDate'] = $dates['to'];
}
@endphp
<li filter-name="{{ $filter->name }}"
filter-type="{{ $filter->type }}"
filter-key="{{ $filter->key }}"
class="nav-item dropdown {{ Request::get($filter->name)?'active':'' }}">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ $filter->label }} <span class="caret"></span></a>
<div class="dropdown-menu p-0">
<div class="form-group backpack-filter mb-0">
<div class="input-group date">
<div class="input-group-prepend">
<span class="input-group-text"><i class="la la-calendar"></i></span>
</div>
<input class="form-control pull-right"
id="daterangepicker-{{ $filter->key }}"
type="text"
data-bs-daterangepicker="{{ json_encode($filter->options['date_range_options'] ?? []) }}"
>
<div class="input-group-append daterangepicker-{{ $filter->key }}-clear-button">
<a class="input-group-text" href=""><i class="la la-times"></i></a>
</div>
</div>
</div>
</div>
</li>
{{-- ########################################### --}}
{{-- Extra CSS and JS for this particular filter --}}
{{-- FILTERS EXTRA CSS --}}
{{-- push things in the after_styles section --}}
@push('crud_list_styles')
<!-- include select2 css-->
<link rel="stylesheet" type="text/css" href="{{ asset('packages/bootstrap-daterangepicker/daterangepicker.css') }}" />
<style>
.input-group.date {
width: 320px;
max-width: 100%; }
.daterangepicker.dropdown-menu {
z-index: 3001!important;
}
</style>
@endpush
{{-- FILTERS EXTRA JS --}}
{{-- push things in the after_scripts section --}}
@push('crud_list_scripts')
<script type="text/javascript" src="{{ asset('packages/moment/min/moment-with-locales.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('packages/bootstrap-daterangepicker/daterangepicker.js') }}"></script>
<script>
function applyDateRangeFilter{{$filter->key}}(start, end) {
if (start && end) {
var dates = {
'from': start.format('YYYY-MM-DD HH:mm:ss '),
'to': end.format('YYYY-MM-DD HH:mm:ss')
};
var value = JSON.stringify(dates);
} else {
var value = '';
}
var parameter = '{{ $filter->name }}';
// behaviour for ajax table
var ajax_table = $('#crudTable').DataTable();
var current_url = ajax_table.ajax.url();
var new_url = addOrUpdateUriParameter(current_url, parameter, value);
// replace the datatables ajax url with new_url and reload it
new_url = normalizeAmpersand(new_url.toString());
ajax_table.ajax.url(new_url).load();
// add filter to URL
crud.updateUrl(new_url);
// mark this filter as active in the navbar-filters
if (URI(new_url).hasQuery('{{ $filter->name }}', true)) {
$('li[filter-key={{ $filter->key }}]').removeClass('active').addClass('active');
} else {
$('li[filter-key={{ $filter->key }}]').trigger('filter:clear');
}
}
jQuery(document).ready(function($) {
moment.locale('{{app()->getLocale()}}');
var dateRangeInput = $('#daterangepicker-{{ $filter->key }}');
$config = dateRangeInput.data('bs-daterangepicker');
$ranges = $config.ranges;
$config.ranges = {};
//if developer configured ranges we convert it to moment() dates.
for (var key in $ranges) {
if ($ranges.hasOwnProperty(key)) {
$config.ranges[key] = $.map($ranges[key], function($val) {
return moment($val);
});
}
}
$config.startDate = moment($config.startDate);
$config.endDate = moment($config.endDate);
dateRangeInput.daterangepicker($config);
dateRangeInput.on('apply.daterangepicker', function(ev, picker) {
applyDateRangeFilter{{$filter->key}}(picker.startDate, picker.endDate);
});
$('li[filter-key={{ $filter->key }}]').on('hide.bs.dropdown', function () {
if($('.daterangepicker').is(':visible'))
return false;
});
$('li[filter-key={{ $filter->key }}]').on('filter:clear', function(e) {
//if triggered by remove filters click just remove active class,no need to send ajax
$('li[filter-key={{ $filter->key }}]').removeClass('active');
});
// datepicker clear button
$(".daterangepicker-{{ $filter->key }}-clear-button").click(function(e) {
e.preventDefault();
applyDateRangeFilter{{$filter->key}}(null, null);
});
});
</script>
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,85 @@
{{-- Dropdown Backpack CRUD filter --}}
<li filter-name="{{ $filter->name }}"
filter-type="{{ $filter->type }}"
filter-key="{{ $filter->key }}"
class="nav-item dropdown {{ Request::get($filter->name)?'active':'' }}">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ $filter->label }} <span class="caret"></span></a>
<ul class="dropdown-menu">
<a class="dropdown-item" parameter="{{ $filter->name }}" dropdownkey="" href="">-</a>
<div role="separator" class="dropdown-divider"></div>
@if (is_array($filter->values) && count($filter->values))
@foreach($filter->values as $key => $value)
@if ($key === 'dropdown-separator')
<div role="separator" class="dropdown-divider"></div>
@else
<a class="dropdown-item {{ ($filter->isActive() && $filter->currentValue == $key)?'active':'' }}"
parameter="{{ $filter->name }}"
href=""
dropdownkey="{{ $key }}"
>{{ $value }}</a>
@endif
@endforeach
@endif
</ul>
</li>
{{-- ########################################### --}}
{{-- Extra CSS and JS for this particular filter --}}
{{-- FILTERS EXTRA CSS --}}
{{-- push things in the after_styles section --}}
{{-- @push('crud_list_styles')
<!-- no css -->
@endpush --}}
{{-- FILTERS EXTRA JS --}}
{{-- push things in the after_scripts section --}}
@push('crud_list_scripts')
<script>
jQuery(document).ready(function($) {
$("li.dropdown[filter-key={{ $filter->key }}] .dropdown-menu a").click(function(e) {
e.preventDefault();
var value = $(this).attr('dropdownkey');
var parameter = $(this).attr('parameter');
// behaviour for ajax table
var ajax_table = $("#crudTable").DataTable();
var current_url = ajax_table.ajax.url();
var new_url = addOrUpdateUriParameter(current_url, parameter, value);
// replace the datatables ajax url with new_url and reload it
new_url = normalizeAmpersand(new_url.toString());
ajax_table.ajax.url(new_url).load();
// add filter to URL
crud.updateUrl(new_url);
// mark this filter as active in the navbar-filters
// mark dropdown items active accordingly
if (URI(new_url).hasQuery('{{ $filter->name }}', true)) {
$("li[filter-key={{ $filter->key }}]").removeClass('active').addClass('active');
$("li[filter-key={{ $filter->key }}] .dropdown-menu a").removeClass('active');
$(this).addClass('active');
}
else
{
$("li[filter-key={{ $filter->key }}]").trigger("filter:clear");
}
});
// clear filter event (used here and by the Remove all filters button)
$("li[filter-key={{ $filter->key }}]").on('filter:clear', function(e) {
// console.log('dropdown filter cleared');
$("li[filter-key={{ $filter->key }}]").removeClass('active');
$("li[filter-key={{ $filter->key }}] .dropdown-menu a").removeClass('active');
});
});
</script>
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,85 @@
{{-- Example Backpack CRUD filter --}}
<li filter-name="{{ $filter->name }}"
filter-type="{{ $filter->type }}"
filter-key="{{ $filter->key }}"
class="nav-item dropdown {{ Request::get($filter->name)?'active':'' }}">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ $filter->label }} <span class="caret"></span></a>
<div class="dropdown-menu padding-10">
{{-- dropdown content: everything you need is inside $filter --}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Unde, inventore assumenda voluptate accusantium recusandae ipsam magni atque vel omnis est debitis, neque nam aspernatur ex quo fuga, nulla soluta. Rerum.
</div>
</li>
{{-- ########################################### --}}
{{-- Extra CSS and JS for this particular filter --}}
{{-- FILTERS EXTRA CSS --}}
{{-- push things in the after_styles section --}}
{{-- @push('crud_list_styles')
<!-- no css -->
@endpush --}}
{{-- FILTERS EXTRA JS --}}
{{-- push things in the after_scripts section --}}
{{-- FILTER JAVASCRIPT CHECKLIST
- redirects to a new URL for standard DataTables
- replaces the search URL for ajax DataTables
- users have a way to clear this filter (and only this filter)
- filter:clear event on li[filter-name], which is called by the "Remove all filters" button, clears this filter;
END OF FILTER JAVSCRIPT CHECKLIST --}}
@push('crud_list_scripts')
<script>
jQuery(document).ready(function($) {
$("li[filter-name={{ $filter->name }}] a").click(function(e) {
e.preventDefault();
var parameter = $(this).attr('parameter');
// behaviour for ajax table
var ajax_table = $("#crudTable").DataTable();
var current_url = ajax_table.ajax.url();
if (URI(current_url).hasQuery(parameter)) {
var new_url = URI(current_url).removeQuery(parameter, true);
} else {
var new_url = URI(current_url).addQuery(parameter, true);
}
// replace the datatables ajax url with new_url and reload it
new_url = normalizeAmpersand(new_url.toString());
ajax_table.ajax.url(new_url).load();
// add filter to URL
crud.updateUrl(new_url);
// mark this filter as active in the navbar-filters
if (URI(new_url).hasQuery('{{ $filter->name }}', true)) {
$("li[filter-key={{ $filter->key }}]").removeClass('active').addClass('active');
}
else
{
$("li[filter-key={{ $filter->key }}]").trigger("filter:clear");
}
});
// clear filter event (used here and by the Remove all filters button)
$("li[filter-key={{ $filter->key }}]").on('filter:clear', function(e) {
// console.log('dropdown filter cleared');
$("li[filter-key={{ $filter->key }}]").removeClass('active');
});
});
</script>
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,131 @@
{{-- Example Backpack CRUD filter --}}
<li filter-name="{{ $filter->name }}"
filter-type="{{ $filter->type }}"
filter-key="{{ $filter->key }}"
class="nav-item dropdown {{ Request::get($filter->name)?'active':'' }}">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ $filter->label }} <span class="caret"></span></a>
<div class="dropdown-menu p-0">
<div class="form-group backpack-filter mb-0">
<?php
$from = '';
$to = '';
if ($filter->currentValue) {
$range = (array) json_decode($filter->currentValue);
$from = $range['from'];
$to = $range['to'];
}
?>
<div class="input-group">
<input class="form-control pull-right from"
type="number"
@if($from)
value = "{{ $from }}"
@endif
@if(array_key_exists('label_from', $filter->options))
placeholder = "{{ $filter->options['label_from'] }}"
@else
placeholder = "min value"
@endif
>
<input class="form-control pull-right to"
type="number"
@if($to)
value = "{{ $to }}"
@endif
@if(array_key_exists('label_to', $filter->options))
placeholder = "{{ $filter->options['label_to'] }}"
@else
placeholder = "max value"
@endif
>
<div class="input-group-append range-filter-{{ $filter->key }}-clear-button">
<a class="input-group-text" href=""><i class="la la-times"></i></a>
</div>
</div>
</div>
</div>
</li>
{{-- ########################################### --}}
{{-- Extra CSS and JS for this particular filter --}}
{{-- FILTERS EXTRA CSS --}}
{{-- push things in the after_styles section --}}
{{-- @push('crud_list_styles')
<!-- no css -->
@endpush --}}
{{-- FILTERS EXTRA JS --}}
{{-- push things in the after_scripts section --}}
{{-- FILTER JAVASCRIPT CHECKLIST
- redirects to a new URL for standard DataTables
- replaces the search URL for ajax DataTables
- users have a way to clear this filter (and only this filter)
- filter:clear event on li[filter-name], which is called by the "Remove all filters" button, clears this filter;
END OF FILTER JAVSCRIPT CHECKLIST --}}
@push('crud_list_scripts')
<script>
jQuery(document).ready(function($) {
$("li[filter-key={{ $filter->key }}] .from, li[filter-key={{ $filter->key }}] .to").change(function(e) {
e.preventDefault();
var from = $("li[filter-key={{ $filter->key }}] .from").val();
var to = $("li[filter-key={{ $filter->key }}] .to").val();
if (from || to) {
var range = {
'from': from,
'to': to
};
var value = JSON.stringify(range);
} else {
//this change to empty string,because addOrUpdateUriParameter method just judgment string
var value = '';
}
var parameter = '{{ $filter->name }}';
// behaviour for ajax table
var ajax_table = $('#crudTable').DataTable();
var current_url = ajax_table.ajax.url();
var new_url = addOrUpdateUriParameter(current_url, parameter, value);
// replace the datatables ajax url with new_url and reload it
new_url = normalizeAmpersand(new_url.toString());
ajax_table.ajax.url(new_url).load();
// add filter to URL
crud.updateUrl(new_url);
// mark this filter as active in the navbar-filters
if (URI(new_url).hasQuery('{{ $filter->name }}', true)) {
$('li[filter-key={{ $filter->key }}]').removeClass('active').addClass('active');
}
});
$('li[filter-key={{ $filter->key }}]').on('filter:clear', function(e) {
$('li[filter-key={{ $filter->key }}]').removeClass('active');
$("li[filter-key={{ $filter->key }}] .from").val("");
$("li[filter-key={{ $filter->key }}] .to").val("");
$("li[filter-key={{ $filter->key }}] .to").trigger('change');
});
// range clear button
$(".range-filter-{{ $filter->key }}-clear-button").click(function(e) {
e.preventDefault();
$('li[filter-key={{ $filter->key }}]').trigger('filter:clear');
})
});
</script>
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,134 @@
{{-- Select2 Backpack CRUD filter --}}
<li filter-name="{{ $filter->name }}"
filter-type="{{ $filter->type }}"
filter-key="{{ $filter->key }}"
class="nav-item dropdown {{ Request::get($filter->name)?'active':'' }}">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ $filter->label }} <span class="caret"></span></a>
<div class="dropdown-menu p-0">
<div class="form-group backpack-filter mb-0">
<select id="filter_{{ $filter->key }}" name="filter_{{ $filter->key }}" data-filter-key="{{ $filter->key }}" class="form-control input-sm select2" data-filter-type="select2" data-filter-name="{{ $filter->name }}" placeholder="{{ $filter->placeholder }}">
<option value="">-</option>
@if (is_array($filter->values) && count($filter->values))
@foreach($filter->values as $key => $value)
<option value="{{ $key }}"
@if($filter->isActive() && $filter->currentValue == $key)
selected
@endif
>
{{ $value }}
</option>
@endforeach
@endif
</select>
</div>
</div>
</li>
{{-- ########################################### --}}
{{-- Extra CSS and JS for this particular filter --}}
{{-- FILTERS EXTRA CSS --}}
{{-- push things in the after_styles section --}}
@push('crud_list_styles')
<!-- include select2 css-->
<link href="{{ asset('packages/select2/dist/css/select2.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
<style>
.form-inline .select2-container {
display: inline-block;
}
.select2-drop-active {
border:none;
}
.select2-container .select2-choices .select2-search-field input, .select2-container .select2-choice, .select2-container .select2-choices {
border: none;
}
.select2-container-active .select2-choice {
border: none;
box-shadow: none;
}
.select2-container--bootstrap .select2-dropdown {
margin-top: -2px;
margin-left: -1px;
}
.select2-container--bootstrap {
position: relative!important;
top: 0px!important;
}
</style>
@endpush
{{-- FILTERS EXTRA JS --}}
{{-- push things in the after_scripts section --}}
@push('crud_list_scripts')
<!-- include select2 js-->
<script src="{{ asset('packages/select2/dist/js/select2.full.min.js') }}"></script>
@if (app()->getLocale() !== 'en')
<script src="{{ asset('packages/select2/dist/js/i18n/' . app()->getLocale() . '.js') }}"></script>
@endif
<script>
jQuery(document).ready(function($) {
// trigger select2 for each untriggered select2 box
$('select[data-filter-type=select2]').not('[data-filter-enabled]').each(function () {
var filterName = $(this).attr('data-filter-name');
var filter_key = $(this).attr('data-filter-key');
var element = $(this);
$(this).attr('data-filter-enabled', 'true');
var obj = $(this).select2({
allowClear: true,
closeOnSelect: false,
theme: "bootstrap",
dropdownParent: $(this).parent('.form-group'),
placeholder: $(this).attr('placeholder'),
});
$(this).change(function() {
var value = $(this).val();
var parameter = $(this).attr('data-filter-name');
// behaviour for ajax table
var ajax_table = $("#crudTable").DataTable();
var current_url = ajax_table.ajax.url();
var new_url = addOrUpdateUriParameter(current_url, parameter, value);
// replace the datatables ajax url with new_url and reload it
new_url = normalizeAmpersand(new_url.toString());
ajax_table.ajax.url(new_url).load();
// add filter to URL
crud.updateUrl(new_url);
// mark this filter as active in the navbar-filters
if (URI(new_url).hasQuery(parameter, true)) {
$("li[filter-key="+filter_key+"]").addClass('active');
}
else
{
$("li[filter-key="+filter_key+"]").removeClass("active");
$("li[filter-key="+filter_key+"]").find('.dropdown-menu').removeClass("show");
}
});
// when the dropdown is opened, autofocus on the select2
$("li[filter-key="+filter_key+"]").on('shown.bs.dropdown', function () {
$('select[data-filter-key='+filter_key+']').select2('open');
});
// clear filter event (used here and by the Remove all filters button)
$("li[filter-key="+filter_key+"]").on('filter:clear', function(e) {
// console.log('select2 filter cleared');
$("li[filter-key="+filter_key+"]").removeClass('active');
$('#filter_'+filter_key).val(null).trigger('change');
});
});
});
</script>
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,184 @@
{{-- Select2 Ajax Backpack CRUD filter --}}
@php
$filter->options['quiet_time'] = $filter->options['quiet_time'] ?? $filter->options['delay'] ?? 500;
@endphp
<li filter-name="{{ $filter->name }}"
filter-type="{{ $filter->type }}"
filter-key="{{ $filter->key }}"
class="nav-item dropdown {{ Request::get($filter->name)?'active':'' }}">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ $filter->label }} <span class="caret"></span></a>
<div class="dropdown-menu p-0 ajax-select">
<div class="form-group mb-0">
<select
id="filter_{{ $filter->key }}"
name="filter_{{ $filter->name }}"
class="form-control input-sm select2"
placeholder="{{ $filter->placeholder }}"
data-filter-key="{{ $filter->key }}"
data-filter-type="select2_ajax"
data-filter-name="{{ $filter->name }}"
data-select-key="{{ $filter->options['select_key'] ?? 'id' }}"
data-select-attribute="{{ $filter->options['select_attribute'] ?? 'name' }}"
filter-minimum-input-length="{{ $filter->options['minimum_input_length'] ?? 2 }}"
filter-method="{{ $filter->options['method'] ?? 'GET' }}"
filter-quiet-time="{{ $filter->options['quiet_time'] }}"
>
@if (Request::get($filter->name))
<option value="{{ Request::get($filter->name) }}" selected="selected"> {{ Request::get($filter->name.'_text') ?? 'Previous selection' }} </option>
@endif
</select>
</div>
</div>
</li>
{{-- ########################################### --}}
{{-- Extra CSS and JS for this particular filter --}}
{{-- FILTERS EXTRA CSS --}}
{{-- push things in the after_styles section --}}
@push('crud_list_styles')
<!-- include select2 css-->
<link href="{{ asset('packages/select2/dist/css/select2.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
<style>
.form-inline .select2-container {
display: inline-block;
}
.select2-drop-active {
border:none;
}
.select2-container .select2-choices .select2-search-field input, .select2-container .select2-choice, .select2-container .select2-choices {
border: none;
}
.select2-container-active .select2-choice {
border: none;
box-shadow: none;
}
.select2-container--bootstrap .select2-dropdown {
margin-top: -2px;
margin-left: -1px;
}
.select2-container--bootstrap {
position: relative!important;
top: 0px!important;
}
</style>
@endpush
{{-- FILTERS EXTRA JS --}}
{{-- push things in the after_scripts section --}}
@push('crud_list_scripts')
<!-- include select2 js-->
<script src="{{ asset('packages/select2/dist/js/select2.full.min.js') }}"></script>
@if (app()->getLocale() !== 'en')
<script src="{{ asset('packages/select2/dist/js/i18n/' . app()->getLocale() . '.js') }}"></script>
@endif
<script>
jQuery(document).ready(function($) {
// trigger select2 for each untriggered select2 box
//TODO: Is it really necessary to foreach an ID when it must be UNIQUE ?
$('#filter_{{ $filter->key }}').each(function () {
// if the filter has already been initialised, do nothing
if ($(this).attr('data-initialised')) {
return;
} else {
$(this).attr('data-initialised', 'true');
}
var filterName = $(this).attr('data-filter-name');
var filterKey = $(this).attr('data-filter-key');
var selectAttribute = $(this).attr('data-select-attribute');
var selectKey = $(this).attr('data-select-key');
$(this).select2({
theme: "bootstrap",
minimumInputLength: $(this).attr('filter-minimum-input-length'),
allowClear: true,
placeholder: $(this).attr('placeholder'),
closeOnSelect: false,
dropdownParent: $(this).parent('.form-group'),
// tags: [],
ajax: {
url: '{{ $filter->values }}',
dataType: 'json',
type: $(this).attr('filter-method'),
delay: $(this).attr('filter-quiet-time'),
processResults: function (data) {
//it's a paginated result
if(Array.isArray(data.data)) {
if(data.data.length > 0) {
return {
results: $.map(data.data, function (item) {
return {
text: item[selectAttribute],
id: item[selectKey]
}
})
};
}
}else{
//it's non-paginated result
return {
results: $.map(data, function (item, i) {
return {
text: item,
id: i
}
})
};
}
}
}
}).on('change', function (evt) {
var val = $(this).val();
var val_text = $(this).select2('data')[0]?$(this).select2('data')[0].text:null;
var parameter = filterName;
// behaviour for ajax table
var ajax_table = $('#crudTable').DataTable();
var current_url = ajax_table.ajax.url();
var new_url = addOrUpdateUriParameter(current_url, parameter, val);
new_url = addOrUpdateUriParameter(new_url, parameter + '_text', val_text);
new_url = normalizeAmpersand(new_url.toString());
// replace the datatables ajax url with new_url and reload it
ajax_table.ajax.url(new_url).load();
// add filter to URL
crud.updateUrl(new_url);
// mark this filter as active in the navbar-filters
if (URI(new_url).hasQuery(filterName, true)) {
$('li[filter-key='+filterKey+']').addClass('active');
}
else
{
$("li[filter-key="+filterKey+"]").removeClass("active");
$("li[filter-key="+filterKey+"]").find('.dropdown-menu').removeClass("show");
}
});
// when the dropdown is opened, autofocus on the select2
$('li[filter-key='+filterKey+']').on('shown.bs.dropdown', function () {
$('#filter_'+filterKey).select2('open');
});
// clear filter event (used here and by the Remove all filters button)
$('li[filter-key='+filterKey+']').on('filter:clear', function(e) {
$('li[filter-key='+filterKey+']').removeClass('active');
$('#filter_'+filterKey).val(null).trigger('change');
});
});
});
</script>
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,137 @@
{{-- Select2 Multiple Backpack CRUD filter --}}
<li filter-name="{{ $filter->name }}"
filter-type="{{ $filter->type }}"
filter-key="{{ $filter->key }}"
class="nav-item dropdown {{ Request::get($filter->name)?'active':'' }}">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ $filter->label }} <span class="caret"></span></a>
<div class="dropdown-menu p-0">
<div class="form-group backpack-filter mb-0">
<select id="filter_{{ $filter->key }}" name="filter_{{ $filter->key }}" data-filter-key="{{ $filter->key }}" data-filter-name="{{ $filter->name }}" class="form-control input-sm select2" data-filter-type="select2_multiple" placeholder="{{ $filter->placeholder }}" multiple>
@if (is_array($filter->values) && count($filter->values))
@foreach($filter->values as $key => $value)
<option value="{{ $key }}"
@if($filter->isActive() && json_decode($filter->currentValue) && array_search($key, json_decode($filter->currentValue)) !== false)
selected
@endif
>
{{ $value }}
</option>
@endforeach
@endif
</select>
</div>
</div>
</li>
{{-- ########################################### --}}
{{-- Extra CSS and JS for this particular filter --}}
{{-- FILTERS EXTRA CSS --}}
{{-- push things in the after_styles section --}}
@push('crud_list_styles')
<!-- include select2 css-->
<link href="{{ asset('packages/select2/dist/css/select2.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
<style>
.form-inline .select2-container {
display: inline-block;
}
.select2-drop-active {
border:none;
}
.select2-container .select2-choices .select2-search-field input, .select2-container .select2-choice, .select2-container .select2-choices {
border: none;
}
.select2-container-active .select2-choice {
border: none;
box-shadow: none;
}
.select2-container--bootstrap .select2-dropdown {
margin-top: -2px;
margin-left: -1px;
}
.select2-container--bootstrap {
position: relative!important;
top: 0px!important;
}
</style>
@endpush
{{-- FILTERS EXTRA JS --}}
{{-- push things in the after_scripts section --}}
@push('crud_list_scripts')
<!-- include select2 js-->
<script src="{{ asset('packages/select2/dist/js/select2.full.min.js') }}"></script>
@if (app()->getLocale() !== 'en')
<script src="{{ asset('packages/select2/dist/js/i18n/' . app()->getLocale() . '.js') }}"></script>
@endif
<script>
jQuery(document).ready(function($) {
// trigger select2 for each untriggered select2 box
$('select[name=filter_{{ $filter->key }}]').not('[data-filter-enabled]').each(function () {
var filterName = $(this).attr('data-filter-name');
var filter_key = $(this).attr('data-filter-key');
$(this).select2({
allowClear: true,
closeOnSelect: false,
theme: "bootstrap",
dropdownParent: $(this).parent('.form-group'),
placeholder: $(this).attr('placeholder'),
});
$(this).change(function() {
var value = '';
if (Array.isArray($(this).val())) {
// clean array from undefined, null, "".
var values = $(this).val().filter(function(e){ return e === 0 || e });
// stringify only if values is not empty. otherwise it will be '[]'.
value = values.length ? JSON.stringify(values) : '';
}
var parameter = '{{ $filter->name }}';
// behaviour for ajax table
var ajax_table = $("#crudTable").DataTable();
var current_url = ajax_table.ajax.url();
var new_url = addOrUpdateUriParameter(current_url, parameter, value);
// replace the datatables ajax url with new_url and reload it
new_url = normalizeAmpersand(new_url.toString());
ajax_table.ajax.url(new_url).load();
// add filter to URL
crud.updateUrl(new_url);
// mark this filter as active in the navbar-filters
if (URI(new_url).hasQuery(filterName, true)) {
$("li[filter-key="+filter_key+"]").addClass('active');
}
else
{
$("li[filter-key="+filter_key+"]").removeClass("active");
$("li[filter-key="+filter_key+"]").find('.dropdown-menu').removeClass("show");
}
});
// when the dropdown is opened, autofocus on the select2
$("li[filter-key="+filter_key+"]").on('shown.bs.dropdown', function () {
$('#filter_'+filter_key+'').select2('open');
});
// clear filter event (used here and by the Remove all filters button)
$("li[filter-key="+filter_key+"]").on('filter:clear', function(e) {
// console.log('select2 filter cleared');
$("li[filter-key="+filter_key+"]").removeClass('active');
$('#filter_'+filter_key).val(null).trigger('change.select2');
});
});
});
</script>
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,72 @@
{{-- Simple Backpack CRUD filter --}}
<li filter-name="{{ $filter->name }}"
filter-type="{{ $filter->type }}"
filter-key="{{ $filter->key }}"
class="nav-item {{ Request::get($filter->name)?'active':'' }}">
<a class="nav-link" href=""
parameter="{{ $filter->name }}"
>{{ $filter->label }}</a>
</li>
{{-- ########################################### --}}
{{-- Extra CSS and JS for this particular filter --}}
{{-- FILTERS EXTRA CSS --}}
{{-- push things in the after_styles section --}}
{{-- @push('crud_list_styles')
<!-- no css -->
@endpush --}}
{{-- FILTERS EXTRA JS --}}
{{-- push things in the after_scripts section --}}
@push('crud_list_scripts')
<script>
jQuery(document).ready(function($) {
$("li[filter-key={{ $filter->key }}] a").click(function(e) {
e.preventDefault();
var parameter = $(this).attr('parameter');
// behaviour for ajax table
var ajax_table = $("#crudTable").DataTable();
var current_url = ajax_table.ajax.url();
if (URI(current_url).hasQuery(parameter)) {
var new_url = URI(current_url).removeQuery(parameter, true);
} else {
var new_url = URI(current_url).addQuery(parameter, true);
}
new_url = normalizeAmpersand(new_url.toString());
// replace the datatables ajax url with new_url and reload it
ajax_table.ajax.url(new_url).load();
// add filter to URL
crud.updateUrl(new_url);
// mark this filter as active in the navbar-filters
if (URI(new_url).hasQuery('{{ $filter->name }}', true)) {
$("li[filter-key={{ $filter->key }}]").removeClass('active').addClass('active');
$('#remove_filters_button').removeClass('invisible');
}
else
{
$("li[filter-key={{ $filter->key }}]").trigger("filter:clear");
}
});
// clear filter event (used here and by the Remove all filters button)
$("li[filter-key={{ $filter->key }}]").on('filter:clear', function(e) {
// console.log('dropdown filter cleared');
$("li[filter-key={{ $filter->key }}]").removeClass('active');
});
});
</script>
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1,79 @@
{{-- Text Backpack CRUD filter --}}
<li filter-name="{{ $filter->name }}"
filter-type="{{ $filter->type }}"
filter-key="{{ $filter->key }}"
class="nav-item dropdown {{ Request::get($filter->name) ? 'active' : '' }}">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ $filter->label }} <span class="caret"></span></a>
<div class="dropdown-menu p-0">
<div class="form-group backpack-filter mb-0">
<div class="input-group">
<input class="form-control pull-right"
id="text-filter-{{ $filter->key }}"
type="text"
@if ($filter->currentValue)
value="{{ $filter->currentValue }}"
@endif
>
<div class="input-group-append text-filter-{{ $filter->key }}-clear-button">
<a class="input-group-text" href=""><i class="la la-times"></i></a>
</div>
</div>
</div>
</div>
</li>
{{-- ########################################### --}}
{{-- Extra CSS and JS for this particular filter --}}
{{-- FILTERS EXTRA JS --}}
{{-- push things in the after_scripts section --}}
@push('crud_list_scripts')
<!-- include select2 js-->
<script>
jQuery(document).ready(function($) {
$('#text-filter-{{ $filter->key }}').on('change', function(e) {
var parameter = '{{ $filter->name }}';
var value = $(this).val();
// behaviour for ajax table
var ajax_table = $('#crudTable').DataTable();
var current_url = ajax_table.ajax.url();
var new_url = addOrUpdateUriParameter(current_url, parameter, value);
// replace the datatables ajax url with new_url and reload it
new_url = normalizeAmpersand(new_url.toString());
ajax_table.ajax.url(new_url).load();
// add filter to URL
crud.updateUrl(new_url);
// mark this filter as active in the navbar-filters
if (URI(new_url).hasQuery('{{ $filter->name }}', true)) {
$('li[filter-key={{ $filter->key }}]').removeClass('active').addClass('active');
} else {
$('li[filter-key={{ $filter->key }}]').trigger('filter:clear');
}
});
$('li[filter-key={{ $filter->key }}]').on('filter:clear', function(e) {
$('li[filter-key={{ $filter->key }}]').removeClass('active');
$('#text-filter-{{ $filter->key }}').val('');
});
// datepicker clear button
$(".text-filter-{{ $filter->key }}-clear-button").click(function(e) {
e.preventDefault();
$('li[filter-key={{ $filter->key }}]').trigger('filter:clear');
$('#text-filter-{{ $filter->key }}').val('');
$('#text-filter-{{ $filter->key }}').trigger('change');
})
});
</script>
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}

View File

@ -0,0 +1 @@
@include($filter->options['view'])

View File

@ -17,4 +17,8 @@
'namespace' => 'App\Http\Controllers\Admin',
], function () { // custom admin routes
Route::crud('client', 'ClientCrudController');
Route::crud('company', 'CompanyCrudController');
Route::crud('country', 'CountryCrudController');
Route::crud('business', 'BusinessCrudController');
Route::crud('account', 'AccountCrudController');
}); // this should be the absolute last line of this file