定制 singsys/laravel-quick 二次开发

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

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

singsys/laravel-quick

Composer 安装命令:

composer require singsys/laravel-quick

包简介

README 文档

README

  • Add trait "Singsys\LQ\Lib\Concerns\LqResponse" in the file: "App\Http\Controllers\Controller"
After that you can use the following methods in your controller 
setData(Array $data) to set the data in Response conllection.
setError(String $error) to set the single error
setErrors(Array $errors) to set all errors of form.
setErrorCode(String #error_code) to set the error code.
response(Number $request_status_code = 200) to set the request status
  • Add trait "Singsys\LQ\Lib\Concerns\LqToken" in User model, and after you can directly generate the Pasword token from the user model Like:
$user = User::findOrFail($id);
$token = $user->createUserToken();
$user->setAttribute('token', $token);
return $this->setData(['user' => $user])
    ->response();
  • replace the file App\Exceptions\Handler from below content
<?php

namespace App\Exceptions;

use Singsys\LQ\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
    /**
     * Render an exception into an HTTP response.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Exception               $exception
     *
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $exception)
    {
        if ($request->is('api/*')) {
            return $this->lqRender($request, $exception);
        }

        return parent::render($request, $exception);
    }
}

  • Execute the following command on terminal:
php artisan migrate
php artisan lq:install
php artisan vendor:publish --tag=lq-config
  • Modify the RouteServiceProvider file, you just need to put the LqApiMiddleware globally for all Apis Like:
protected function mapApiRoutes()
{
    Route::prefix('api')
         ->middleware([\Singsys\LQ\Middleware\LqApiMiddleware::class])
         ->namespace($this->namespace . '\Api')
         ->group(base_path('routes/api.php'));
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-04-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固