Last active
November 4, 2022 04:37
-
-
Save JoshuaDoshua/2815e101c0735ac9b833207ffce9ca8e to your computer and use it in GitHub Desktop.
Weekday FlaggedEnum for BemSampo/Laravel-Enum
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
<?php | |
namespace App\Enums; | |
use BenSampo\Enum\FlaggedEnum; | |
final class Day extends FlaggedEnum | |
{ | |
const Monday = 1 << 0; | |
const Tuesday = 1 << 1; | |
const Wednesday = 1 << 2; | |
const Thursday = 1 << 3; | |
const Friday = 1 << 4; | |
const Saturday = 1 << 5; | |
const Sunday = 1 << 6; | |
// Shortcuts | |
const Weekdays = self::Monday | self::Tuesday | self::Wednesday | self::Thursday | self::Friday; | |
const Weekend = self::Saturday | self::Sunday; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Allows for storing multiple days in a single database column. (
$table->unsignedTinyInteger('day');
should suffice)