-
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.
- Loading branch information
1 parent
8c10026
commit 9df27fe
Showing
13 changed files
with
101 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Actions; | ||
|
||
use App\Models\Semester; | ||
use Exception; | ||
use Illuminate\Database\ConnectionInterface; | ||
|
||
class ActivateSemesterAction | ||
{ | ||
public function __construct( | ||
protected ConnectionInterface $db, | ||
) {} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function execute(Semester $semester): void | ||
{ | ||
try { | ||
$this->db->beginTransaction(); | ||
|
||
Semester::getActive()?->update(["active" => 0]); | ||
$semester->update(["active" => 1]); | ||
|
||
$this->db->commit(); | ||
} catch (Exception $exception) { | ||
$this->db->rollBack(); | ||
|
||
throw $exception; | ||
} | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Enums; | ||
|
||
enum Semester: string | ||
{ | ||
case FIRST = "I"; | ||
case SECOND = "II"; | ||
case THIRD = "III"; | ||
case FOURTH = "IV"; | ||
case FIFTH = "V"; | ||
case SIXTH = "VI"; | ||
case SEVENTH = "VII"; | ||
case EIGHTH = "VIII"; | ||
case NINTH = "IX"; | ||
case TENTH = "X"; | ||
|
||
public static function labels(): array | ||
{ | ||
return [ | ||
"I" => __("I"), | ||
"II" => __("II"), | ||
"III" => __("III"), | ||
"IV" => __("IV"), | ||
"V" => __("V"), | ||
"VI" => __("VI"), | ||
"VII" => __("VII"), | ||
"VIII" => __("VIII"), | ||
"IX" => __("IX"), | ||
"X" => __("X"), | ||
]; | ||
} | ||
} |
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
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