1 | <?php |
||
9 | abstract class BaseMiddleware |
||
10 | { |
||
11 | /** |
||
12 | * @var \Illuminate\Routing\ResponseFactory |
||
13 | */ |
||
14 | protected $response; |
||
15 | |||
16 | /** |
||
17 | * @var \Illuminate\Events\Dispatcher |
||
18 | */ |
||
19 | protected $events; |
||
20 | |||
21 | /** |
||
22 | * @var \Tymon\JWTAuth\JWTAuth |
||
23 | */ |
||
24 | protected $auth; |
||
25 | |||
26 | /** |
||
27 | * Create a new BaseMiddleware instance |
||
28 | * |
||
29 | * @param \Illuminate\Routing\ResponseFactory $response |
||
30 | * @param \Illuminate\Events\Dispatcher $events |
||
31 | * @param \Tymon\JWTAuth\JWTAuth $auth |
||
32 | */ |
||
33 | 15 | public function __construct(ResponseFactory $response, Dispatcher $events, JWTAuth $auth) |
|
39 | |||
40 | /** |
||
41 | * Fire event and return the response |
||
42 | * |
||
43 | * @param string $event |
||
44 | * @param string $error |
||
45 | * @param integer $status |
||
46 | * @param array $payload |
||
47 | * @return mixed |
||
48 | */ |
||
49 | 12 | protected function respond($event, $error, $status, $payload = []) |
|
50 | { |
||
51 | 12 | $response = $this->events->fire($event, $payload, true); |
|
52 | |||
53 | 12 | return $response ?: $this->response->json(['error' => $error], $status); |
|
54 | } |
||
55 | |||
56 | |||
57 | /** |
||
58 | * Convert to array a string passed as argument of a middleware in this way key1-ele1;key2-ele2 |
||
59 | * @param String $str |
||
60 | * @return array |
||
61 | */ |
||
62 | 15 | protected function convertToArray($str){ |
|
73 | } |
||
74 |