-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add is_disabled tu schools table * fix code style * remove unused routes * add disable school route * update school resource * fix code style * implement school enabling * hide disabled schools in select school input * fix user test * create school for admins * fix code style * fix code style * fix test * remove randomness from school test
- Loading branch information
1 parent
e014f9f
commit 177a04a
Showing
28 changed files
with
457 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Policies; | ||
|
||
use App\Models\School; | ||
use App\Models\User; | ||
|
||
class SchoolPolicy | ||
{ | ||
public function update(User $user, School $school): bool | ||
{ | ||
return !$school->is_admin_school && !$school->is_disabled; | ||
} | ||
|
||
public function delete(User $user, School $school): bool | ||
{ | ||
return $school->users()->count() === 0 && !$school->is_disabled && !$school->is_admin_school; | ||
} | ||
|
||
public function disable(User $user, School $school): bool | ||
{ | ||
return !$school->is_disabled && !$school->is_admin_school; | ||
} | ||
|
||
public function enable(User $user, School $school): bool | ||
{ | ||
return $school->is_disabled && !$school->is_admin_school; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Rules; | ||
|
||
use App\Models\School; | ||
use Closure; | ||
use Illuminate\Contracts\Validation\ValidationRule; | ||
use Illuminate\Support\Facades\Lang; | ||
|
||
class IsSchoolValidForRegularUsers implements ValidationRule | ||
{ | ||
public function validate(string $attribute, mixed $value, Closure $fail): void | ||
{ | ||
$school = School::query()->find($value); | ||
|
||
if (!$school) { | ||
return; | ||
} | ||
|
||
if ($school->is_disabled | $school->is_admin_school) { | ||
$fail(Lang::get("validation.custom.school_id.exists")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,20 @@ class AdminSeeder extends Seeder | |
{ | ||
public function run(): void | ||
{ | ||
$school = School::firstOrCreate( | ||
["is_admin_school" => true], | ||
[ | ||
"name" => "Admin school", | ||
"regon" => "", | ||
"city" => "", | ||
"street" => "", | ||
"building_number" => "", | ||
"zip_code" => "", | ||
"is_disabled" => true, | ||
"is_admin_school" => true, | ||
], | ||
); | ||
|
||
$superAdmin = User::firstOrCreate( | ||
["email" => "[email protected]"], | ||
[ | ||
|
@@ -23,7 +37,7 @@ public function run(): void | |
"email_verified_at" => Carbon::now(), | ||
"password" => Hash::make("password"), | ||
"remember_token" => Str::random(10), | ||
"school_id" => School::factory()->create()->id, | ||
"school_id" => $school->id, | ||
], | ||
); | ||
$superAdmin->syncRoles("super_admin"); | ||
|
@@ -36,7 +50,7 @@ public function run(): void | |
"email_verified_at" => Carbon::now(), | ||
"password" => Hash::make("password"), | ||
"remember_token" => Str::random(10), | ||
"school_id" => School::factory()->create()->id, | ||
"school_id" => $school->id, | ||
], | ||
); | ||
$admin->syncRoles("admin"); | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.