定制 shengfai/laravel-admin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shengfai/laravel-admin

Composer 安装命令:

composer require shengfai/laravel-admin

包简介

An administrative interface package for Laravel

README 文档

README

An administrative interface package for Laravel.

Screenshots

菜单管理 角色管理

Look here for lots of screenshots for the application.

Required

  • PHP 7.0 +
  • Laravel 7.0 +

Installing

You can install the package using composer.

$ composer require shengfai/laravel-admin -vvv

Then run following command to finish install.

$ php artisan admin:install

Open http://localhost/console/ in browser,use username 13123456789 and password 111111 to login.

Usage

Custom routes

Create routes/administrator.php file:

<?php

use Illuminate\Support\Facades\Route;

// 资源路由
Route::resources([
    'schools' => 'SchoolController',           // 学校管理
]);

Setup your controllers

Create app/Http/Controllers/Admin/SchoolController.php file:

<?php

namespace App\Http\Controllers\Admin;

use App\Models\School;
use App\Services\SchoolService;
use Illuminate\Http\Request;
use Shengfai\LaravelAdmin\Controllers\Controller;

/**
 * 学校控制台
 * Class SchoolController
 *
 * @author ShengFai <shengfai@qq.com>
 * @version 2020年4月16日
 */
class SchoolController extends Controller
{

    /**
     * The title of the page.
     *
     * @var string $title
     */
    protected $title = '学校管理';

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $queryBuilder = School::sorted();

        return $this->list($queryBuilder);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $types = School::types();
        $this->assign('types', $types);

        return $this->form();
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $newSchoolData = collect($request->all());

        $activity = (new SchoolService())->store($newSchoolData);

        return $this->success('数据添加成功', '');
    }

    /**
     * Display the specified resource.
     *
     * @param \App\Models\School $school
     * @return \Illuminate\Http\Response
     */
    public function show(School $school)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param \App\Models\School $school
     * @return \Illuminate\Http\Response
     */
    public function edit(School $school)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param \Illuminate\Http\Request $request
     * @param \App\Models\School $school
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, School $school)
    {
        // 更新指定字段
        if ($request->isMethod('Patch')) {
            tap($school)->update([
                $request->field => $request->value
            ]);

            return $this->success('数据更新成功', '');
        }
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param \App\Models\School $school
     * @return \Illuminate\Http\Response
     */
    public function destroy(School $school)
    {
        //
    }
}

Setup your views

Create resources\views\vendor\admin\school\index.blade.php file:

@extends('admin::layouts.content')

@section('button')
<button data-modal="{{route('admin.schools.create')}}" data-title="添加学校" class="layui-btn layui-btn-sm">添加学校</button>
@stop

@section('content')
<div class="layui-card">
    <div class="layui-card-body">
    <form autocomplete="off" onsubmit="return false;" data-auto="true" method="get">
        @empty($list)
        <p class="help-block text-center well">没 有 记 录 哦!</p>
        @else
        <input type="hidden" value="resort" name="action">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <table id="test" class="layui-table" lay-skin="line">
            <thead>
            <tr>
                <th class='list-table-sort-td'>
                    <button type="submit" class="layui-btn layui-btn-normal layui-btn-xs">排 序</button>
                </th>
                <th class="text-left">编号</th>
                <th class="text-left">名称</th>
                <th class="text-left">创建时间</th>
                <th class="text-left">操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach ($list as $key => $vo)
            <tr>
                <td class="list-table-sort-td">
                    <input name="_{{ $vo->id }}" value="{{ $vo->sort }}" class="list-sort-input">
                </td>
                <td class="text-left">{{ $vo->code }}</td>
                <td class="text-left">{{ $vo->letter }} {{ $vo->name }}</td>
                <td class="text-left">{!! $vo->getTimestampFormat() !!}</td>
                <td class="text-left">
                    <a data-title="编辑资料" data-modal="{{ route('admin.schools.edit', $vo->id) }}">编辑</a>
                    <span class="text-explode">|</span>
                    @if ($vo->status === 1)
                    <a data-update="{{ $vo->id }}" data-field="status" data-value="0"  data-csrf="{{ csrf_token() }}" data-action="{{ route('admin.schools.update', $vo->id) }}">禁用</a>
                    @else
                    <a data-update="{{ $vo->id }}" data-field="status" data-value="1" data-csrf="{{ csrf_token() }}" data-action="{{ route('admin.schools.update', $vo->id) }}">启用</a>
                    @endif
                </td>
            </tr>
            @endforeach
            </tbody>
        </table>
        @if (isset($page))<p>{!! $page !!}</p>@endif
        @endempty
    </form>
    </div>
</div>

@stop

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

Extensions

laravel-admin based on following plugins or services:

License

MIT

shengfai/laravel-admin 适用场景与选型建议

shengfai/laravel-admin 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 1.05k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 03 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「admin」 「laravel」 「laravel admin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 shengfai/laravel-admin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 shengfai/laravel-admin 我们能提供哪些服务?
定制开发 / 二次开发

基于 shengfai/laravel-admin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-10