@@ -6,7 +6,7 @@ |
||
| 6 | 6 | |
| 7 | 7 | class DeviceArchive extends Model |
| 8 | 8 | { |
| 9 | - protected $table = 'device_archive'; |
|
| 9 | + protected $table = 'device_archive'; |
|
| 10 | 10 | |
| 11 | - protected $guarded = []; |
|
| 11 | + protected $guarded = []; |
|
| 12 | 12 | } |
@@ -11,29 +11,29 @@ |
||
| 11 | 11 | |
| 12 | 12 | class UpdateStatistics |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Handle the event. |
|
| 16 | - * |
|
| 17 | - * @param ServerWasPoked $event |
|
| 18 | - * |
|
| 19 | - * @return void |
|
| 20 | - */ |
|
| 21 | - public function handle(ServerWasPoked $event) |
|
| 22 | - { |
|
| 23 | - $device = $event->getDevice()->toArray(); |
|
| 14 | + /** |
|
| 15 | + * Handle the event. |
|
| 16 | + * |
|
| 17 | + * @param ServerWasPoked $event |
|
| 18 | + * |
|
| 19 | + * @return void |
|
| 20 | + */ |
|
| 21 | + public function handle(ServerWasPoked $event) |
|
| 22 | + { |
|
| 23 | + $device = $event->getDevice()->toArray(); |
|
| 24 | 24 | |
| 25 | - // device count |
|
| 26 | - DeviceArchive::updateOrCreate( |
|
| 27 | - ['mac_hash' => md5($device['mac'])], |
|
| 28 | - ['updated_at' => Carbon::now()] |
|
| 29 | - ); |
|
| 25 | + // device count |
|
| 26 | + DeviceArchive::updateOrCreate( |
|
| 27 | + ['mac_hash' => md5($device['mac'])], |
|
| 28 | + ['updated_at' => Carbon::now()] |
|
| 29 | + ); |
|
| 30 | 30 | |
| 31 | - // network distribution |
|
| 32 | - $network = ExtractNetwork::fromIp($device['ip']); |
|
| 33 | - DB::table('network_distribution')->where('network', $network)->increment('pokes'); |
|
| 31 | + // network distribution |
|
| 32 | + $network = ExtractNetwork::fromIp($device['ip']); |
|
| 33 | + DB::table('network_distribution')->where('network', $network)->increment('pokes'); |
|
| 34 | 34 | |
| 35 | - // pokes |
|
| 36 | - $date = Carbon::now()->toDateString(); |
|
| 37 | - Poke::firstOrCreate(['date' => $date])->increment('pokes'); |
|
| 38 | - } |
|
| 35 | + // pokes |
|
| 36 | + $date = Carbon::now()->toDateString(); |
|
| 37 | + Poke::firstOrCreate(['date' => $date])->increment('pokes'); |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Poke extends Model |
| 8 | 8 | { |
| 9 | - protected $guarded = []; |
|
| 9 | + protected $guarded = []; |
|
| 10 | 10 | |
| 11 | - public $timestamps = false; |
|
| 11 | + public $timestamps = false; |
|
| 12 | 12 | } |
@@ -4,27 +4,27 @@ |
||
| 4 | 4 | |
| 5 | 5 | class ExtractNetwork |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Extract the network from the ip address. |
|
| 9 | - * |
|
| 10 | - * @param string $ip |
|
| 11 | - * |
|
| 12 | - * @return string $network |
|
| 13 | - */ |
|
| 14 | - public static function fromIp($ip) |
|
| 15 | - { |
|
| 16 | - if (starts_with($ip, '192.168.')) { |
|
| 17 | - return '192.168.0.0/16'; |
|
| 18 | - } |
|
| 7 | + /** |
|
| 8 | + * Extract the network from the ip address. |
|
| 9 | + * |
|
| 10 | + * @param string $ip |
|
| 11 | + * |
|
| 12 | + * @return string $network |
|
| 13 | + */ |
|
| 14 | + public static function fromIp($ip) |
|
| 15 | + { |
|
| 16 | + if (starts_with($ip, '192.168.')) { |
|
| 17 | + return '192.168.0.0/16'; |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - if (starts_with($ip, '10.')) { |
|
| 21 | - return '10.0.0.0/8'; |
|
| 22 | - } |
|
| 20 | + if (starts_with($ip, '10.')) { |
|
| 21 | + return '10.0.0.0/8'; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - if (preg_match('/^172\.(1[6-9]|2[0-9]|3[01])\./', $ip)) { |
|
| 25 | - return '172.16.0.0/12'; |
|
| 26 | - } |
|
| 24 | + if (preg_match('/^172\.(1[6-9]|2[0-9]|3[01])\./', $ip)) { |
|
| 25 | + return '172.16.0.0/12'; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - return 'Internet'; |
|
| 29 | - } |
|
| 28 | + return 'Internet'; |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -9,83 +9,83 @@ |
||
| 9 | 9 | |
| 10 | 10 | class UserCreate extends Command |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * The console command name. |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - protected $name = 'user:create'; |
|
| 12 | + /** |
|
| 13 | + * The console command name. |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + protected $name = 'user:create'; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * The console command description. |
|
| 21 | - * |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - protected $description = 'Create a user.'; |
|
| 19 | + /** |
|
| 20 | + * The console command description. |
|
| 21 | + * |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + protected $description = 'Create a user.'; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * The registrar implementation. |
|
| 28 | - * |
|
| 29 | - * @var Registrar |
|
| 30 | - */ |
|
| 31 | - private $registrar; |
|
| 26 | + /** |
|
| 27 | + * The registrar implementation. |
|
| 28 | + * |
|
| 29 | + * @var Registrar |
|
| 30 | + */ |
|
| 31 | + private $registrar; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Create a new command instance. |
|
| 35 | - * |
|
| 36 | - * @param Registrar $registrar |
|
| 37 | - */ |
|
| 38 | - public function __construct(Registrar $registrar) |
|
| 39 | - { |
|
| 40 | - parent::__construct(); |
|
| 33 | + /** |
|
| 34 | + * Create a new command instance. |
|
| 35 | + * |
|
| 36 | + * @param Registrar $registrar |
|
| 37 | + */ |
|
| 38 | + public function __construct(Registrar $registrar) |
|
| 39 | + { |
|
| 40 | + parent::__construct(); |
|
| 41 | 41 | |
| 42 | - $this->registrar = $registrar; |
|
| 43 | - } |
|
| 42 | + $this->registrar = $registrar; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Execute the console command. |
|
| 47 | - * |
|
| 48 | - * @return mixed |
|
| 49 | - */ |
|
| 50 | - public function fire() |
|
| 51 | - { |
|
| 52 | - $email = $this->argument('email'); |
|
| 53 | - $password = $this->option('password'); |
|
| 54 | - $password_confirmation = $this->option('password_confirmation'); |
|
| 45 | + /** |
|
| 46 | + * Execute the console command. |
|
| 47 | + * |
|
| 48 | + * @return mixed |
|
| 49 | + */ |
|
| 50 | + public function fire() |
|
| 51 | + { |
|
| 52 | + $email = $this->argument('email'); |
|
| 53 | + $password = $this->option('password'); |
|
| 54 | + $password_confirmation = $this->option('password_confirmation'); |
|
| 55 | 55 | |
| 56 | - if (! $password) { |
|
| 57 | - $password = $this->secret('What password should the user have?'); |
|
| 58 | - } |
|
| 56 | + if (! $password) { |
|
| 57 | + $password = $this->secret('What password should the user have?'); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - if (! $password_confirmation) { |
|
| 61 | - $password_confirmation = $this->secret('Please confirm the password.'); |
|
| 62 | - } |
|
| 60 | + if (! $password_confirmation) { |
|
| 61 | + $password_confirmation = $this->secret('Please confirm the password.'); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $this->registrar->create(compact('email', 'password', 'password_confirmation')); |
|
| 65 | - } |
|
| 64 | + $this->registrar->create(compact('email', 'password', 'password_confirmation')); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Get the console command arguments. |
|
| 69 | - * |
|
| 70 | - * @return array |
|
| 71 | - */ |
|
| 72 | - protected function getArguments() |
|
| 73 | - { |
|
| 74 | - return [ |
|
| 75 | - ['email', InputArgument::REQUIRED, 'The email address of the user.'], |
|
| 76 | - ]; |
|
| 77 | - } |
|
| 67 | + /** |
|
| 68 | + * Get the console command arguments. |
|
| 69 | + * |
|
| 70 | + * @return array |
|
| 71 | + */ |
|
| 72 | + protected function getArguments() |
|
| 73 | + { |
|
| 74 | + return [ |
|
| 75 | + ['email', InputArgument::REQUIRED, 'The email address of the user.'], |
|
| 76 | + ]; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Get the console command options. |
|
| 81 | - * |
|
| 82 | - * @return array |
|
| 83 | - */ |
|
| 84 | - protected function getOptions() |
|
| 85 | - { |
|
| 86 | - return [ |
|
| 87 | - ['password', null, InputOption::VALUE_OPTIONAL, 'The password for the user.', null], |
|
| 88 | - ['password_confirmation', null, InputOption::VALUE_OPTIONAL, 'Password confirmation.', null], |
|
| 89 | - ]; |
|
| 90 | - } |
|
| 79 | + /** |
|
| 80 | + * Get the console command options. |
|
| 81 | + * |
|
| 82 | + * @return array |
|
| 83 | + */ |
|
| 84 | + protected function getOptions() |
|
| 85 | + { |
|
| 86 | + return [ |
|
| 87 | + ['password', null, InputOption::VALUE_OPTIONAL, 'The password for the user.', null], |
|
| 88 | + ['password_confirmation', null, InputOption::VALUE_OPTIONAL, 'Password confirmation.', null], |
|
| 89 | + ]; |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -53,11 +53,11 @@ |
||
| 53 | 53 | $password = $this->option('password'); |
| 54 | 54 | $password_confirmation = $this->option('password_confirmation'); |
| 55 | 55 | |
| 56 | - if (! $password) { |
|
| 56 | + if (!$password) { |
|
| 57 | 57 | $password = $this->secret('What password should the user have?'); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if (! $password_confirmation) { |
|
| 60 | + if (!$password_confirmation) { |
|
| 61 | 61 | $password_confirmation = $this->secret('Please confirm the password.'); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -10,138 +10,138 @@ |
||
| 10 | 10 | |
| 11 | 11 | class DeviceController extends ApiController |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @var DeviceTransformer |
|
| 15 | - */ |
|
| 16 | - private $transformer; |
|
| 17 | - |
|
| 18 | - public function __construct(DeviceTransformer $transformer) |
|
| 19 | - { |
|
| 20 | - $this->middleware('auth.basic', ['except' => ['index', 'poke', 'show']]); |
|
| 21 | - |
|
| 22 | - $this->transformer = $transformer; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Display a listing of the resource. |
|
| 27 | - * |
|
| 28 | - * @param null $group |
|
| 29 | - * |
|
| 30 | - * @return Response |
|
| 31 | - */ |
|
| 32 | - public function index($group = null) |
|
| 33 | - { |
|
| 34 | - $devices = $group ? Device::where('group', $group)->get() : Device::onHomePage()->get(); |
|
| 35 | - |
|
| 36 | - return $this->respond([ |
|
| 37 | - 'data' => $this->transformer->transformCollection($devices->all()), |
|
| 38 | - 'server_time' => Carbon::now()->toIso8601String(), |
|
| 39 | - ]); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Store a newly created resource in storage. |
|
| 44 | - * |
|
| 45 | - * @param StoreComputerRequest $request |
|
| 46 | - * |
|
| 47 | - * @return Response |
|
| 48 | - */ |
|
| 49 | - public function store(StoreComputerRequest $request) |
|
| 50 | - { |
|
| 51 | - $device = Device::create($request->all()); |
|
| 52 | - |
|
| 53 | - $device->public = $request->get('public', 'auto'); |
|
| 54 | - |
|
| 55 | - return $this->respondCreated($this->transformer->transform($device), $device->id); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Display the specified resource. |
|
| 60 | - * |
|
| 61 | - * @param int $id |
|
| 62 | - * |
|
| 63 | - * @return Response |
|
| 64 | - */ |
|
| 65 | - public function show($id) |
|
| 66 | - { |
|
| 67 | - $device = Device::find($id); |
|
| 68 | - |
|
| 69 | - if (! $device) { |
|
| 70 | - return $this->respondNotFound('Did not find the device you are looking for!'); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - return $this->respond([ |
|
| 74 | - 'data' => $this->transformer->transform($device), |
|
| 75 | - ]); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Update the specified resource in storage. |
|
| 80 | - * |
|
| 81 | - * @param StoreComputerRequest $request |
|
| 82 | - * @param int $id |
|
| 83 | - * |
|
| 84 | - * @return Response |
|
| 85 | - */ |
|
| 86 | - public function update(StoreComputerRequest $request, $id) |
|
| 87 | - { |
|
| 88 | - $device = Device::find($id); |
|
| 89 | - |
|
| 90 | - if (! $device) { |
|
| 91 | - return $this->respondNotFound('Did not find the device you are looking for!'); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - $device = $device->fill($request->all()); |
|
| 95 | - |
|
| 96 | - $device->save(); |
|
| 97 | - |
|
| 98 | - return $this->respond([ |
|
| 99 | - 'data' => $this->transformer->transform($device), |
|
| 100 | - ]); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Remove the specified resource from storage. |
|
| 105 | - * |
|
| 106 | - * @param int $id |
|
| 107 | - * |
|
| 108 | - * @return Response |
|
| 109 | - */ |
|
| 110 | - public function destroy($id) |
|
| 111 | - { |
|
| 112 | - $device = Device::find($id); |
|
| 113 | - |
|
| 114 | - if (! $device) { |
|
| 115 | - return $this->respondNotFound('Did not find the device you are looking for!'); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $device->delete(); |
|
| 119 | - |
|
| 120 | - return $this->respondNoContent(); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Handle device pokes. |
|
| 125 | - * |
|
| 126 | - * @param StoreComputerRequest $request |
|
| 127 | - * |
|
| 128 | - * @throws \Exception |
|
| 129 | - * |
|
| 130 | - * @return Response |
|
| 131 | - */ |
|
| 132 | - public function poke(StoreComputerRequest $request) |
|
| 133 | - { |
|
| 134 | - $device = Device::firstOrNew(['mac' => $request->mac]); |
|
| 135 | - |
|
| 136 | - $device->fill($request->all()); |
|
| 137 | - |
|
| 138 | - $device->group = $request->get('group', null); |
|
| 139 | - $device->public = $request->get('public', 'auto'); |
|
| 140 | - |
|
| 141 | - $device->touch(); |
|
| 142 | - |
|
| 143 | - event(new ServerWasPoked(array_add($device, 'server_time', Carbon::now()->toDateTimeString()))); |
|
| 144 | - |
|
| 145 | - return $this->respondPoked($this->transformer->transform($device), $device->id); |
|
| 146 | - } |
|
| 13 | + /** |
|
| 14 | + * @var DeviceTransformer |
|
| 15 | + */ |
|
| 16 | + private $transformer; |
|
| 17 | + |
|
| 18 | + public function __construct(DeviceTransformer $transformer) |
|
| 19 | + { |
|
| 20 | + $this->middleware('auth.basic', ['except' => ['index', 'poke', 'show']]); |
|
| 21 | + |
|
| 22 | + $this->transformer = $transformer; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Display a listing of the resource. |
|
| 27 | + * |
|
| 28 | + * @param null $group |
|
| 29 | + * |
|
| 30 | + * @return Response |
|
| 31 | + */ |
|
| 32 | + public function index($group = null) |
|
| 33 | + { |
|
| 34 | + $devices = $group ? Device::where('group', $group)->get() : Device::onHomePage()->get(); |
|
| 35 | + |
|
| 36 | + return $this->respond([ |
|
| 37 | + 'data' => $this->transformer->transformCollection($devices->all()), |
|
| 38 | + 'server_time' => Carbon::now()->toIso8601String(), |
|
| 39 | + ]); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Store a newly created resource in storage. |
|
| 44 | + * |
|
| 45 | + * @param StoreComputerRequest $request |
|
| 46 | + * |
|
| 47 | + * @return Response |
|
| 48 | + */ |
|
| 49 | + public function store(StoreComputerRequest $request) |
|
| 50 | + { |
|
| 51 | + $device = Device::create($request->all()); |
|
| 52 | + |
|
| 53 | + $device->public = $request->get('public', 'auto'); |
|
| 54 | + |
|
| 55 | + return $this->respondCreated($this->transformer->transform($device), $device->id); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Display the specified resource. |
|
| 60 | + * |
|
| 61 | + * @param int $id |
|
| 62 | + * |
|
| 63 | + * @return Response |
|
| 64 | + */ |
|
| 65 | + public function show($id) |
|
| 66 | + { |
|
| 67 | + $device = Device::find($id); |
|
| 68 | + |
|
| 69 | + if (! $device) { |
|
| 70 | + return $this->respondNotFound('Did not find the device you are looking for!'); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + return $this->respond([ |
|
| 74 | + 'data' => $this->transformer->transform($device), |
|
| 75 | + ]); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Update the specified resource in storage. |
|
| 80 | + * |
|
| 81 | + * @param StoreComputerRequest $request |
|
| 82 | + * @param int $id |
|
| 83 | + * |
|
| 84 | + * @return Response |
|
| 85 | + */ |
|
| 86 | + public function update(StoreComputerRequest $request, $id) |
|
| 87 | + { |
|
| 88 | + $device = Device::find($id); |
|
| 89 | + |
|
| 90 | + if (! $device) { |
|
| 91 | + return $this->respondNotFound('Did not find the device you are looking for!'); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + $device = $device->fill($request->all()); |
|
| 95 | + |
|
| 96 | + $device->save(); |
|
| 97 | + |
|
| 98 | + return $this->respond([ |
|
| 99 | + 'data' => $this->transformer->transform($device), |
|
| 100 | + ]); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Remove the specified resource from storage. |
|
| 105 | + * |
|
| 106 | + * @param int $id |
|
| 107 | + * |
|
| 108 | + * @return Response |
|
| 109 | + */ |
|
| 110 | + public function destroy($id) |
|
| 111 | + { |
|
| 112 | + $device = Device::find($id); |
|
| 113 | + |
|
| 114 | + if (! $device) { |
|
| 115 | + return $this->respondNotFound('Did not find the device you are looking for!'); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + $device->delete(); |
|
| 119 | + |
|
| 120 | + return $this->respondNoContent(); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Handle device pokes. |
|
| 125 | + * |
|
| 126 | + * @param StoreComputerRequest $request |
|
| 127 | + * |
|
| 128 | + * @throws \Exception |
|
| 129 | + * |
|
| 130 | + * @return Response |
|
| 131 | + */ |
|
| 132 | + public function poke(StoreComputerRequest $request) |
|
| 133 | + { |
|
| 134 | + $device = Device::firstOrNew(['mac' => $request->mac]); |
|
| 135 | + |
|
| 136 | + $device->fill($request->all()); |
|
| 137 | + |
|
| 138 | + $device->group = $request->get('group', null); |
|
| 139 | + $device->public = $request->get('public', 'auto'); |
|
| 140 | + |
|
| 141 | + $device->touch(); |
|
| 142 | + |
|
| 143 | + event(new ServerWasPoked(array_add($device, 'server_time', Carbon::now()->toDateTimeString()))); |
|
| 144 | + |
|
| 145 | + return $this->respondPoked($this->transformer->transform($device), $device->id); |
|
| 146 | + } |
|
| 147 | 147 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | $device = Device::find($id); |
| 68 | 68 | |
| 69 | - if (! $device) { |
|
| 69 | + if (!$device) { |
|
| 70 | 70 | return $this->respondNotFound('Did not find the device you are looking for!'); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | $device = Device::find($id); |
| 89 | 89 | |
| 90 | - if (! $device) { |
|
| 90 | + if (!$device) { |
|
| 91 | 91 | return $this->respondNotFound('Did not find the device you are looking for!'); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | { |
| 112 | 112 | $device = Device::find($id); |
| 113 | 113 | |
| 114 | - if (! $device) { |
|
| 114 | + if (!$device) { |
|
| 115 | 115 | return $this->respondNotFound('Did not find the device you are looking for!'); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -4,37 +4,37 @@ |
||
| 4 | 4 | // mix('js/app.js') |
| 5 | 5 | function mix($path, $json = false, $shouldHotReload = false) |
| 6 | 6 | { |
| 7 | - if (! $json) { |
|
| 8 | - static $json; |
|
| 9 | - } |
|
| 10 | - if (! $shouldHotReload) { |
|
| 11 | - static $shouldHotReload; |
|
| 12 | - } |
|
| 7 | + if (! $json) { |
|
| 8 | + static $json; |
|
| 9 | + } |
|
| 10 | + if (! $shouldHotReload) { |
|
| 11 | + static $shouldHotReload; |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - if (! $json) { |
|
| 15 | - $manifestPath = public_path('manifest.json'); |
|
| 16 | - $shouldHotReload = file_exists(public_path('hot')); |
|
| 14 | + if (! $json) { |
|
| 15 | + $manifestPath = public_path('manifest.json'); |
|
| 16 | + $shouldHotReload = file_exists(public_path('hot')); |
|
| 17 | 17 | |
| 18 | - if (! file_exists($manifestPath)) { |
|
| 19 | - throw new Exception( |
|
| 20 | - 'The Laravel Mix manifest file does not exist. '. |
|
| 21 | - 'Please run "npm run webpack" and try again.' |
|
| 22 | - ); |
|
| 23 | - } |
|
| 18 | + if (! file_exists($manifestPath)) { |
|
| 19 | + throw new Exception( |
|
| 20 | + 'The Laravel Mix manifest file does not exist. '. |
|
| 21 | + 'Please run "npm run webpack" and try again.' |
|
| 22 | + ); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - $json = json_decode(file_get_contents($manifestPath), true); |
|
| 26 | - } |
|
| 25 | + $json = json_decode(file_get_contents($manifestPath), true); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - $path = pathinfo($path, PATHINFO_BASENAME); |
|
| 28 | + $path = pathinfo($path, PATHINFO_BASENAME); |
|
| 29 | 29 | |
| 30 | - if (! array_key_exists($path, $json)) { |
|
| 31 | - throw new Exception( |
|
| 32 | - 'Unknown file path. Please check your requested '. |
|
| 33 | - 'webpack.mix.js output path, and try again.' |
|
| 34 | - ); |
|
| 35 | - } |
|
| 30 | + if (! array_key_exists($path, $json)) { |
|
| 31 | + throw new Exception( |
|
| 32 | + 'Unknown file path. Please check your requested '. |
|
| 33 | + 'webpack.mix.js output path, and try again.' |
|
| 34 | + ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - return $shouldHotReload |
|
| 38 | - ? "http://localhost:8080{$json[$path]}" |
|
| 39 | - : url($json[$path]); |
|
| 37 | + return $shouldHotReload |
|
| 38 | + ? "http://localhost:8080{$json[$path]}" |
|
| 39 | + : url($json[$path]); |
|
| 40 | 40 | } |
@@ -4,18 +4,18 @@ discard block |
||
| 4 | 4 | // mix('js/app.js') |
| 5 | 5 | function mix($path, $json = false, $shouldHotReload = false) |
| 6 | 6 | { |
| 7 | - if (! $json) { |
|
| 7 | + if (!$json) { |
|
| 8 | 8 | static $json; |
| 9 | 9 | } |
| 10 | - if (! $shouldHotReload) { |
|
| 10 | + if (!$shouldHotReload) { |
|
| 11 | 11 | static $shouldHotReload; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - if (! $json) { |
|
| 14 | + if (!$json) { |
|
| 15 | 15 | $manifestPath = public_path('manifest.json'); |
| 16 | 16 | $shouldHotReload = file_exists(public_path('hot')); |
| 17 | 17 | |
| 18 | - if (! file_exists($manifestPath)) { |
|
| 18 | + if (!file_exists($manifestPath)) { |
|
| 19 | 19 | throw new Exception( |
| 20 | 20 | 'The Laravel Mix manifest file does not exist. '. |
| 21 | 21 | 'Please run "npm run webpack" and try again.' |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | $path = pathinfo($path, PATHINFO_BASENAME); |
| 29 | 29 | |
| 30 | - if (! array_key_exists($path, $json)) { |
|
| 30 | + if (!array_key_exists($path, $json)) { |
|
| 31 | 31 | throw new Exception( |
| 32 | 32 | 'Unknown file path. Please check your requested '. |
| 33 | 33 | 'webpack.mix.js output path, and try again.' |
@@ -6,55 +6,55 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Kernel extends HttpKernel |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * The application's global HTTP middleware stack. |
|
| 11 | - * |
|
| 12 | - * These middleware are run during every request to your application. |
|
| 13 | - * |
|
| 14 | - * @var array |
|
| 15 | - */ |
|
| 16 | - protected $middleware = [ |
|
| 17 | - \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, |
|
| 18 | - \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, |
|
| 19 | - \PiFinder\Http\Middleware\TrimStrings::class, |
|
| 20 | - \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, |
|
| 21 | - ]; |
|
| 9 | + /** |
|
| 10 | + * The application's global HTTP middleware stack. |
|
| 11 | + * |
|
| 12 | + * These middleware are run during every request to your application. |
|
| 13 | + * |
|
| 14 | + * @var array |
|
| 15 | + */ |
|
| 16 | + protected $middleware = [ |
|
| 17 | + \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, |
|
| 18 | + \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, |
|
| 19 | + \PiFinder\Http\Middleware\TrimStrings::class, |
|
| 20 | + \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, |
|
| 21 | + ]; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * The application's route middleware groups. |
|
| 25 | - * |
|
| 26 | - * @var array |
|
| 27 | - */ |
|
| 28 | - protected $middlewareGroups = [ |
|
| 29 | - 'web' => [ |
|
| 30 | - \PiFinder\Http\Middleware\EncryptCookies::class, |
|
| 31 | - \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
|
| 32 | - \Illuminate\Session\Middleware\StartSession::class, |
|
| 33 | - // \Illuminate\Session\Middleware\AuthenticateSession::class, |
|
| 34 | - \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
|
| 35 | - \PiFinder\Http\Middleware\VerifyCsrfToken::class, |
|
| 36 | - \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
| 37 | - ], |
|
| 23 | + /** |
|
| 24 | + * The application's route middleware groups. |
|
| 25 | + * |
|
| 26 | + * @var array |
|
| 27 | + */ |
|
| 28 | + protected $middlewareGroups = [ |
|
| 29 | + 'web' => [ |
|
| 30 | + \PiFinder\Http\Middleware\EncryptCookies::class, |
|
| 31 | + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
|
| 32 | + \Illuminate\Session\Middleware\StartSession::class, |
|
| 33 | + // \Illuminate\Session\Middleware\AuthenticateSession::class, |
|
| 34 | + \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
|
| 35 | + \PiFinder\Http\Middleware\VerifyCsrfToken::class, |
|
| 36 | + \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
| 37 | + ], |
|
| 38 | 38 | |
| 39 | - 'api' => [ |
|
| 40 | - 'throttle:60,1', |
|
| 41 | - 'bindings', |
|
| 42 | - ], |
|
| 43 | - ]; |
|
| 39 | + 'api' => [ |
|
| 40 | + 'throttle:60,1', |
|
| 41 | + 'bindings', |
|
| 42 | + ], |
|
| 43 | + ]; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * The application's route middleware. |
|
| 47 | - * |
|
| 48 | - * These middleware may be assigned to groups or used individually. |
|
| 49 | - * |
|
| 50 | - * @var array |
|
| 51 | - */ |
|
| 52 | - protected $routeMiddleware = [ |
|
| 53 | - 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, |
|
| 54 | - 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
|
| 55 | - 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
| 56 | - 'can' => \Illuminate\Auth\Middleware\Authorize::class, |
|
| 57 | - 'guest' => \PiFinder\Http\Middleware\RedirectIfAuthenticated::class, |
|
| 58 | - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
|
| 59 | - ]; |
|
| 45 | + /** |
|
| 46 | + * The application's route middleware. |
|
| 47 | + * |
|
| 48 | + * These middleware may be assigned to groups or used individually. |
|
| 49 | + * |
|
| 50 | + * @var array |
|
| 51 | + */ |
|
| 52 | + protected $routeMiddleware = [ |
|
| 53 | + 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, |
|
| 54 | + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
|
| 55 | + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
| 56 | + 'can' => \Illuminate\Auth\Middleware\Authorize::class, |
|
| 57 | + 'guest' => \PiFinder\Http\Middleware\RedirectIfAuthenticated::class, |
|
| 58 | + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
|
| 59 | + ]; |
|
| 60 | 60 | } |
@@ -6,13 +6,13 @@ |
||
| 6 | 6 | |
| 7 | 7 | class TrimStrings extends BaseTrimmer |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * The names of the attributes that should not be trimmed. |
|
| 11 | - * |
|
| 12 | - * @var array |
|
| 13 | - */ |
|
| 14 | - protected $except = [ |
|
| 15 | - 'password', |
|
| 16 | - 'password_confirmation', |
|
| 17 | - ]; |
|
| 9 | + /** |
|
| 10 | + * The names of the attributes that should not be trimmed. |
|
| 11 | + * |
|
| 12 | + * @var array |
|
| 13 | + */ |
|
| 14 | + protected $except = [ |
|
| 15 | + 'password', |
|
| 16 | + 'password_confirmation', |
|
| 17 | + ]; |
|
| 18 | 18 | } |