小白兔晒黑了

导航

 

 

Laravel-admin 是一个可以快速帮你构建后台管理的工具,它提供的页面组件和表单元素等功能,能帮助你使用很少的代码就实现功能完善的后台管理功能。

  • 内置用户和权限系统
  • model-grid 支持快速构建数据表格
  • model-form 支持快速构建数据表单
  • model-tree 支持快速构建树状数据
  • 内置 40+ 种 form 元素组件、以及支持扩展组件
  • 支持 Laravel 的多种模型关系
  • mysql、mongodb、pgsql 等多数据库支持
  • 支持引入第三方前端库
  • 数据库和 artisan 命令行工具的 web 实现
  • 支持自定义图表
  • 多种常用 web 组件
  • 支持本地和 oss 文件上传

 

手册 https://laravel-admin.org/docs/zh/installation

 

 

1 安装Laravel

composer create-project laravel/laravel projectName

2 下载laravel-admin组件

composer require encore/laravel-admin

 

 

3 安装admin模块

php artisan admin:install

 

 

建一个站点 指向 \localhost\china-holdings\public目录

 

配置你的数据库

配置步骤 https://www.jianshu.com/p/a5382761301a

就可以访问了 admin admin

 关于上传头像失败的问题

1

\config\admin.php 有一个上传设置

'upload' => [

        // Disk in `config/filesystem.php`.
        'disk' => 'admin',


        // Image and file upload path under the disk above.
        'directory' => [
            'image' => 'images',
            'file'  => 'files',
        ],
    ],

2

\config\filesystems.php 里添加一个admin配置

'admin' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

3

并打开php_fileinfo扩展

4 运行命令 设置软链接

php artisan storage:link

 

 

如果已经存在此文件夹 需要手动删除一下再重试

就能看到头像了

 

安装脚手架helpers

laravel admin 提供了脚手架,可以帮助我们快速搭建后台

 

composer require laravel-admin-ext/helpers

 

php artisan admin:import helpers

 

 添加广告管理功能

 搭建cms

参考

https://blog.csdn.net/tang05709/article/details/80843032

https://blog.csdn.net/tang05709/article/details/80843514

脚手架(Scaffold)页面添加一个广告管理

表名:adverts

 

点击提交以后自动创建了三个文件和一个表。

但其实我们要的表结构不仅是单单一个adverts_title,所以我们把表删掉重新创建

添加以下代码:

 

        Schema::create('adverts', function (Blueprint $table) {
            $table->increments('id');
            $table->string('advert_desc');
            $table->string('image');
            $table->string('url');
            $table->integer('advert_type_id');
            $table->timestamps();
        });
        Schema::create('advert_types', function (Blueprint $table) {
            $table->increments('id');
            $table->string('advert_type_name');
            $table->timestamps();
        });

然后我们把文件名+1s

运行数据库迁移命令

 php artisan  migrate

我们就会看到两个新表被创建了

然后配置菜单

然后访问http://localhost/admin/advert

发现404错误。因为你还没有配置路由

\app\Admin\routes.php

添加一下代码

   //广告
    $router->resource('advert', 'AdvertController');
    //广告类型
    $router->resource('advert_type', 'AdvertTypeController');

 

参考阅读

https://www.cnblogs.com/yehuisir/p/11384161.html

https://findcat.cn/archives/831

http://www.pianshen.com/article/5674254952/

 

posted on 2019-10-25 10:24  小白兔晒黑了  阅读(655)  评论(0编辑  收藏  举报