| 12345678910111213141516171819202122232425262728 |
- <?php
- namespace App\Components;
- use Illuminate\Support\Facades\Gate;
- trait AsyncResponse{
- protected function gate(string $authorityName)
- {
- if(!Gate::allows($authorityName)){
- echo ["success"=>false,"data"=>"无权操作"];
- exit();
- }
- }
- public function error(string $message)
- {
- echo json_encode(["success"=>false,"data"=>$message]);
- exit();
- }
- public function success($message)
- {
- echo json_encode(["success"=>true,"data"=>$message]);
- exit();
- }
- }
|