Skip to content

Commit aeda64d

Browse files
committed
Add ordered_class_elements rule to code standard
1 parent de82584 commit aeda64d

File tree

3 files changed

+56
-55
lines changed

3 files changed

+56
-55
lines changed

.php_cs

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ $rules = [
6262
'normalize_index_brace' => true,
6363
'not_operator_with_successor_space' => true,
6464
'object_operator_without_whitespace' => true,
65+
'ordered_class_elements' => true,
6566
'ordered_imports' => ['sortAlgorithm' => 'length'],
6667
'phpdoc_align' => true,
6768
'phpdoc_indent' => true,

app/Http/Controllers/Auth/RegisterController.php

+41-41
Original file line numberDiff line numberDiff line change
@@ -46,47 +46,6 @@ public function __construct()
4646
->only(['confirm', 'resendConfirmationEmail']);
4747
}
4848

49-
/**
50-
* Get a validator for an incoming registration request.
51-
*
52-
* @param array $data
53-
*
54-
* @return \Illuminate\Contracts\Validation\Validator
55-
*/
56-
protected function validator(array $data)
57-
{
58-
return Validator::make($data, [
59-
'name' => 'required|string|max:255',
60-
'student_number' => 'required|string|unique:students,student_number|student_number',
61-
'password' => 'required|string|min:6|confirmed',
62-
]);
63-
}
64-
65-
/**
66-
* Create a new user instance after a valid registration.
67-
*
68-
* @param array $data
69-
*
70-
* @return \App\Judite\Models\User
71-
*/
72-
protected function create(array $data)
73-
{
74-
$user = DB::transaction(function () use ($data) {
75-
$user = User::make([
76-
'name' => $data['name'],
77-
'email' => $data['student_number'].'@alunos.uminho.pt',
78-
'password' => bcrypt($data['password']),
79-
]);
80-
$user->verification_token = str_random(32);
81-
$user->save();
82-
$user->student()->create(['student_number' => $data['student_number']]);
83-
84-
return $user;
85-
});
86-
87-
return $user;
88-
}
89-
9049
/**
9150
* Confirm a student account.
9251
*
@@ -133,6 +92,47 @@ public function resendConfirmationEmail()
13392
return redirect($this->redirectTo);
13493
}
13594

95+
/**
96+
* Get a validator for an incoming registration request.
97+
*
98+
* @param array $data
99+
*
100+
* @return \Illuminate\Contracts\Validation\Validator
101+
*/
102+
protected function validator(array $data)
103+
{
104+
return Validator::make($data, [
105+
'name' => 'required|string|max:255',
106+
'student_number' => 'required|string|unique:students,student_number|student_number',
107+
'password' => 'required|string|min:6|confirmed',
108+
]);
109+
}
110+
111+
/**
112+
* Create a new user instance after a valid registration.
113+
*
114+
* @param array $data
115+
*
116+
* @return \App\Judite\Models\User
117+
*/
118+
protected function create(array $data)
119+
{
120+
$user = DB::transaction(function () use ($data) {
121+
$user = User::make([
122+
'name' => $data['name'],
123+
'email' => $data['student_number'].'@alunos.uminho.pt',
124+
'password' => bcrypt($data['password']),
125+
]);
126+
$user->verification_token = str_random(32);
127+
$user->save();
128+
$user->student()->create(['student_number' => $data['student_number']]);
129+
130+
return $user;
131+
});
132+
133+
return $user;
134+
}
135+
136136
/**
137137
* The user has been registered.
138138
*

app/Judite/Models/Exchange.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,6 @@ public function toEnrollment()
182182
return $this->belongsTo(Enrollment::class, 'to_enrollment_id');
183183
}
184184

185-
/**
186-
* Deletes all exchanges involving the given enrollments.
187-
*
188-
* @param \Illuminate\Support\Collection $enrollments
189-
*/
190-
private function deleteExchangesOfEnrollments(Collection $enrollments)
191-
{
192-
$enrollmentIds = $enrollments->pluck('id');
193-
194-
self::whereIn('from_enrollment_id', $enrollmentIds)
195-
->orWhereIn('to_enrollment_id', $enrollmentIds)
196-
->delete();
197-
}
198-
199185
/**
200186
* Get the course of this exchange.
201187
*
@@ -257,4 +243,18 @@ public function isOwnedBy(Student $student): bool
257243
{
258244
return $this->fromStudent()->is($student);
259245
}
246+
247+
/**
248+
* Deletes all exchanges involving the given enrollments.
249+
*
250+
* @param \Illuminate\Support\Collection $enrollments
251+
*/
252+
private function deleteExchangesOfEnrollments(Collection $enrollments)
253+
{
254+
$enrollmentIds = $enrollments->pluck('id');
255+
256+
self::whereIn('from_enrollment_id', $enrollmentIds)
257+
->orWhereIn('to_enrollment_id', $enrollmentIds)
258+
->delete();
259+
}
260260
}

0 commit comments

Comments
 (0)