z-song / laravel-admin Goto Github PK
View Code? Open in Web Editor NEWBuild a full-featured administrative interface in ten minutes
Home Page: https://laravel-admin.org
License: MIT License
Build a full-featured administrative interface in ten minutes
Home Page: https://laravel-admin.org
License: MIT License
你好,在根据readme的安装步骤中有以下问题:
安装
问题1:git clone 的master版本找不到config/app.php这个文件
在config/app.php加入ServiceProvider:
Encore\Admin\Providers\AdminServiceProvider::class
然后运行下面的命令完成安装:
问题2:在根目录执行php artisan,提示Could not open input file: artisan
php artisan vendor:publish --tag=laravel-admin
php artisan admin:install
另外,请问你有及时联系的方式么,比如QQ或者微信,遇到问题也可以及时请教
I have a custom file storage system and File class.
Therefore I would like to add my own File field so I can write the file in my own way.
But this prevents using custom forms:
$className = __NAMESPACE__ . '\\Form\\Field\\' . ucfirst($method);
Am I missing something?
when you try to filter the grid with something like this my_filter=0&my_other_filter=2
then the filters that are = 0 are not considered.
This is a bug when working with mysql boolean fields (0,1) - you can only filter for 1, not for 0
So we can add buttons like save & close, save, delete, copy, send new password, etc.
or add some buttons that just contain a link to for example a ChangePassword Form to seperate update actions.
Here is some pseudo/sample code how I see this, heavily borrowing from Silverstripe.
class MyForm extends Encore\Admin\Form
{
$template = 'something_custom_with_a_default';
public function addFormAction(FormAction $action)
{
$action->setForm($this);
$this->formactions->push($action); // could have some defaults??
return $this;
}
}
class MyFormAction extends FormAction
{
$template = 'something_custom_with_a_default';
//$rules = []; somecustomrules here? or create a Request class with rules?;
// Form would always call the FormAction->submit(); method...
public function submit($data, Form $form, Request $request)
{
// do something with submitted $data or $form->model()
// do some other custom things
// trigger an event
// set a flash message
// return redirect response or let the Form class do something by default.
}
}
I think with this approach, instead of keeping the update/create logic in the form, it should be moved to a dedicated SaveFormAction and / or UpdateFormAction. Which also allows custom validation when creating or updating a model.
Updating or Saving could also be decided by checking the $model->getKey(); value?
If you like this idea, im happy to dive into it....
a fix could be to use more rows for the filters in case they are alot.
When adding 2 or more filters to a grid it only filters by the latest filter added, it doesn't consider the others.
you cannot sort by relation.name
之前在tp的一个项目看到类似的方式,感觉会比较直观好用,大神可考虑下一版本改用此方式
Your requirements could not be resolved to an installable set of packages.
Problem 1
- intervention/image 2.3.8 requires ext-fileinfo * -> the requested PHP exte nsion fileinfo is missing from your system.
- intervention/image 2.3.7 requires ext-fileinfo * -> the requested PHP exte nsion fileinfo is missing from your system.
- intervention/image 2.3.6 requires ext-fileinfo * -> the requested PHP exte nsion fileinfo is missing from your system.
- intervention/image 2.3.5 requires ext-fileinfo * -> the requested PHP exte nsion fileinfo is missing from your system.
- intervention/image 2.3.4 requires ext-fileinfo * -> the requested PHP exte nsion fileinfo is missing from your system.
- intervention/image 2.3.3 requires ext-fileinfo * -> the requested PHP exte nsion fileinfo is missing from your system.
- intervention/image 2.3.2 requires ext-fileinfo * -> the requested PHP exte nsion fileinfo is missing from your system.
- intervention/image 2.3.1 requires ext-fileinfo * -> the requested PHP exte nsion fileinfo is missing from your system.
- intervention/image 2.3.0 requires ext-fileinfo * -> the requested PHP exte nsion fileinfo is missing from your system.
- encore/laravel-admin dev-master requires intervention/image ~2.3 -> satisf iable by intervention/image[2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.3.6, 2.3 .7, 2.3.8].
- Installation request for encore/laravel-admin dev-master -> satisfiable by encore/laravel-admin[dev-master].
To enable extensions, verify that they are enabled in those .ini files:
- D:\AppServ\php5\php.ini
You can also run php --ini
inside terminal to see which files are used by PH P in CLI mode.
This is what I was looking for..
It installed straightforwarded and without errors.
It would be really nice if you could default to english though... :)
我们的项目数据id用的都是uniqueid作为数据id,结果导致生成的内容被强制转整了
安装报错:
[root@iZ23m2zt6hsZ laravel-admin]# composer require encore/laravel-admin "dev-master"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package encore/laravel-admin No version set (parsed as 1.0.0) is satisfiable by encore/laravel-admin[No version set (parsed as 1.0.0)] but these conflict with your requirements or minimum-stability.
Installation failed, reverting ./composer.json to its original content.
RT
如题。谢谢
it shows chinese instead of english like the rest..
fix JS
now you use
protected $js = [
**'moment/min/moment.min.js',**
'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js'
];
change to
protected $js = [
'moment/min/moment-with-locales.min.js',
'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js'
];
and remove
$js[] = "moment/locale/{$options['locale']}.js";
如题
您好,想请问我这么调用grid有什么问题吗,为什么一直报错
public function index(){
return Admin::content(function(Content $content){
$content->header('app用户');
$content->description('用户信息');
$content->body($this->grid()->render());
});
}
protected function grid(){
return Admin::grid(AppUserModel::class,function(Grid $grid){
$grid->id('id');
$grid->name();
$grid->created_at()->sortable();
$grid->updated_at();
});
}
一直提示我 Undefined index: xx (View: F:\Apache24\htdocs\yulejia\vendor\encore\laravel-admin\views\grid.blade.php),
想问一下是我那里写错了吗
I've been using Menu to utilize access control for user that has a role. It works smoothly that entry menu didn't show up if user didn't have a role.
Like if user is not administrator, they can't see Users page appear on sidebar. But they still be able to open Users page by manually type http://localhost:8000/admin/auth/users.
How to protect routes like adding 401 unauthorized into laravel-admin?
Updating encore/laravel-admin 1.3.x-dev (aa5ecfa => a2a5f6d)
路径: http://localhost/admin/auth/users/create
Oops! Something went wrong.
In 4b652399b4089f7b955876f81f16ce9006e97948.php
line 12
: Undefined variable: options (View: C:\wamp64\www\laravelapp\laravel\vendor\encore\laravel-admin\views\form\multipleselect.blade.php) (View: C:\wamp64\www\laravelapp\laravel\vendor\encore\laravel-admin\views\form\multipleselect.blade.php)
On subsequent save the password gets bcrypted again with this example :
$form->saving(function($form) {
$form->password = bcrypt($form->password);
});
I think there are several ways to solve this, but this depends where you want to go with this:
public function setPasswordAttribute($password)
{
if($password && $password != $this->password) {
$this->attributes['password'] = bcrypt($password);
}
}
there is already a prepare method that returns the changed value, but we need access to the Form object in the FormFields. This can be handy for other formfields as well :
public function pushField(Field $field)
{
$field->setForm($this);
$this->builder->fields()->push($field);
return $this;
}
有没有 GRID FORM 的使用文档之类的!用着好吃力!
还有 默认 edit creat 方法 提交 是提交到哪里
$form->display('updated_at');
does not show anything
and
$form->divider();
seems to not to do anything?
$grid->title();
is a bit misleading when you have a column title in your table...
But $grid->title()
; is the Title of the Grid. not the column title
如果更新之后提示报错:表admin_operation_log
不存在,是因为添加了操作日志功能,新增了表和配置,解决办法如下:
1.在相应数据库里面新建表
CREATE TABLE `admin_operation_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL,
`path` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`method` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`ip` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
`input` text COLLATE utf8_unicode_ci,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `admin_operation_log_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2.在config/admin.php
添加配置
在database下添加一条 'operation_log_table' => 'admin_operation_log',
3.打开http://localhost:8000/admin/auth/menu
添加一项菜单,父级菜单选择Auth
,URI填admin/auth/logs
,Title填操作日志
, Icon填fa-history
然后就能在菜单栏看到操作日志入口了
So we don't have to extend formfields, but just implement the interface...
<?php
namespace Encore\Admin\Contracts;
use Encore\Admin\Form;
interface Field
{
/**
* Fill data to the field.
*
* @param $data
* @return void
*/
public function fill($data);
/**
* Set original value to the field.
*
* @param $data
* @return void
*/
public function setOriginal($data);
/**
* Set the Form to the field
*
* @param Form $form
* @return \Encore\Admin\Form\Field
*/
public function setForm(Form $form);
/**
* Set the field options.
*
* @param array $options
* @return \Encore\Admin\Form\Field
*/
public function options($options = []);
/**
* Get or set rules.
*
* @param null $rules
* @return string
*/
public function rules($rules = null);
/**
* Set or get value of the field.
*
* @param null $value
* @return mixed
*/
public function value($value = null);
/**
* Get column of the field.
*
* @return string
*/
public function column();
/**
* Get label of the field.
*
* @return string
*/
public function label();
/**
* Get original value of the field.
*
* @return mixed
*/
public function original();
/**
* Set the field as readonly mode.
*/
public function readOnly();
/**
* Get view of this field.
*
* @return string
*/
public function getView();
/**
* Render this filed.
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function render();
}
I will come up with better PR's soon, but I need a crashcourse for that first.
I have some extended form fields, where I want to do more with a Model then only write a value to the column. like setting other values based upon the submission, and this needs to be done before a value is set on a model.
There is a lot of flexiblilty if we could have access to the Form and Model in the Form Fields and can be done pretty easy to add this to the forms:
/**
* @return Model
*/
public function model()
{
return $this->model;
}
/**
* @param Field $field
*
* @return $this
*/
public function pushField(Field $field)
{
$field->setForm($this);
$this->builder->fields()->push($field);
return $this;
}
and change the line in __call()
$this->builder->fields()->push($element);
to this :
$this->pushField($element);
php artisan admin:install
之后访问 http://localhost/admin/ 出现 404
翻了一下源码,好像也没发现有这个方法,请问是写在哪里了?(另外发现版本更新后部分文档未更新,大神有空的话麻烦更新一下使用文档,感谢分享了这么好用的后台)
Run composer require encore/laravel-admin "1.3.x-dev" for Laravel 5.3, got this line:
Failed to download encore/laravel-admin from source: Failed to clone https://github.com/z-song/laravel-admin.git, git was not found, check that it is installed and in your PATH env.
'git' is not recognized as an internal or external command,
operable program or batch file.
如何在项目中添加验证信息的。如长度验证,非空验证等等。
文档有提到可以在控制器类内进行权限控制,这样做的有一个小问题,后台菜单对所有用户都默认显示了,点击进去后才会执行权限控制代码。如果需要管理用户登录后立即判断管理权限并显示有权限的菜单选项,应该需要如何操作?
重新安装项目的情况下(laravel5.2)
安装完成之后运行报没有数据库表的错,admin_users和menu都没有呢?谢谢
For instance on Unix (I am on Centos 7) I get a fatal error when FileViewFinder.php tries to include the form.multipleselect because it is camelcase "multipleSelect". I fixed by renaming the blade view to lowercase
现在的File和Image模块好像只能处理一对一关系. 也就是说我的一篇文章只能附加一个文件或者一张图片.
但多数时候我会想要附加不止一个, 请问有什么思路可以解决这样的问题吗? 谢谢.
From all of the packages that promise an easy way of creating cruds and admins, I really thing this one has the best approach.
Im working a lot with the Silverstripe Framework and there Forms works more or less the same.
I guess this package can gain a lot of ground with some tests.
this is needed as you don't want to show the hashed password in the field but you want to leave it blank and the user will decide if he wants to fill something in case he wants to change the pass
in many enterprise apps you need to filter by a many to many relation - that would generate a sql like:
SELECT
personID
FROM
people_to_sports
WHERE
sportID IN (1, 2)
GROUP BY
personID
HAVING
COUNT(*) = 2
Do you something like this could be done sometime in the future ?
我用的5.2版本的laravel。因为我表里面有个column叫title和一个方法重名,所以要按照文档里面:
使用column()方法:$grid->column('name', '用户名');
但是我使用的时候提示
ErrorException in Grid.php line 131:
Undefined variable: relation
$form->multipleSelect($column[, $label])->options([1 => 'foo', 2 => 'bar', 'val' => 'Option name']);
多选框使用错误,貌似是数据格式不识别;
再有一点,麻烦 添加一些 ajax 调用 和 类似于省份市之类的多选!
输入admin账号密码点击登录后,显示页面找不到。
是路由没设置还是其他什么情况呢?
如果model是多对多的多态关联(MorphToMany修饰关系), 则没有保存关联数据
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.