@@ -6,17 +6,17 @@ |
||
6 | 6 | |
7 | 7 | abstract class Request extends FormRequest |
8 | 8 | { |
9 | - public function __construct() |
|
10 | - { |
|
11 | - parent::__construct(); |
|
9 | + public function __construct() |
|
10 | + { |
|
11 | + parent::__construct(); |
|
12 | 12 | |
13 | - $this->validateMac(); |
|
14 | - } |
|
13 | + $this->validateMac(); |
|
14 | + } |
|
15 | 15 | |
16 | - public function validateMac() |
|
17 | - { |
|
18 | - app('validator')->extend('mac', function ($attribute, $value, $parameters) { |
|
19 | - return preg_match('/^(([0-9a-fA-F]{2}-){5}|([0-9a-fA-F]{2}:){5})[0-9a-fA-F]{2}$/', $value); |
|
20 | - }); |
|
21 | - } |
|
16 | + public function validateMac() |
|
17 | + { |
|
18 | + app('validator')->extend('mac', function ($attribute, $value, $parameters) { |
|
19 | + return preg_match('/^(([0-9a-fA-F]{2}-){5}|([0-9a-fA-F]{2}:){5})[0-9a-fA-F]{2}$/', $value); |
|
20 | + }); |
|
21 | + } |
|
22 | 22 | } |
@@ -6,34 +6,34 @@ |
||
6 | 6 | |
7 | 7 | class StoreComputerRequest extends Request |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'ip' => 'required|ip', |
|
28 | - 'mac' => 'required|mac', |
|
29 | - 'name' => 'required', |
|
30 | - 'group' => 'alpha_dash|max:30', |
|
31 | - 'public' => 'in:true,false,auto', |
|
32 | - ]; |
|
33 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'ip' => 'required|ip', |
|
28 | + 'mac' => 'required|mac', |
|
29 | + 'name' => 'required', |
|
30 | + 'group' => 'alpha_dash|max:30', |
|
31 | + 'public' => 'in:true,false,auto', |
|
32 | + ]; |
|
33 | + } |
|
34 | 34 | |
35 | - public function response(array $errors) |
|
36 | - { |
|
37 | - return new JsonResponse($errors, 422); |
|
38 | - } |
|
35 | + public function response(array $errors) |
|
36 | + { |
|
37 | + return new JsonResponse($errors, 422); |
|
38 | + } |
|
39 | 39 | } |
@@ -6,32 +6,32 @@ |
||
6 | 6 | |
7 | 7 | class MarkdownParser |
8 | 8 | { |
9 | - /** |
|
10 | - * Markdown parser instance. |
|
11 | - * |
|
12 | - * @var ParsedownExtra |
|
13 | - */ |
|
14 | - private $markdown; |
|
9 | + /** |
|
10 | + * Markdown parser instance. |
|
11 | + * |
|
12 | + * @var ParsedownExtra |
|
13 | + */ |
|
14 | + private $markdown; |
|
15 | 15 | |
16 | - /** |
|
17 | - * MarkdownParser constructor. |
|
18 | - * |
|
19 | - * @param ParsedownExtra $markdown |
|
20 | - */ |
|
21 | - public function __construct(ParsedownExtra $markdown) |
|
22 | - { |
|
23 | - $this->markdown = $markdown; |
|
24 | - } |
|
16 | + /** |
|
17 | + * MarkdownParser constructor. |
|
18 | + * |
|
19 | + * @param ParsedownExtra $markdown |
|
20 | + */ |
|
21 | + public function __construct(ParsedownExtra $markdown) |
|
22 | + { |
|
23 | + $this->markdown = $markdown; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Parse a markdown document. |
|
28 | - * |
|
29 | - * @param $path |
|
30 | - * |
|
31 | - * @return mixed|string |
|
32 | - */ |
|
33 | - public function parse($path) |
|
34 | - { |
|
35 | - return $this->markdown->text($path); |
|
36 | - } |
|
26 | + /** |
|
27 | + * Parse a markdown document. |
|
28 | + * |
|
29 | + * @param $path |
|
30 | + * |
|
31 | + * @return mixed|string |
|
32 | + */ |
|
33 | + public function parse($path) |
|
34 | + { |
|
35 | + return $this->markdown->text($path); |
|
36 | + } |
|
37 | 37 | } |
@@ -4,17 +4,17 @@ |
||
4 | 4 | |
5 | 5 | abstract class Transformer |
6 | 6 | { |
7 | - /** |
|
8 | - * Transform a collection of items. |
|
9 | - * |
|
10 | - * @param array $items |
|
11 | - * |
|
12 | - * @return array |
|
13 | - */ |
|
14 | - public function transformCollection(array $items) |
|
15 | - { |
|
16 | - return array_map([$this, 'transform'], $items); |
|
17 | - } |
|
7 | + /** |
|
8 | + * Transform a collection of items. |
|
9 | + * |
|
10 | + * @param array $items |
|
11 | + * |
|
12 | + * @return array |
|
13 | + */ |
|
14 | + public function transformCollection(array $items) |
|
15 | + { |
|
16 | + return array_map([$this, 'transform'], $items); |
|
17 | + } |
|
18 | 18 | |
19 | - abstract public function transform($item); |
|
19 | + abstract public function transform($item); |
|
20 | 20 | } |
@@ -4,16 +4,16 @@ |
||
4 | 4 | |
5 | 5 | class DeviceTransformer extends Transformer |
6 | 6 | { |
7 | - public function transform($device) |
|
8 | - { |
|
9 | - return [ |
|
10 | - 'id' => $device['id'], |
|
11 | - 'ip' => $device['ip'], |
|
12 | - 'name' => $device['name'], |
|
13 | - 'group' => $device['group'], |
|
14 | - 'on_home_page' => $device['public'], |
|
15 | - 'device_added' => $device['created_at']->toIso8601String(), |
|
16 | - 'last_contact' => $device['updated_at']->toIso8601String(), |
|
17 | - ]; |
|
18 | - } |
|
7 | + public function transform($device) |
|
8 | + { |
|
9 | + return [ |
|
10 | + 'id' => $device['id'], |
|
11 | + 'ip' => $device['ip'], |
|
12 | + 'name' => $device['name'], |
|
13 | + 'group' => $device['group'], |
|
14 | + 'on_home_page' => $device['public'], |
|
15 | + 'device_added' => $device['created_at']->toIso8601String(), |
|
16 | + 'last_contact' => $device['updated_at']->toIso8601String(), |
|
17 | + ]; |
|
18 | + } |
|
19 | 19 | } |
@@ -9,5 +9,5 @@ |
||
9 | 9 | |
10 | 10 | abstract class Controller extends BaseController |
11 | 11 | { |
12 | - use AuthorizesRequests, DispatchesJobs, ValidatesRequests; |
|
12 | + use AuthorizesRequests, DispatchesJobs, ValidatesRequests; |
|
13 | 13 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | class WelcomeController extends Controller |
13 | 13 | { |
14 | - /* |
|
14 | + /* |
|
15 | 15 | |-------------------------------------------------------------------------- |
16 | 16 | | Welcome Controller |
17 | 17 | |-------------------------------------------------------------------------- |
@@ -22,63 +22,63 @@ discard block |
||
22 | 22 | | |
23 | 23 | */ |
24 | 24 | |
25 | - /** |
|
26 | - * Create a new controller instance. |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - $this->middleware('guest'); |
|
31 | - } |
|
25 | + /** |
|
26 | + * Create a new controller instance. |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + $this->middleware('guest'); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Show the application welcome screen to the user. |
|
35 | - * |
|
36 | - * @return Response |
|
37 | - */ |
|
38 | - public function index() |
|
39 | - { |
|
40 | - $devices = Device::onHomePage()->get(); |
|
33 | + /** |
|
34 | + * Show the application welcome screen to the user. |
|
35 | + * |
|
36 | + * @return Response |
|
37 | + */ |
|
38 | + public function index() |
|
39 | + { |
|
40 | + $devices = Device::onHomePage()->get(); |
|
41 | 41 | |
42 | - return view('overview')->with(compact('devices')); |
|
43 | - } |
|
42 | + return view('overview')->with(compact('devices')); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Show the getting started screen to the user. |
|
47 | - * |
|
48 | - * @param MarkdownParser $markdown |
|
49 | - * @param Cache $cache |
|
50 | - * @param Filesystem $file |
|
51 | - * |
|
52 | - * @return Response |
|
53 | - */ |
|
54 | - public function gettingStarted(MarkdownParser $markdown, Cache $cache, Filesystem $file) |
|
55 | - { |
|
56 | - $gettingStarted = $cache->remember('getting-started', 5, function () use ($markdown, $file) { |
|
57 | - $gettingStarted = $file->get(base_path('resources/getting-started/readme.md')); |
|
45 | + /** |
|
46 | + * Show the getting started screen to the user. |
|
47 | + * |
|
48 | + * @param MarkdownParser $markdown |
|
49 | + * @param Cache $cache |
|
50 | + * @param Filesystem $file |
|
51 | + * |
|
52 | + * @return Response |
|
53 | + */ |
|
54 | + public function gettingStarted(MarkdownParser $markdown, Cache $cache, Filesystem $file) |
|
55 | + { |
|
56 | + $gettingStarted = $cache->remember('getting-started', 5, function () use ($markdown, $file) { |
|
57 | + $gettingStarted = $file->get(base_path('resources/getting-started/readme.md')); |
|
58 | 58 | |
59 | - return $markdown->parse($gettingStarted); |
|
60 | - }); |
|
59 | + return $markdown->parse($gettingStarted); |
|
60 | + }); |
|
61 | 61 | |
62 | - return view('getting-started')->with(compact('gettingStarted')); |
|
63 | - } |
|
62 | + return view('getting-started')->with(compact('gettingStarted')); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Show the statistics screen to the user. |
|
67 | - * |
|
68 | - * @return Response |
|
69 | - */ |
|
70 | - public function statistics(Statistics $statistics) |
|
71 | - { |
|
72 | - $pokes_total = $statistics->totalPokes(); |
|
65 | + /** |
|
66 | + * Show the statistics screen to the user. |
|
67 | + * |
|
68 | + * @return Response |
|
69 | + */ |
|
70 | + public function statistics(Statistics $statistics) |
|
71 | + { |
|
72 | + $pokes_total = $statistics->totalPokes(); |
|
73 | 73 | |
74 | - $devices_total = $statistics->totalDevices(); |
|
74 | + $devices_total = $statistics->totalDevices(); |
|
75 | 75 | |
76 | - $pokes = $statistics->allPokes()->toArray(); |
|
76 | + $pokes = $statistics->allPokes()->toArray(); |
|
77 | 77 | |
78 | - $network_distribution = $statistics->networkDistribution()->toArray(); |
|
78 | + $network_distribution = $statistics->networkDistribution()->toArray(); |
|
79 | 79 | |
80 | - JavaScript::put(compact('pokes', 'network_distribution')); |
|
80 | + JavaScript::put(compact('pokes', 'network_distribution')); |
|
81 | 81 | |
82 | - return view('statistics')->with(compact('pokes_total', 'devices_total')); |
|
83 | - } |
|
82 | + return view('statistics')->with(compact('pokes_total', 'devices_total')); |
|
83 | + } |
|
84 | 84 | } |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class EventServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * The event handler mappings for the application. |
|
11 | - * |
|
12 | - * @var array |
|
13 | - */ |
|
14 | - protected $listen = [ |
|
15 | - 'PiFinder\Events\ServerWasPoked' => [ |
|
16 | - 'PiFinder\Handlers\Events\NotifyUsersAboutPoke', |
|
17 | - 'PiFinder\Handlers\Events\UpdateStatistics', |
|
18 | - ], |
|
19 | - ]; |
|
9 | + /** |
|
10 | + * The event handler mappings for the application. |
|
11 | + * |
|
12 | + * @var array |
|
13 | + */ |
|
14 | + protected $listen = [ |
|
15 | + 'PiFinder\Events\ServerWasPoked' => [ |
|
16 | + 'PiFinder\Handlers\Events\NotifyUsersAboutPoke', |
|
17 | + 'PiFinder\Handlers\Events\UpdateStatistics', |
|
18 | + ], |
|
19 | + ]; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Register any other events for your application. |
|
23 | - * |
|
24 | - * @param \Illuminate\Contracts\Events\Dispatcher $events |
|
25 | - */ |
|
26 | - public function boot() |
|
27 | - { |
|
28 | - parent::boot(); |
|
21 | + /** |
|
22 | + * Register any other events for your application. |
|
23 | + * |
|
24 | + * @param \Illuminate\Contracts\Events\Dispatcher $events |
|
25 | + */ |
|
26 | + public function boot() |
|
27 | + { |
|
28 | + parent::boot(); |
|
29 | 29 | |
30 | - // |
|
31 | - } |
|
30 | + // |
|
31 | + } |
|
32 | 32 | } |
@@ -8,61 +8,61 @@ |
||
8 | 8 | |
9 | 9 | class Handler extends ExceptionHandler |
10 | 10 | { |
11 | - /** |
|
12 | - * A list of the exception types that should not be reported. |
|
13 | - * |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $dontReport = [ |
|
17 | - \Illuminate\Auth\AuthenticationException::class, |
|
18 | - \Illuminate\Auth\Access\AuthorizationException::class, |
|
19 | - \Symfony\Component\HttpKernel\Exception\HttpException::class, |
|
20 | - \Illuminate\Database\Eloquent\ModelNotFoundException::class, |
|
21 | - \Illuminate\Session\TokenMismatchException::class, |
|
22 | - \Illuminate\Validation\ValidationException::class, |
|
23 | - ]; |
|
11 | + /** |
|
12 | + * A list of the exception types that should not be reported. |
|
13 | + * |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $dontReport = [ |
|
17 | + \Illuminate\Auth\AuthenticationException::class, |
|
18 | + \Illuminate\Auth\Access\AuthorizationException::class, |
|
19 | + \Symfony\Component\HttpKernel\Exception\HttpException::class, |
|
20 | + \Illuminate\Database\Eloquent\ModelNotFoundException::class, |
|
21 | + \Illuminate\Session\TokenMismatchException::class, |
|
22 | + \Illuminate\Validation\ValidationException::class, |
|
23 | + ]; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Report or log an exception. |
|
27 | - * |
|
28 | - * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|
29 | - * |
|
30 | - * @param \Exception $exception |
|
31 | - * |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public function report(Exception $exception) |
|
35 | - { |
|
36 | - parent::report($exception); |
|
37 | - } |
|
25 | + /** |
|
26 | + * Report or log an exception. |
|
27 | + * |
|
28 | + * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|
29 | + * |
|
30 | + * @param \Exception $exception |
|
31 | + * |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public function report(Exception $exception) |
|
35 | + { |
|
36 | + parent::report($exception); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Render an exception into an HTTP response. |
|
41 | - * |
|
42 | - * @param \Illuminate\Http\Request $request |
|
43 | - * @param \Exception $exception |
|
44 | - * |
|
45 | - * @return \Illuminate\Http\Response |
|
46 | - */ |
|
47 | - public function render($request, Exception $exception) |
|
48 | - { |
|
49 | - return parent::render($request, $exception); |
|
50 | - } |
|
39 | + /** |
|
40 | + * Render an exception into an HTTP response. |
|
41 | + * |
|
42 | + * @param \Illuminate\Http\Request $request |
|
43 | + * @param \Exception $exception |
|
44 | + * |
|
45 | + * @return \Illuminate\Http\Response |
|
46 | + */ |
|
47 | + public function render($request, Exception $exception) |
|
48 | + { |
|
49 | + return parent::render($request, $exception); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Convert an authentication exception into an unauthenticated response. |
|
54 | - * |
|
55 | - * @param \Illuminate\Http\Request $request |
|
56 | - * @param \Illuminate\Auth\AuthenticationException $exception |
|
57 | - * |
|
58 | - * @return \Illuminate\Http\Response |
|
59 | - */ |
|
60 | - protected function unauthenticated($request, AuthenticationException $exception) |
|
61 | - { |
|
62 | - if ($request->expectsJson()) { |
|
63 | - return response()->json(['error' => 'Unauthenticated.'], 401); |
|
64 | - } |
|
52 | + /** |
|
53 | + * Convert an authentication exception into an unauthenticated response. |
|
54 | + * |
|
55 | + * @param \Illuminate\Http\Request $request |
|
56 | + * @param \Illuminate\Auth\AuthenticationException $exception |
|
57 | + * |
|
58 | + * @return \Illuminate\Http\Response |
|
59 | + */ |
|
60 | + protected function unauthenticated($request, AuthenticationException $exception) |
|
61 | + { |
|
62 | + if ($request->expectsJson()) { |
|
63 | + return response()->json(['error' => 'Unauthenticated.'], 401); |
|
64 | + } |
|
65 | 65 | |
66 | - return redirect()->guest('login'); |
|
67 | - } |
|
66 | + return redirect()->guest('login'); |
|
67 | + } |
|
68 | 68 | } |