sebastienheyd / boilerplate Goto Github PK
View Code? Open in Web Editor NEWLaravel AdminLTE 3 Boilerplate package with blade components, users, roles and permissions management
License: MIT License
Laravel AdminLTE 3 Boilerplate package with blade components, users, roles and permissions management
License: MIT License
Hi Again Sebastien
I manually integrate Justify plugin to CKEditor https://ckeditor.com/cke4/addon/justify. Would be great if can be added in base installation. I only added folder plugin and define as an extra parameter on CKEDITOR.replace() instance
CKEDITOR.replace( 'description',
{
extraPlugins : 'justify'
});
, but I think after update boilerplate and publish public tag maybe plugin folder is deleted. I'm right? Or its safe to do this way?
I try to add to my fork, but I'm new to webpack/mixin/assets procedure.. and I have to learn how to integrate well to make your pull requests easely !! :)
I'm trying to set a conditional validation which must check this:
So in my blade view:
@if ($riskfield->type == 'min_max')
<x-boilerplate::input type="number" name="values[min]" label="medicalrecords.min" required
placeholder="medicalrecords.min_plc" autofocus="true" min="0" prepend-text="fas fa-signature">
</x-boilerplate::input>
<x-boilerplate::input type="number" name="values[max]" label="medicalrecords.max"
placeholder="medicalrecords.max_plc" autofocus="true" min="0" prepend-text="fas fa-signature">
</x-boilerplate::input>
@elseif($riskfield->type == 'number')
<x-boilerplate::input type="number" name="values[number]" label="medicalrecords.number" required
placeholder="medicalrecords.number_plc" autofocus="true" min="0"
prepend-text="fas fa-signature">
</x-boilerplate::input>
@endif
and also at the top of my form I have an hidden field:
<input type="hidden" name="riskfield_type" value="{{ $riskfield->type }}">
Then in the store method there is this validation config:
$this->validate($request, [
'riskfield_id' => 'required',
'riskarea_id' => 'required',
'values[min]' => 'required_if:riskfield_type,==,min_max',
'values[max]' => 'required_if:riskfield_type,==,min_max',
'values[number]' => 'required_if:riskfield_type,==,number'
]);
Now the problem's that if I fill both values[min] and values[max] I get:
The values [min] field is required when the riskfield type is min_max.
So I changed the validation as:
'values.min' => 'required_if:riskfield_type,==,min_max',
'values.max' => 'required_if:riskfield_type,==,min_max',
and this fix the problem but the error message doesn't appear because it contains:
{"values.max":["The values.max \u00e8 is required when the riskfield type \u00e8 min_max."]}
and within input.blade.php
we have:
$errors->first($name,' is-invalid')
So I suspect that this condition fails
Hello,
I created a menu that I wanted to make accessible only to the admin role.
Here is the code:
<?php
namespace App\Menu;
use Sebastienheyd\Boilerplate\Menu\Builder;
class Configuration
{
public function make(Builder $menu)
{
$menu->add('Configuration', [ 'role' => 'admin', 'icon' => 'cogs' ])
->id('configuration')
->order(10);
$menu->addTo('configuration', 'Langues', [ 'route' => 'mayers.languages.index', 'role' => 'admin' ])
->activeIfRoute(['mayers.languages.*']);
}
}
But by logging in with a user whose role is backend_user this menu is visible.
I think the problem comes from Menu/Builder.php, in the add function.
The condition, line 50 if($currentUser->ability (['admin'], [])) {
always returns true, , because of the empty array for permissions.
Here is a correction that works for me:
...
if (isset($options['role']) || isset($options['permission'])) {
$ability = ['admin'];
if (isset($options['role'])) {
$ability = $ability + explode(',', $options['role']);
}
$permission = null; //Set permissions to null rather than an empty array.
if (isset($options['permission'])) {
$permission = explode(',', $options['permission']);
}
$currentUser = Auth::user();
if ($currentUser->ability($ability, $permission)) {
$this->items->push($item);
}
} else {
$this->items->push($item);
}
...
Another solution is to put the option 'permission' of the menu on a value that does not exist,
$menu->add('Configuration', [ 'permission' => 'fake_admin', 'icon' => 'cogs' ])
->id('configuration')
->order(10);
but it is not very clean.
By the way, thank you for this great boilerplate.
I'm using an API service that returns only 50 records per request, so I need to use the Datatable pagination and set the total records.
I searched for setTotalRecords within your boilerplate but there is no implementation.
I found this on the official repo of yajra datatable: yajra/laravel-datatables#2083
Do you thinks is possible add this behavior? It would be very useful
Thanks
Hi,
The doc says:
php artisan vendor:publish --provider="Sebastienheyd\Boilerplate\BoilerplateServiceProvider"
But I don't see boilerplate views in ressources. Is there a way to publish views ?
Thank you
how can i fully extend language files to have full control?
I have defined these roles:
Then, I have created a menu called Patients
:
class Patients
{
public function make(Builder $menu)
{
$item = $menu->add('patients.title', [
'icon' => 'fa-user-injured',
'role' => 'tenant',
'order' => 103
]);
$item->add('patients.list.title', [
'route' => 'socialthess.patients.index',
'active' => 'socialthess.patients.index',
]);
}
}
as you can see I have specified the role tenant
, but if I access as an user which have the role patient
I can see the menu.
Also, I would like to ask another question: when I signin as patient user and try to access to the datatable I get:
Symfony\Component\HttpKernel\Exception\HttpException
This is the content of the setUp function:
public function setUp()
{
$this->permissions(['invites_crud'])
->order('id', 'desc');
}
The user have that permission, but for some reason the data aren't returned, this happen just for invites_crud
user, the admin doesn't have any issues ..
what I did wrong?
Hey @sebastienheyd! Thank you for your work. Is really awesome.
Would be possible to add the dark mode button on the top navbar as in adminlte 3.1?
The css is already compiled for it. Just append class dark-mode to body and the magic is done.
thank you!
Would be possible to add https://github.com/yairEO/tagify
and this: https://adminlte.io/themes/v3/pages/charts/chartjs.html
Is there a way to disable logs?
it is possible to add support for laravel Datatables and Laravel package for translatable models ???
How to best way, for add some new plugin assets?
Hi @sebastienheyd,
Thanks for this great package, I want to customize the views, i run this command :
php artisan vendor:publish --tag=boilerplate-views
to override. and views are on resources/views/vendor/boilerplate
when i edit the views on this folder, changes are not show even i clear cache and view. any idea how to fix that ?
Thanks in advance.
Best,
If I use the verified
middleware:
public function __construct()
{
$this->middleware(['auth', 'verified']);
}
I get:
Route [verification.notice] not defined.
The problem seems to be related to the boilerplate route file, in particular to this line:
'as' => 'boilerplate.',
So if I remove boilerplate.
the error goes away but then I get:
Route [boilerplate.verification.send] not defined.
Could you please look into this?
Thanks in advance
Hey @sebastienheyd! Thank you for your work. Is really save my time.
I want use another icon or just an image on the menu, can you make it?
for now, i use prepend method from laravel-menu and make little changes to disable the default icon.
Does this package support Laratrust's team feature?
If so, is there documentation on how to set it up?
I'm trying to use the :ajax
feature, but for some reason I'm not able to make it working. This is my datatable:
<x-boilerplate::datatable name="medicalrecordsriskfield" :ajax="['riskarea_id' => $riskarea->id]" />
within the Datatable datasource
method I have:
dd(request()->post('riskarea_id'));
and it returns null
.
UPDATE
The error is related to this line:
window.{{ $id }}_ajax = {!! json_encode($ajax) !!}
which actually does nothing since the ajax data must be passed in the ajax block:
ajax: {
url: '{!! route('boilerplate.datatables', $datatable->slug, false) !!}',
type: 'post',
data: $.fn.dataTable.parseDatatableFilters,
complete: () => {
$('#{{ $id }} [name=dt-check-all]').prop('checked', false)
}
},
In particular within the data block, but I'm not sure the purpose of this $.fn.dataTable.parseDatatableFilters
, so I will wait for a fix
is it maybe possible to have an normal php branch without lavarel
Hi,
I have created a migration like this:
Schema::create('riskareas_fields', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->enum('type', ['number', 'min_max', 'text']);
$table->string('icon')->nullable();
$table->timestamps();
$table->softDeletes();
});
then I've defined the model
class RiskareasField extends Model
{
protected $table = "riskareas_fields";
protected $fillable = [
'name',
'type',
'icon'
];
}
I tried to create a datatable using the boilerplate command: php artisan boilerplate:datatable riskareasfields --model="App\Models\RiskareasField
but I get:
Unknown database type enum requested, Doctrine\DBAL\Platforms\MariaDb1027Platform may not support it.
I'm using Laravel 8 and php 8.0.2
Hi, I'm using the latest method added to the boilerplate: setTotalRecords
and setOffset
in this way:
public function datasource()
{
$search = request()->post('search');
$start = request()->post('start');
$length = request()->post('length');
$response = $this->packages::searchByDrugName([
'page' => $start / $length,
'name' => $search['value']
]);
$this->setOffset($response['to']);
$this->setTotalRecords($response['total']);
return $response['data'];
}
I'm calling an external API service through an SDK, and when the DataTable loads I can see all the rows correctly, this is the $response
value (check on pastebin).
When I type something in the search bar, eg "idro", I get this $response
value(check on pastebin).
The problem's that after the second call, so when I valorized the search bar with "idro", I doesn't get any rows displayed even if the response has returned data. This is the response returned:
I initially though that was a problem of the API, but I tried to add this before searchByDrugName
: $search['value'] = 'idro';
. So I have simulated the search type of "idro" without typing anything in the search box, and the Datatable has returned the expected rows.
I guess there is a conflict somewhere that prevent the DataTable to return the data array when the search box is filled, specifically when the method setOffset
and setTotalRecords
are used.
Could you kindly look into this?
Thanks
Hello, I'm fairly new to Laravel and your CRM example is really nice for my playground, but I can't seem to understand the Menu part. Those "User" and "Logs" files don't generate after project setup, as the whole Menu folder. I can see the config tho. The authors way with middleware dose work. But I'm not clear about your way - I can't seem to find any place where I could edit the whole Menu ir create a new one.
Plus: Permission CRUD setup would be great if it was out of the box :)
EDIT If you edit the menus in the Vendor it dose work, for now I could stick to that.
Hi,
If you browse the route: /admin/users
, you will get this error:
which is caused by that line: @if(in_array('filters', $datatable->buttons))
, in particular UsersDatatable
doesn't have any buttons, so this will throw an exception, I temporary fixed this using:
$this->permissions('users_crud')
->locale([
'deleteConfirm' => __('boilerplate::users.list.confirmdelete'),
'deleteSuccess' => __('boilerplate::users.list.deletesuccess'),
])
->buttons([]) // MUST BE SPECIFIED
->order('created_at', 'desc')
->stateSave();
Also, I guess that this line:
$userModel = config('boilerplate.laratrust.user.providers.users.model');
should be:
$userModel = config('boilerplate.laratrust.user');
otherwise this will throw a type exception on ajax load
Hi,
I saw there is the TinyMCE component which is great, but sometimes we just need to add notes to a particular field and we don't need markup feature. Could you please add the Textarea component too so we don't have to craft it manually?
Thanks
Facade\Ignition\Exceptions\ViewException
Undefined variable: title (View: C:\wamp64\www\la-perpustakaan\vendor\sebastienheyd\boilerplate\src\resources\views\auth\loginbox.blade.php)
Hi Sebastien,
After deploy new installation of boilerplate on fresh laravel 5.8 installation, I got error when making migration process
php artisan make:migration
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table 'sonica_db.#sql-edb_78b07' (errno: 150) (SQL: alter table
role_useradd constraint
role_user_user_id_foreign foreign key (
user_id) references
users (
id) on delete cascade on update cascade)
After check your source files, found an UnsignedBigInteger on user_id field definition and Mysql can't create foreign index because doesn't match column ID on user tables.
Line 57 of 2017_03_24_093351_laratrust_setup_tables.php
$table->unsignedBigInteger('user_id');
After change to
$table->unsignedInteger('user_id');
all is working great again.
Hope this helps u
All the best
I have error like this when add lang
https://flareapp.io/share/17WgKG87#F79
When i check because this line
$title = sprintf('
%s
', /** @scrutinizer ignore-type */ __($title));haii admin ,you can give me sample crud with boilerplate?
Please add permission management like create, update, delete. Thanks!
I used the scaffhold command to customize the UserModel and other view, now when I create a new user I get:
MyApp\Boilerplate\Events\UserCreated::__construct(): Argument #1 ($user) must be of type MyApp\Boilerplate\Models\User, App\Models\Boilerplate\User given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php on line 206
Of course I changed the user type within the config auth providers, but this doesn't fix the issue 'cause in the UserCreated event we have this line:
public function __construct(User $user)
which refers to:
use Sebastienheyd\Boilerplate\Models\User;
So I guess the events must be copied in the App\src folder too and the models scaffholded must replace the namespace, agree with me?
Could not open input file: artisan
"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'name' in 'field list' (SQL: insert into users
(name
, email
, password
, updated_at
, created_at
▶"
Could you suggest me a way to change languages? I'm following this tutorial: https://5balloons.info/localization-laravel-multi-language-language-switcher/, but the effect is that it keeps the default locale. If I change the locale in the config file, everything is fine, but if I make it on the fly, the locale is the default.
I was testing the $dt->showCheckboxes()
which is working well, but imho we should add the data id of the row, in this way we can store the correct record reference, code is better than any words:
public function getColumns()
{
$columns = $this->columns();
if ($this->checkboxes) {
$cbid = uniqid('checkbox_');
array_unshift($columns, Column::add(
'<div class="icheck-primary mb-0 mt-0">
<input type="checkbox" name="dt-check-all" id="' . $cbid . '" autocomplete="off">
<label for="' . $cbid . '"></label>
</div>'
)
->notSearchable()
->notOrderable()
->data('checkbox', function ($data) {
$id = uniqid('checkbox_');
$name = isset($data['id'])
? 'dt-checkbox[' . $data['id'] . ']'
: 'dt-checkbox[]';
return '<div class="icheck-primary mb-0">
<input type="checkbox" name="' . $name . '" id="' . $id . '" autocomplete="off">
<label for="' . $id . '"></label>
</div>';
}));
}
return $columns;
}
As you can see I check if $data
have the id, then I assign for each checkbox the id of the record.
When sent a post request, I will get:
Which represent the id of the rows selected, this id is associated can be associated to a pk of a table.
What do you think about it?
Nice job, exactly i neeed, but i dont understand how to create new module out of vendor/sebastian....
Module "Product" with CRUD (in app/controllers/products, app/productModel and resource/views/productsViews) and create permission for this module in roles:
mysite.com/roles/create:
PRODUCT
|___| Create
|___| Read
|___| Update
|___| Delete
|___| Browser (if not checked, hide menu product and block access page)
Is there a way to extract models, controllers and routes in vendor folder as views? I need to make some changes. Do you have fresh installation where this package is integrated?
Hi Sebastien, how its going !!
Only as a suggestion, for future releases.
Currently I'm working on a little project and I choose to have boilerplate separated from web URL and have his own subdomain. Laravel support subdomain routing, so I add a line to app/config.php
'domain' => 'http://sudomain.domain.tld' // Use your own http(s)://subdomain
'prefix' => '', // Set no null for root url
And in Boilerplate route file add this to $default array
'domain' => config('boilerplate.app.domain','')
Only rest to configure Apache or Nginx adding subdomain.domain.tld as an alias of vhost to have bolierplate separated from web url's. Tested and working out of the box.
Maybe someone find this useful and u can add in next updates.
Regards
Line 10 in d685c4a
public function make($name, $callback, array $options = [])
See commit from v1.8.2:
lavary/laravel-menu@4ae8ae8#diff-df3b8bf41c6dfbe13be15b951c5210b65c69a87ea649343e8ccbf37170b8d5abR70
When I ran php artisan migrate, it resulted in the following error
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users
add unique users_email_unique
(email
))
Hi,
First of all, thanks for your boilerplate
it's an incredible help for all devs.
I would like to know if I did something wrong, or I discovered some issues. Essentially:
boilerplate
and when I login I have this info message:The information you are about to send is not secure
As this form was submitted via an insecure connection, the information will be visible to others.
within src/.env
I have this configuration: APP_URL=https://example.com
(hide the url for privacy reason), and the ssl is correctly registered. This also happen when I logout.
This happen only for public/images/avatars
, the problem isn't showing for public/assets
, check also:
Is there something I can do to fix this?
Thanks in advance
Hi, I'm facing a weird situation, essentially I have this Datatable Column:
Column::add(__('invites.status.title'))
->width('100px')
->data('status', function (Invite $invite) {
$badge = '<span class="badge badge-pill badge-%s">%s</span';
if ($invite->status == 'accepted') {
return sprintf($badge, 'success', __('invites.status.accepted'));
} else if ($invite->status == 'not_accepted') {
return sprintf($badge, 'danger', __('invites.status.not_accepted'));
}
return sprintf($badge, 'warning', __('invites.status.waiting'));
})
->filterOptions([
__('invites.status.accepted'),
__('invites.status.waiting'),
__('invites.status.not_accepted'),
]),
the invites
locale array contains this:
'status' => [
'title' => 'Stato',
'not_accepted' => 'Non accettato',
'accepted' => 'Accettato',
'waiting' => 'In attesa',
],
If I select: 'accepted', the rows are filtered correctly, if I select 'waiting' or 'not_accepted' which contains space inside the string, no records is returned.
i have tried using this from datatables.net
$('#myTable').DataTable( {
responsive: true
} );
but it is not working and just does not work.
adminlte 3 has given a explanation here
https://adminlte.io/docs/3.1//javascript/expandable-tables.html
but i don't understand how can i make it responsive in boilerplate .
Hi again Sebastien !!
Only for your information:
Trying to understand what's happening with my routes under Laravel I run a fresh installation of laravel 5.8.3 and boilerplate package as local project under Vagrant, published assets and run migration. Not installed anything else.
After register a new user, and logged in I go to user section and laravel throw this exception message. Only for your information.
Entering on userprofile get this exception error
As a read, isoFormat method is only available on Carbon 2, and is supposed to be installed as default carbon versión with Laravel 5.8.
This is my composer.json
I'm sure this is not related to boilerplate, seems more a laravel/carbon integration error, but affects to boilerplate after you switch on use isoFormat method to format dates as you explain in readme.
If I get some light about this.. drop u a note here.
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: PUT, PATCH, DELETE.
http://localhost:8000/admin/users/3
please change in lists.blade.php
$('#users-table').on('click', '.destroy', function (e) {
e.preventDefault();
to
$('#users-list').on('click', '.destroy', function (e) {
e.preventDefault();
Hi Sebastien,
After update 5.4 branch to 5.8, I'm unable to expand routes to add functionality to boilerplate. Maybe u can help me with this strange behaivour
I Added boilerplate.php to root route folder and add some route example closure
Route::get('testroute', function (){ return 'I'm a test route'; })->name('routetest');
At this point laravel don't load boilerplate.php file so added file to route provider App/Providers/RouteServiceProvider.php
public function map() { $this->mapApiRoutes(); $this->mapWebRoutes(); $this->mapAdminRoutes(); }
protected function mapAdminRoutes() { Route::middleware('web') ->namespace('\App\Http\Controllers\Admin') ->group(base_path('routes/admin.php')); }
if I check routes in console with php artisan route:list, new route appears on list as a closure.. all seems to work fine but if a try the url in browser
always returns a 404 error page. Only happens with new routes added outside boilerplate scope, if I try to get p.e users page
http://domain.tld/users works as expected and returns users dashboard page.
How do you expand routes in your package?? In old version was so easy, but after update I'm getting crazy about this
thanks in advance
how i can add new fillable column to users model with boilerplate?
i have create migrate, after i have override view but i need to seet fillable.
This issue happen when we use the scaffhold
command, so we have a copy of UsersDatatable and RolesDatatable within our Datatables
directory.
The BoilerplateServiceProvider
actually register these two Datatables using this line:
app('boilerplate.datatables')->registerDatatable(UsersDatatable::class, RolesDatatable::class);
So if I call the datatable component I get the error above. I think is not necessary instantiate the UsersDatatable and RolesDatatable by default, or maybe I'm missing something in this logic.
Again, this happen only for the scaffhold.
I don't know if this is a bug, or I'm doing something incorrect.
So this is my code:
<x-boilerplate::icheck name="riskareas[view][{{ $riskarea->id }}]" {{ $riskarea->pivot->insert == 1 ? 'checked' : '' }} />
In my case the value insert
is equal to 1, so if inspect the source code I can see the checked attribute, but for some reason the checkbox doesn't appear.
No problem if I use this instead:
<input type="checkbox" {{ $riskarea->pivot->insert == 1 ? 'checked' : '' }} />
Hi, thanks for this amazing boilerplate.
Would be possible add an email verification system for the registration?
Thanks
Hi,
i would know if the package will be updated to include support to the new version of laravel, 7.x.
Thanks in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.