36 lines
850 B
PHP
36 lines
850 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Base;
|
|
|
|
use App\Service\ReplyService;
|
|
use Illuminate\Routing\Controller;
|
|
|
|
abstract class BaseController extends Controller
|
|
{
|
|
public array $validateMethodParams = [];
|
|
|
|
function __call($method, $parameters)
|
|
{
|
|
if (isset($this->validateMethodParams[$method])) {
|
|
request()->validate($this->validateMethodParams[$method]);
|
|
}
|
|
parent::__call($method, $parameters);
|
|
}
|
|
|
|
function reply($code, $msg, $data = []): \Illuminate\Http\JsonResponse
|
|
{
|
|
return ReplyService::reply($code, $msg, $data);
|
|
}
|
|
|
|
function success($data = []): \Illuminate\Http\JsonResponse
|
|
{
|
|
return ReplyService::success($data);
|
|
}
|
|
|
|
function error($msg = 'error', $data = []): \Illuminate\Http\JsonResponse
|
|
{
|
|
ReplyService::error($msg, $data);
|
|
}
|
|
|
|
}
|