Completed
Pull Request — master (#10)
by Manuel
02:47
created
app/Services/Registrar.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -8,33 +8,33 @@
 block discarded – undo
8 8
 
9 9
 class Registrar implements RegistrarContract
10 10
 {
11
-    /**
12
-     * Get a validator for an incoming registration request.
13
-     *
14
-     * @param array $data
15
-     *
16
-     * @return \Illuminate\Contracts\Validation\Validator
17
-     */
18
-    public function validator(array $data)
19
-    {
20
-        return Validator::make($data, [
21
-            'email'    => 'required|email|max:255|unique:users',
22
-            'password' => 'required|confirmed|min:6',
23
-        ]);
24
-    }
11
+	/**
12
+	 * Get a validator for an incoming registration request.
13
+	 *
14
+	 * @param array $data
15
+	 *
16
+	 * @return \Illuminate\Contracts\Validation\Validator
17
+	 */
18
+	public function validator(array $data)
19
+	{
20
+		return Validator::make($data, [
21
+			'email'    => 'required|email|max:255|unique:users',
22
+			'password' => 'required|confirmed|min:6',
23
+		]);
24
+	}
25 25
 
26
-    /**
27
-     * Create a new user instance after a valid registration.
28
-     *
29
-     * @param array $data
30
-     *
31
-     * @return User
32
-     */
33
-    public function create(array $data)
34
-    {
35
-        return User::create([
36
-            'email'    => $data['email'],
37
-            'password' => bcrypt($data['password']),
38
-        ]);
39
-    }
26
+	/**
27
+	 * Create a new user instance after a valid registration.
28
+	 *
29
+	 * @param array $data
30
+	 *
31
+	 * @return User
32
+	 */
33
+	public function create(array $data)
34
+	{
35
+		return User::create([
36
+			'email'    => $data['email'],
37
+			'password' => bcrypt($data['password']),
38
+		]);
39
+	}
40 40
 }
Please login to merge, or discard this patch.
app/Transformers/Transformer.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
app/User.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,26 +10,26 @@
 block discarded – undo
10 10
 
11 11
 class User extends Model implements AuthenticatableContract, CanResetPasswordContract
12 12
 {
13
-    use Authenticatable, CanResetPassword;
13
+	use Authenticatable, CanResetPassword;
14 14
 
15
-    /**
16
-     * The database table used by the model.
17
-     *
18
-     * @var string
19
-     */
20
-    protected $table = 'users';
15
+	/**
16
+	 * The database table used by the model.
17
+	 *
18
+	 * @var string
19
+	 */
20
+	protected $table = 'users';
21 21
 
22
-    /**
23
-     * The attributes that are mass assignable.
24
-     *
25
-     * @var array
26
-     */
27
-    protected $fillable = ['email', 'password'];
22
+	/**
23
+	 * The attributes that are mass assignable.
24
+	 *
25
+	 * @var array
26
+	 */
27
+	protected $fillable = ['email', 'password'];
28 28
 
29
-    /**
30
-     * The attributes excluded from the model's JSON form.
31
-     *
32
-     * @var array
33
-     */
34
-    protected $hidden = ['password', 'remember_token'];
29
+	/**
30
+	 * The attributes excluded from the model's JSON form.
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected $hidden = ['password', 'remember_token'];
35 35
 }
Please login to merge, or discard this patch.
app/Commands/Command.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,5 +4,5 @@
 block discarded – undo
4 4
 
5 5
 abstract class Event
6 6
 {
7
-    //
7
+	//
8 8
 }
Please login to merge, or discard this patch.
app/Http/Controllers/Api/DeviceController.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -10,137 +10,137 @@
 block discarded – undo
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
-     * @return Response
30
-     */
31
-    public function index($group = null)
32
-    {
33
-        $devices = $group ? Device::where('group', $group)->get() : Device::onHomePage()->get();
34
-
35
-        return $this->respond([
36
-            'data'        => $this->transformer->transformCollection($devices->all()),
37
-            'server_time' => Carbon::now()->toIso8601String(),
38
-        ]);
39
-    }
40
-
41
-    /**
42
-     * Store a newly created resource in storage.
43
-     *
44
-     * @param StoreComputerRequest $request
45
-     *
46
-     * @return Response
47
-     */
48
-    public function store(StoreComputerRequest $request)
49
-    {
50
-        $device = Device::create($request->all());
51
-
52
-        $device->public = $request->get('public', 'auto');
53
-
54
-        return $this->respondCreated($this->transformer->transform($device), $device->id);
55
-    }
56
-
57
-    /**
58
-     * Display the specified resource.
59
-     *
60
-     * @param int $id
61
-     *
62
-     * @return Response
63
-     */
64
-    public function show($id)
65
-    {
66
-        $device = Device::find($id);
67
-
68
-        if (!$device) {
69
-            return $this->respondNotFound('Did not find the device you are looking for!');
70
-        }
71
-
72
-        return $this->respond([
73
-            'data' => $this->transformer->transform($device),
74
-        ]);
75
-    }
76
-
77
-    /**
78
-     * Update the specified resource in storage.
79
-     *
80
-     * @param StoreComputerRequest $request
81
-     * @param int                  $id
82
-     *
83
-     * @return Response
84
-     */
85
-    public function update(StoreComputerRequest $request, $id)
86
-    {
87
-        $device = Device::find($id);
88
-
89
-        if (!$device) {
90
-            return $this->respondNotFound('Did not find the device you are looking for!');
91
-        }
92
-
93
-        $device = $device->fill($request->all());
94
-
95
-        $device->save();
96
-
97
-        return $this->respond([
98
-            'data' => $this->transformer->transform($device),
99
-        ]);
100
-    }
101
-
102
-    /**
103
-     * Remove the specified resource from storage.
104
-     *
105
-     * @param int $id
106
-     *
107
-     * @return Response
108
-     */
109
-    public function destroy($id)
110
-    {
111
-        $device = Device::find($id);
112
-
113
-        if (!$device) {
114
-            return $this->respondNotFound('Did not find the device you are looking for!');
115
-        }
116
-
117
-        $device->delete();
118
-
119
-        return $this->respondNoContent();
120
-    }
121
-
122
-    /**
123
-     * Handle device pokes.
124
-     *
125
-     * @param StoreComputerRequest $request
126
-     *
127
-     * @throws \Exception
128
-     *
129
-     * @return Response
130
-     */
131
-    public function poke(StoreComputerRequest $request)
132
-    {
133
-        $device = Device::firstOrNew(['mac' => $request->mac]);
134
-
135
-        $device->fill($request->all());
136
-
137
-        $device->group = $request->get('group', null);
138
-        $device->public = $request->get('public', 'auto');
139
-
140
-        $device->touch();
141
-
142
-        event(new ServerWasPoked(array_add($device, 'server_time', Carbon::now()->toDateTimeString())));
143
-
144
-        return $this->respondPoked($this->transformer->transform($device), $device->id);
145
-    }
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
+	 * @return Response
30
+	 */
31
+	public function index($group = null)
32
+	{
33
+		$devices = $group ? Device::where('group', $group)->get() : Device::onHomePage()->get();
34
+
35
+		return $this->respond([
36
+			'data'        => $this->transformer->transformCollection($devices->all()),
37
+			'server_time' => Carbon::now()->toIso8601String(),
38
+		]);
39
+	}
40
+
41
+	/**
42
+	 * Store a newly created resource in storage.
43
+	 *
44
+	 * @param StoreComputerRequest $request
45
+	 *
46
+	 * @return Response
47
+	 */
48
+	public function store(StoreComputerRequest $request)
49
+	{
50
+		$device = Device::create($request->all());
51
+
52
+		$device->public = $request->get('public', 'auto');
53
+
54
+		return $this->respondCreated($this->transformer->transform($device), $device->id);
55
+	}
56
+
57
+	/**
58
+	 * Display the specified resource.
59
+	 *
60
+	 * @param int $id
61
+	 *
62
+	 * @return Response
63
+	 */
64
+	public function show($id)
65
+	{
66
+		$device = Device::find($id);
67
+
68
+		if (!$device) {
69
+			return $this->respondNotFound('Did not find the device you are looking for!');
70
+		}
71
+
72
+		return $this->respond([
73
+			'data' => $this->transformer->transform($device),
74
+		]);
75
+	}
76
+
77
+	/**
78
+	 * Update the specified resource in storage.
79
+	 *
80
+	 * @param StoreComputerRequest $request
81
+	 * @param int                  $id
82
+	 *
83
+	 * @return Response
84
+	 */
85
+	public function update(StoreComputerRequest $request, $id)
86
+	{
87
+		$device = Device::find($id);
88
+
89
+		if (!$device) {
90
+			return $this->respondNotFound('Did not find the device you are looking for!');
91
+		}
92
+
93
+		$device = $device->fill($request->all());
94
+
95
+		$device->save();
96
+
97
+		return $this->respond([
98
+			'data' => $this->transformer->transform($device),
99
+		]);
100
+	}
101
+
102
+	/**
103
+	 * Remove the specified resource from storage.
104
+	 *
105
+	 * @param int $id
106
+	 *
107
+	 * @return Response
108
+	 */
109
+	public function destroy($id)
110
+	{
111
+		$device = Device::find($id);
112
+
113
+		if (!$device) {
114
+			return $this->respondNotFound('Did not find the device you are looking for!');
115
+		}
116
+
117
+		$device->delete();
118
+
119
+		return $this->respondNoContent();
120
+	}
121
+
122
+	/**
123
+	 * Handle device pokes.
124
+	 *
125
+	 * @param StoreComputerRequest $request
126
+	 *
127
+	 * @throws \Exception
128
+	 *
129
+	 * @return Response
130
+	 */
131
+	public function poke(StoreComputerRequest $request)
132
+	{
133
+		$device = Device::firstOrNew(['mac' => $request->mac]);
134
+
135
+		$device->fill($request->all());
136
+
137
+		$device->group = $request->get('group', null);
138
+		$device->public = $request->get('public', 'auto');
139
+
140
+		$device->touch();
141
+
142
+		event(new ServerWasPoked(array_add($device, 'server_time', Carbon::now()->toDateTimeString())));
143
+
144
+		return $this->respondPoked($this->transformer->transform($device), $device->id);
145
+	}
146 146
 }
Please login to merge, or discard this patch.
app/Observers/DeviceObserver.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,31 +7,31 @@
 block discarded – undo
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
-     * @param PusherManager $pusher
23
-     * @param DeviceTransformer $transformer
24
-     */
25
-    public function __construct(PusherManager $pusher, DeviceTransformer $transformer)
26
-    {
27
-        $this->pusher = $pusher;
28
-        $this->transformer = $transformer;
29
-    }
20
+	/**
21
+	 * DeviceObserver constructor.
22
+	 * @param PusherManager $pusher
23
+	 * @param DeviceTransformer $transformer
24
+	 */
25
+	public function __construct(PusherManager $pusher, DeviceTransformer $transformer)
26
+	{
27
+		$this->pusher = $pusher;
28
+		$this->transformer = $transformer;
29
+	}
30 30
 
31
-    public function deleted($device)
32
-    {
33
-        $this->pusher->trigger(env('PUSHER_CHANNEL', 'pi-finder'), 'DeviceWasDeleted', [
34
-            'device' => $this->transformer->transform($device),
35
-        ]);
36
-    }
31
+	public function deleted($device)
32
+	{
33
+		$this->pusher->trigger(env('PUSHER_CHANNEL', 'pi-finder'), 'DeviceWasDeleted', [
34
+			'device' => $this->transformer->transform($device),
35
+		]);
36
+	}
37 37
 }
Please login to merge, or discard this patch.
app/Transformers/DeviceTransformer.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.