-
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
9cfb370
commit 744b8b2
Showing
26 changed files
with
850 additions
and
289 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace App\Enums\User; | ||
|
||
enum Role: string | ||
{ | ||
case SUPER_ADMINISTRATOR = 'super_administrator'; | ||
case ADMINISTRATOR = 'administrator'; | ||
case TECHNICIAN = 'technician'; | ||
|
||
public static function toArray(): array | ||
{ | ||
return [ | ||
self::SUPER_ADMINISTRATOR, | ||
self::ADMINISTRATOR, | ||
self::TECHNICIAN, | ||
]; | ||
} | ||
|
||
public static function labels(): array | ||
{ | ||
return [ | ||
self::SUPER_ADMINISTRATOR->label(), | ||
self::ADMINISTRATOR->label(), | ||
self::TECHNICIAN->label(), | ||
]; | ||
} | ||
|
||
public static function values(): array | ||
{ | ||
return [ | ||
self::SUPER_ADMINISTRATOR->value, | ||
self::ADMINISTRATOR->value, | ||
self::TECHNICIAN->value, | ||
]; | ||
} | ||
|
||
public static function labelAndValues(): array | ||
{ | ||
return [ | ||
['label' => self::SUPER_ADMINISTRATOR->label(), 'value' => self::SUPER_ADMINISTRATOR->value], | ||
['label' => self::ADMINISTRATOR->label(), 'value' => self::ADMINISTRATOR->value], | ||
['label' => self::TECHNICIAN->label(), 'value' => self::TECHNICIAN->value], | ||
]; | ||
} | ||
|
||
public function label(): string | ||
{ | ||
return match ($this) { | ||
self::SUPER_ADMINISTRATOR => 'Super Administrator', | ||
self::ADMINISTRATOR => 'Administrator', | ||
self::TECHNICIAN => 'Technician', | ||
}; | ||
} | ||
|
||
public function description(): string | ||
{ | ||
return match ($this) { | ||
self::SUPER_ADMINISTRATOR => 'Super Administrator has all permissions.', | ||
self::ADMINISTRATOR => 'Administrator has all permissions except for managing roles and permissions.', | ||
self::TECHNICIAN => 'Technician has limited permissions.', | ||
}; | ||
} | ||
} |
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,77 @@ | ||
<?php | ||
|
||
namespace App\Exports; | ||
|
||
use App\Livewire\Device\Index; | ||
use Illuminate\Support\Collection; | ||
use Maatwebsite\Excel\Concerns\Exportable; | ||
use Maatwebsite\Excel\Concerns\FromCollection; | ||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; | ||
use Maatwebsite\Excel\Concerns\WithColumnFormatting; | ||
use Maatwebsite\Excel\Concerns\WithHeadings; | ||
use Maatwebsite\Excel\Concerns\WithMapping; | ||
use Maatwebsite\Excel\Concerns\WithStyles; | ||
use PhpOffice\PhpSpreadsheet\Shared\Date; | ||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; | ||
|
||
class UserExport implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping, WithStyles | ||
{ | ||
use Exportable; | ||
|
||
private Collection $users; | ||
|
||
public function __construct(Collection $users) | ||
{ | ||
$this->users = $users; | ||
} | ||
|
||
public function collection(): Collection | ||
{ | ||
return $this->users; | ||
} | ||
|
||
public function properties(): array | ||
{ | ||
return [ | ||
'creator' => config('app.name'), | ||
'lastModifiedBy' => config('app.name'), | ||
'title' => 'User Export', | ||
'description' => 'Exported user data from '.config('app.name'), | ||
'category' => 'Users', | ||
'subject' => 'Users', | ||
'keywords' => 'users,export,spreadsheet', | ||
]; | ||
} | ||
|
||
public function styles($sheet): array | ||
{ | ||
return [ | ||
1 => ['font' => ['bold' => true], 'alignment' => ['horizontal' => 'center']], | ||
]; | ||
} | ||
|
||
public function columnFormats(): array | ||
{ | ||
return [ | ||
'A' => NumberFormat::FORMAT_TEXT, | ||
'B' => NumberFormat::FORMAT_TEXT, | ||
'C' => NumberFormat::FORMAT_TEXT, | ||
'D' => NumberFormat::FORMAT_DATE_DDMMYYYY, | ||
]; | ||
} | ||
|
||
public function headings(): array | ||
{ | ||
return Index::getTableColumns(); | ||
} | ||
|
||
public function map($user): array | ||
{ | ||
return [ | ||
$user->name, | ||
$user->email, | ||
$user->role->name, | ||
Date::dateTimeToExcel($user->createdAt), | ||
]; | ||
} | ||
} |
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
Oops, something went wrong.