laravel-admin is a good thing, first worship the great god, thank the great god @song, the following is the pit crawled during the use process, everyone encourages
1. Add a router
The documentation says: Use the following command to create a router corresponding to the App\User model
// in windows system
php artisan admin:make UserController --model=App\\User
// 在windows系统中
php artisan admin:make UserController --model=App\User
Error:
Model does not exists !
The path is wrong? Check N times, the path is absolutely correct! ! ! !
Climbing pit:
php artisan admin:make UserController --model="App\User"
It's right to add quotation marks, fainted. . .
2. How to display the short fields on the same line in from
What I'm talking about here is a problem of extending the row-table . With this plug-in, you can display some content that does not need to occupy the front row to display in one row.
After installing according to the installation document, an error is reported:
Class 'App\Admin\Controllers\TableRow' not found
After the global search failed, I had a headache. After asking the author, I got the following answer:
use Ichynul\RowTable\TableRow;
3. Thumbnail
According to the documentation, multiple thumbnails can be generated while uploading an image:
$form->image($column[, $label])->thumbnail([
'small' => [100, 100],
'small' => [200, 200],
'small' => [300, 300],
]);
After using it, I found that there will only be one small, and the size is the last 300*300. After checking, I found that only one multi-thumbnail is generated because small is the name. . .
Correct posture:
$form->image($column[, $label])->thumbnail([
'small-1' => [100, 100],
'small-2' => [200, 200],
'small-3' => [300, 300],
]);
4. Upload image path
After configuring according to the official document, you will find an embarrassing thing. The uploaded path is a relative path, not starting with a slash. Of course, this may also be because I did not configure the domain name. The reason is that I don’t like the stored path to contain the domain name. , This is not conducive to what if the domain name is changed later? ?
Solution:
- First add storage configuration,
config/filesystems.php
add a disk:
'disks' => [
'admin' => [
'driver' => 'local',
'root' => public_path('uploads'),
'visibility' => 'public',
'url' => env('APP_URL').'/',
],
- Open
config/admin.php
to find:
'upload' => [
// Disk in `config/filesystem.php`.
'disk' => 'admin',
// Image and file upload path under the disk above.
'directory' => [
'image' => 'images',
'file' => 'files',
],
],
- Find the corresponding model:
public function setCoverAttribute($path)
{
$this->attributes['cover'] = '/uploads/'.$path;
}
- Modify the corresponding From:
$dir = "/images/testpsy/" . date("Ym/d", time());
$form->image('thumb', __('Thumb'))->uniqueName()->move($dir);
5. Configure WangEditor2 to report an error
This is still an extended problem of wangEditor2 , and an error will be reported after configuration:
Field type [editor] does not exist.
Reason: The editor type has been canceled after laravel-admin V1.7
Workaround:
Open app/Admin/bootstrap.php
the file:
Encore\Admin\Form::forget(['map', 'editor']);
Replace with:
Encore\Admin\Form::forget(['map']);
For the time being, these pits will continue to be updated. . .