sohelamin / laravel-admin Goto Github PK
View Code? Open in Web Editor NEWLaravel Admin Panel
Home Page: https://packagist.org/packages/appzcoder/laravel-admin
License: MIT License
Laravel Admin Panel
Home Page: https://packagist.org/packages/appzcoder/laravel-admin
License: MIT License
I'd like to have inside the migration, on each field that's not required, a ->nullable(). This way the user can skip the field and MySQL won't fail because there's no default value when submiting a form.
How i can delete my Modules after create?
Thank you for the wonderful package. I would like to contribute a tip to optimize the loading of User permissions on AuthServiceProvider.
public function boot(GateContract $gate)
{
// Checks table permissions exists
if(!App::environment('local') && Schema::hasTable('permissions')){
throw new \Exception("Table permissions not exists, please run migration!");
}
parent::registerPolicies($gate);
......
I installed laravel-admin in Laravel 5.5
I confirmed that I can "view", "edit", "delete" actions and show list.
but, "create" is not working.
When I click the "Add New" button, I see a message like this
"Sorry, the page you are looking for could not be found."
404 not found error ?
Hi;
I've installed your package, but I have these problems with the crud generator:
<input type="hidden" name="_token" value="{{ csrf_token() }}">
Thanks a lot for this useful package.
hello, i have problem after save form, because your plugin don't add routes for save.
after install i have routes
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index');
Route::get('admin', 'Admin\AdminController@index');
Route::get('admin/give-role-permissions', 'Admin\AdminController@getGiveRolePermissions');
Route::post('admin/give-role-permissions', 'Admin\AdminController@postGiveRolePermissions');
Route::resource('admin/roles', 'Admin\RolesController');
Route::resource('admin/permissions', 'Admin\PermissionsController');
Route::resource('admin/users', 'Admin\UsersController');
Auth::routes();
Route::get('/home', 'HomeController@index');
Hi,
/js/app.js & /css/app.css not found after installation.
When is leave
Controller Namespace:blank
Route Group Prefix:blank
View Path:blank
its show Undefined index: --route-group
controller models, views migration file created (route get updated)
but migration not runs and menu.json file not created.
Are there any plans to create relations with the Laravel-Admin? It is already possible with the crud-generator
Hi,
First, many thanks for your effort.
My problem is that:
How to use crud generator with foreign key relations?
Example: I have countries
table with id, name
fields and cities
table with id, name, country_id
fields. Now when I want to add a new city, what are the fields shall I put in my php artisan crud:view
command? and how to display a dropdown menu containing all the countries in the database?
Thanks in advance :)
Problem when add user.
exception 'BadMethodCallException' with message 'Call to undefined method Illuminate\Database\Query\Builder::assignRole()'
in /var/www/html/uno/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2451
The tables associated with the roles/permissions are deleted in the wrong order. When running php artisan migrate:refresh exceptions get thrown:
[Illuminate\Database\QueryException]
SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails (SQL: drop table `roles`)
[PDOException]
SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails
in the migration file create_roles_permissions_tables.php the order needs to be switched from:
Schema::drop('roles');
Schema::drop('permissions');
Schema::drop('permission_role');
Schema::drop('role_user');
to
Schema::drop('permission_role');
Schema::drop('role_user');
Schema::drop('roles');
Schema::drop('permissions');
Hi,
There is an error when using CRUD Generator - On Post event I believe that it is trying to search for FORM-FIELD.blade.stab file whereas there is no folder "form-fields".
File does not exist at path /var/www/html/app/test/resources/crud-generator/form-fields/form-field.blade.stub
Appreciate if you can help with these.
Thanks,
Vik
do not see the selected roles when I edit the user.
View resources\views\admin\users\form.blade.php line 27
I changed it for " <option value="{{ $role->name }}" {{ isset($user_roles)?(in_array($role->name, $user_roles) ? 'selected="selected"' : ''):'' }}>{{ $role->label }} "
Hello, i'm learning laravel since a few days and i didn't manage to make the route works
how to check if the user avec admin role to see the admin panel?
After successfully upgraded to Laravel 5.4 and latest (dev-master) of the laravel-admin, everything is working fine.
Except one small thing.
Not working:
Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth', 'roles'], 'roles' => 'admin'], function() {
Route::get('', 'AdminController@index');
Route::get('/give-role-permissions', 'AdminController@getGiveRolePermissions');
Route::post('/give-role-permissions', 'AdminController@postGiveRolePermissions');
Route::resource('/roles', 'RolesController');
Route::resource('/permissions', 'PermissionsController');
Route::resource('/users', 'UsersController');
Route::get('/generator', ['uses' => '\Appzcoder\LaravelAdmin\Controllers\ProcessController@getGenerator']);
Route::post('/generator', ['uses' => '\Appzcoder\LaravelAdmin\Controllers\ProcessController@postGenerator']);
});
Works
Route::get('admin', 'Admin\AdminController@index');
Route::get('admin/give-role-permissions', 'Admin\AdminController@getGiveRolePermissions');
Route::post('admin/give-role-permissions', 'Admin\AdminController@postGiveRolePermissions');
Route::resource('admin/roles', 'Admin\RolesController');
Route::resource('admin/permissions', 'Admin\PermissionsController');
Route::resource('admin/users', 'Admin\UsersController');
Route::get('admin/generator', ['uses' => '\Appzcoder\LaravelAdmin\Controllers\ProcessController@getGenerator']);
Route::post('admin/generator', ['uses' => '\Appzcoder\LaravelAdmin\Controllers\ProcessController@postGenerator']);
Thank in advance for helping!
how can i make admin login and register use another model not use User because i use it's table with different attribute ??!
thanks
Hi.
Thank you for the good work.
i tried extending the app for multitenancy and modifying the schema. I get error after changing the table name
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'tracker.role_user' doesn't exist (SQL: select `RG_roles`.*, `role_user`.`user_id` as `pivot_user_id`, `role_user`.`role_id` as `pivot_role_id` from `RG_roles` inner join `role_user` on `RG_roles`.`id` = `role_user`.`role_id` where `role_user`.`user_id` = 1)
everything is ok upto i hit $ php artisan laravel-admin:install
after creating database on phpmyadmin when i hit this command it says:
"Config your database first"
Your package will not install alongside laravel 5.4.x-dev.
I have a bug :D
RelationNotFoundException in RelationNotFoundException.php line 20: Call to undefined relationship [roles] on model [App\User].
in RelationNotFoundException.php line 20
at RelationNotFoundException::make(object(User), 'roles') in Builder.php line 530
at Builder->Illuminate\Database\Eloquent\{closure}()
at call_user_func(object(Closure)) in Relation.php line 86
at Relation::noConstraints(object(Closure)) in Builder.php line 532
at Builder->getRelation('roles') in Builder.php line 500
at Builder->eagerLoadRelation(array(object(User)), 'roles', object(Closure)) in Builder.php line 480
at Builder->eagerLoadRelations(array(object(User))) in Builder.php line 447
at Builder->get(array('*')) in BuildsQueries.php line 71
at Builder->first(array('*')) in Builder.php line 264
at Builder->find('1', array('*')) in Builder.php line 294
at Builder->findOrFail('1') in UsersController.php line 96
at UsersController->edit('1')
at call_user_func_array(array(object(UsersController), 'edit'), array('1')) in Controller.php line 55
at Controller->callAction('edit', array('1')) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(UsersController), 'edit') in Route.php line 203
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 561
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 520
at Router->dispatchToRoute(object(Request)) in Router.php line 498
at Router->dispatch(object(Request)) in Kernel.php line 174
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ValidatePostSize.php line 27
at ValidatePostSize->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53
at require_once('/home/adrian/cmf/public/index.php') in server.php line 21
I use a lot more Bootstrap 4 these days - if I modify the Templates would you add them to this Project?
This way we would have BS4 options for Building Admin Panels
After install it on laravel 5.3 when I try to edit a user I get this error:
RelationNotFoundException in RelationNotFoundException.php line 20:
Call to undefined relationship [roles] on model [App\User].
In usersController update function don't encrypt new password with bcrypt function. This a fix code. public function update($id, Request $request)
{
$this->validate($request, ['name' => 'required', 'email' => 'required', 'roles' => 'required']);
$user = User::findOrFail($id);
$data = $request->except('password');
if ($request->input('password'))
$data['password'] = bcrypt($request->password);
$user->update($data);
$user->roles()->detach();
foreach ($request->roles as $role) {
$user->assignRole($role);
}
Session::flash('flash_message', 'User updated!');
return redirect('admin/users');
}
UsersController
method store:
'email' => 'required|string|max:255|email|unique:users'
method update:
'email' => ['required',
'string',
'max:255',
'email',
\Illuminate\Validation\Rule::unique('users')->ignore($id)
],
First, your app are simple and awesome.
BUT
Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'roles'], 'roles' => ['admin','user']], function () { Route::get('/', ['uses' => 'Admin\AdminController@index']); });
you will see 'roles' => ['admin','user']
it doesn't work, how can I set the route group for admin, user role ?
Using this routes configuration
Route::group(['middleware' => ['auth', 'roles'], 'roles' => NULL], function () {
you see this error browsing http://127.0.0.1:8000/admin
Call to a member function intersect() on null
This is a possible solution into CheckRole
//if ($request->user()->hasRole($roles) || !$roles) {
if (!$roles || $request->user()->hasRole($roles)) {
return $next($request);
}
Parse error: syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'
`/Users/hatajie/Sites/isidia-backend/app/Http/Controllers/Admin/PermissionsController.php
*/
public function create()
{
return view('admin.permissions.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
*
* @return void
*/
public function store(Request $request)
{
$this->validate($request, ['name' => 'required']);
Permission::create($request->all());
return redirect('admin/permissions')->('flash_message', 'Permission added!');
}`
method store and update less with in flash message
solved with
return redirect('admin/permissions')->with('flash_message','Permission added !');
and error again
Undefined variable: role (View: /Users/hatajie/Sites/isidia-backend/resources/views/admin/roles/form.blade.php) (View: /Users/hatajie/Sites/isidia-backend/resources/views/admin/roles/form.blade.php)
Step 5: Install the admin package.
php artisan laravel-admin:install
Result:
PHP Fatal error: Class 'App\User' not found in /var/www/html/inversiones/vendor/appzcoder/laravel-admin/src/LaravelAdminCommand.php on line 44
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'App\User' not found
Does i need User.php file in Model directory?
We can not select multiple options when we use givePermissionTo method like this :
public function givePermissionTo(Permission $permission)
{
return $this->permissions()->save($permission);
}
as you can see, we typehint the injection to Permission..
Pls fix:
users/create.blade.php @include ('admin.users.form', ['submitButtonText' => 'Update']) ---> @include ('admin.users.form', ['passwordRequired' => true,'submitButtonText' => 'Update'])
users/edit.blade.php @include ('admin.users.form', ['submitButtonText' => 'Update']) ---> @include ('admin.users.form', ['passwordRequired' => false, 'submitButtonText' => 'Update'])
users/form.blade.php Row 18
{!! Form::password('password', ['class' => 'form-control', 'required' => $passwordRequired ? 'required' : false]) !!}
laravel 5.6 styles seems to be broken. when i use styles and html from previously generated for laravel 5.5 project it works fine. may be it is generator itself issue and appears after last commit or may be it is connected with laravel version
http://joxi.ru/l2Z4nzkt8gGaOr
When i try to install for laravel 5.3:
step:
it got an error:
php artisan laravel-admin:install
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Appzcoder\LaravelAdmin\LaravelAdminServiceProvider' not found
i cant even publish the package..
what do i wrong?
Hi,
I am trying to protect all dashboard links (/admin/*) from being accessible by non-admin.
So far, the code below can get the job done.
/routes/web.php
Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'roles'], 'roles' => 'admin'], function () {
Route::get('/', 'Admin\AdminController@index');
Route::get('/give-role-permissions', 'Admin\AdminController@getGiveRolePermissions');
Route::post('/give-role-permissions', 'Admin\AdminController@postGiveRolePermissions');
Route::resource('/roles', 'Admin\RolesController');
Route::resource('/permissions', 'Admin\PermissionsController');
Route::resource('/users', 'Admin\UsersController');
});
There is the link 'admin/generator' which can be accessed publicly and it seems like there is some protection already in https://github.com/appzcoder/laravel-admin/blob/master/src/routes.php, but unfortunately it did not work in my case.
Can anyone give me hint how to get this done?
(FYI: I started Laravel a few days ago, so I am very beginner. Thank for your patience)
Regarding to this issue, my other thinking is that I made mistake at the first place which I installed this package by using composer require but not require-dev. But I do need the dashboard functions.
Thank for any answers
Do you intend to include in the generator the foreign-key type and in the view to build with the combo box?
exec php artisan laravel-admin:install
make:auth not found error.(make:auth is laravel 5.2 or later)
vendor/appzcoder/laravel-admin/src/LaravelAdminCommand.php
line 73: $this->call('make:auth');
Please forgive me my lousy English.
Thanks.
When I use the generator on Laravel Framework 5.4.24 the controller.stub generates invalid code for the Controller@index
Output:
public function index(Request $request)
{
$keyword = $request->get('search');
$perPage = 25;
if (!empty($keyword)) {
$pages = Page::where('title', 'LIKE', "%$keyword%")
->orWhere('body', 'LIKE', "%$keyword%")
->
->paginate($perPage);
} else {
$pages = Page::paginate($perPage);
}
return view('admin.pages.index', compact('pages'));
}
It add a -> between the orWhere and Paginate. When I delete the "->" manually it is fixed.
how to solve this, if the user is logged in yet,
then this command I place right on the blade
layout.blade.php
`
@if(Auth::user()->hasRole('superadmin'))
@endif`
Came across your project and was wondering how easy would it be to integrate AngularJS into this project?
This tool looks great but I am not able to install it with composer as I've already installed your latest crud-generator (which works great), which is at ^3.0.
Error:
Problem 1
appzcoder/laravel-admin v1.0.4 requires appzcoder/crud-generator ^2.0 -> satisfiable by >appzcoder/crud-generator[2.0.x-dev, v2.0.0, v2.0.1, v2.0.2, v2.0.3, v2.0.4, v2.0.5, v2.0.6, v2.0.7, v2.0.8] but >these conflict with your requirements or minimum-stability.
Hello, thanks for the package.
I tried using package for external users model. duplicated all the models and files needed. when external user logs in it throw error referencing roles table. is it possible to use package for multi-auth?
'Base table or view not found: 1146 Table 'tracker.external_user_role' doesn't exist (SQL: select roles
.*, external_user_role
.external_user_id
as pivot_external_user_id
, external_user_role
.role_id
as pivot_role_id
from roles
inner join external_user_role
on roles
.id
= external_user_role
.role_id
where external_user_role
.external_user_id
= 1)'
thanks
I was trying the package and came with a need to check more than one role in a route. Digging in the HasRoles
trait you only check for a string in the role so I extended the code to check an array.
Now you can do something like this.
$api->group(["middleware" => "roles", "roles" => ["admin", "user"] ], function($api){
...
In HasRoles add this.
public function hasRole($role)
{
if (is_string($role)) {
return $this->roles->contains('name', $role);
}
//In case we have more than one role to check.
if(is_array($role)){
foreach($role as $r){
if($this->hasRole($r)){
return true;
}
}
}
return !!$role->intersect($this->roles)->count();
}
Hope it helps!
Executing the command php artisan laravel-admin:install
you have this error:
1071 Specified key was too long; max key length is 767 bytes
This is the solution:
namespace App\Providers;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
Schema::defaultStringLength(191);
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
If you add editing / deleting function models will be great
if run this command
php artisan laravel-admin:install
error
[Symfony\Component\Debug\Exception\FatalErrorException]
Trait 'App\HasRoles' not found
solved if run php artisan vendor:publish
my routes
Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth', 'roles'], 'roles' => 'admin'], function () { Route::get('/tes', ['uses' => 'AdminController@index']); });
but woops errorr
`public function hasRole($role)
{
if (is_string($role)) {
return $this->roles->contains('name', $role);
}
if (is_array($role)) {
foreach ($role as $r) {
if ($this->hasRole($r)) {
return true;
}
}
}`
"Call to a member function contains() on string"
Hi,
It would be very helpful if it's possible to add (Eloquent) table relations while using the crud generator.
Is this feature on the roadmap?
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.