51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
use Illuminate\Routing\Controller as BaseController;
|
|
|
|
class Controller extends BaseController
|
|
{
|
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
|
|
|
protected $res = [
|
|
'httpCode' => 200,
|
|
'message' => '操作成功',
|
|
'errorCode' => 0,
|
|
'errorMessage' => '',
|
|
];
|
|
|
|
protected $log;
|
|
|
|
protected function setValidatorFailResponse($errorMessage)
|
|
{
|
|
return $this->res = [
|
|
'httpCode' => 400,
|
|
'errorCode' => 400416,
|
|
'errorMessage' => $errorMessage,
|
|
];
|
|
}
|
|
|
|
protected function setBeforeUpdate($data)
|
|
{
|
|
$this->log->before_update = is_array($data) ? json_encode($data, 256) : $data;
|
|
}
|
|
|
|
protected function setAfterUpdate($data)
|
|
{
|
|
$this->log->after_update = is_array($data) ? json_encode($data, 256) : $data;
|
|
}
|
|
|
|
protected function addLog($targetId = 0, $targetField = '', $targetType = '')
|
|
{
|
|
if ($targetType) {
|
|
$this->log->target_type = $targetType;
|
|
}
|
|
|
|
return $this->log->add($targetId, $targetField);
|
|
}
|
|
}
|