@@ -8,52 +8,52 @@ |
||
8 | 8 | |
9 | 9 | class NotifyUsersAboutPoke |
10 | 10 | { |
11 | - /** |
|
12 | - * The Pusher instance. |
|
13 | - * |
|
14 | - * @var PusherManager |
|
15 | - */ |
|
16 | - protected $pusher; |
|
17 | - |
|
18 | - /** |
|
19 | - * @var DeviceTransformer |
|
20 | - */ |
|
21 | - private $transformer; |
|
22 | - |
|
23 | - /** |
|
24 | - * Create the event handler. |
|
25 | - * |
|
26 | - * @param PusherManager $pusher |
|
27 | - * @param DeviceTransformer $transformer |
|
28 | - */ |
|
29 | - public function __construct(PusherManager $pusher, DeviceTransformer $transformer) |
|
30 | - { |
|
31 | - $this->pusher = $pusher; |
|
32 | - $this->transformer = $transformer; |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * Handle the server was poked event. |
|
37 | - * |
|
38 | - * @param ServerWasPoked $event |
|
39 | - * |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function handle(ServerWasPoked $event) |
|
43 | - { |
|
44 | - $channel = env('PUSHER_CHANNEL', 'pi-finder'); |
|
45 | - $device = $event->getDevice(); |
|
46 | - |
|
47 | - if ($device->isPublic()) { |
|
48 | - $this->pusher->trigger($channel, 'ServerWasPoked', [ |
|
49 | - 'device' => $this->transformer->transform($device), |
|
50 | - ]); |
|
51 | - } else { |
|
52 | - $channel = $channel.'-'.$device->group; |
|
53 | - |
|
54 | - $this->pusher->trigger($channel, 'ServerWasPoked', [ |
|
55 | - 'device' => $this->transformer->transform($device), |
|
56 | - ]); |
|
57 | - } |
|
58 | - } |
|
11 | + /** |
|
12 | + * The Pusher instance. |
|
13 | + * |
|
14 | + * @var PusherManager |
|
15 | + */ |
|
16 | + protected $pusher; |
|
17 | + |
|
18 | + /** |
|
19 | + * @var DeviceTransformer |
|
20 | + */ |
|
21 | + private $transformer; |
|
22 | + |
|
23 | + /** |
|
24 | + * Create the event handler. |
|
25 | + * |
|
26 | + * @param PusherManager $pusher |
|
27 | + * @param DeviceTransformer $transformer |
|
28 | + */ |
|
29 | + public function __construct(PusherManager $pusher, DeviceTransformer $transformer) |
|
30 | + { |
|
31 | + $this->pusher = $pusher; |
|
32 | + $this->transformer = $transformer; |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * Handle the server was poked event. |
|
37 | + * |
|
38 | + * @param ServerWasPoked $event |
|
39 | + * |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function handle(ServerWasPoked $event) |
|
43 | + { |
|
44 | + $channel = env('PUSHER_CHANNEL', 'pi-finder'); |
|
45 | + $device = $event->getDevice(); |
|
46 | + |
|
47 | + if ($device->isPublic()) { |
|
48 | + $this->pusher->trigger($channel, 'ServerWasPoked', [ |
|
49 | + 'device' => $this->transformer->transform($device), |
|
50 | + ]); |
|
51 | + } else { |
|
52 | + $channel = $channel.'-'.$device->group; |
|
53 | + |
|
54 | + $this->pusher->trigger($channel, 'ServerWasPoked', [ |
|
55 | + 'device' => $this->transformer->transform($device), |
|
56 | + ]); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | } |
@@ -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 | } |
@@ -7,32 +7,32 @@ |
||
7 | 7 | |
8 | 8 | class DeviceObserver |
9 | 9 | { |
10 | - /** |
|
11 | - * @var PusherManager |
|
12 | - */ |
|
13 | - protected $pusher; |
|
10 | + /** |
|
11 | + * @var PusherManager |
|
12 | + */ |
|
13 | + protected $pusher; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @var DeviceTransformer |
|
17 | - */ |
|
18 | - private $transformer; |
|
15 | + /** |
|
16 | + * @var DeviceTransformer |
|
17 | + */ |
|
18 | + private $transformer; |
|
19 | 19 | |
20 | - /** |
|
21 | - * DeviceObserver constructor. |
|
22 | - * |
|
23 | - * @param PusherManager $pusher |
|
24 | - * @param DeviceTransformer $transformer |
|
25 | - */ |
|
26 | - public function __construct(PusherManager $pusher, DeviceTransformer $transformer) |
|
27 | - { |
|
28 | - $this->pusher = $pusher; |
|
29 | - $this->transformer = $transformer; |
|
30 | - } |
|
20 | + /** |
|
21 | + * DeviceObserver constructor. |
|
22 | + * |
|
23 | + * @param PusherManager $pusher |
|
24 | + * @param DeviceTransformer $transformer |
|
25 | + */ |
|
26 | + public function __construct(PusherManager $pusher, DeviceTransformer $transformer) |
|
27 | + { |
|
28 | + $this->pusher = $pusher; |
|
29 | + $this->transformer = $transformer; |
|
30 | + } |
|
31 | 31 | |
32 | - public function deleted($device) |
|
33 | - { |
|
34 | - $this->pusher->trigger(env('PUSHER_CHANNEL', 'pi-finder'), 'DeviceWasDeleted', [ |
|
35 | - 'device' => $this->transformer->transform($device), |
|
36 | - ]); |
|
37 | - } |
|
32 | + public function deleted($device) |
|
33 | + { |
|
34 | + $this->pusher->trigger(env('PUSHER_CHANNEL', 'pi-finder'), 'DeviceWasDeleted', [ |
|
35 | + 'device' => $this->transformer->transform($device), |
|
36 | + ]); |
|
37 | + } |
|
38 | 38 | } |
@@ -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 | } |
@@ -7,26 +7,26 @@ |
||
7 | 7 | |
8 | 8 | class AuthServiceProvider extends ServiceProvider |
9 | 9 | { |
10 | - /** |
|
11 | - * The policy mappings for the application. |
|
12 | - * |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - protected $policies = [ |
|
16 | - 'App\Model' => 'App\Policies\ModelPolicy', |
|
17 | - ]; |
|
10 | + /** |
|
11 | + * The policy mappings for the application. |
|
12 | + * |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + protected $policies = [ |
|
16 | + 'App\Model' => 'App\Policies\ModelPolicy', |
|
17 | + ]; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Register any application authentication / authorization services. |
|
21 | - * |
|
22 | - * @param \Illuminate\Contracts\Auth\Access\Gate $gate |
|
23 | - * |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function boot(GateContract $gate) |
|
27 | - { |
|
28 | - $this->registerPolicies($gate); |
|
19 | + /** |
|
20 | + * Register any application authentication / authorization services. |
|
21 | + * |
|
22 | + * @param \Illuminate\Contracts\Auth\Access\Gate $gate |
|
23 | + * |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function boot(GateContract $gate) |
|
27 | + { |
|
28 | + $this->registerPolicies($gate); |
|
29 | 29 | |
30 | - // |
|
31 | - } |
|
30 | + // |
|
31 | + } |
|
32 | 32 | } |
@@ -12,26 +12,26 @@ |
||
12 | 12 | |
13 | 13 | class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract |
14 | 14 | { |
15 | - use Authenticatable, Authorizable, CanResetPassword; |
|
15 | + use Authenticatable, Authorizable, CanResetPassword; |
|
16 | 16 | |
17 | - /** |
|
18 | - * The database table used by the model. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $table = 'users'; |
|
17 | + /** |
|
18 | + * The database table used by the model. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $table = 'users'; |
|
23 | 23 | |
24 | - /** |
|
25 | - * The attributes that are mass assignable. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $fillable = ['email', 'password']; |
|
24 | + /** |
|
25 | + * The attributes that are mass assignable. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $fillable = ['email', 'password']; |
|
30 | 30 | |
31 | - /** |
|
32 | - * The attributes excluded from the model's JSON form. |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - protected $hidden = ['password', 'remember_token']; |
|
31 | + /** |
|
32 | + * The attributes excluded from the model's JSON form. |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + protected $hidden = ['password', 'remember_token']; |
|
37 | 37 | } |
@@ -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 | } |