install
This commit is contained in:
64
app/Modules/Region/RegionModule.php
Normal file
64
app/Modules/Region/RegionModule.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Region;
|
||||
|
||||
use App\Modules\Makeable;
|
||||
use App\Modules\ModuleContract;
|
||||
|
||||
class RegionModule implements ModuleContract
|
||||
{
|
||||
use Makeable;
|
||||
|
||||
/**
|
||||
* Module is enabled
|
||||
*/
|
||||
protected bool $enabled = true;
|
||||
|
||||
/**
|
||||
* Check if is module enabled
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable module
|
||||
*/
|
||||
public function disable(): void
|
||||
{
|
||||
$this->enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable module
|
||||
*/
|
||||
public function enable(): void
|
||||
{
|
||||
$this->enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if module has a filament resource
|
||||
*/
|
||||
public function hasFilamentResource(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module composer requirements
|
||||
*/
|
||||
public function getComposerRequirements(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module composer suggestions
|
||||
*/
|
||||
public function getComposerSuggestions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
77
app/Modules/Region/Repositories/RegionRepository.php
Normal file
77
app/Modules/Region/Repositories/RegionRepository.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Region\Repositories;
|
||||
|
||||
use App\Modules\Region\Models\Region;
|
||||
|
||||
class RegionRepository
|
||||
{
|
||||
/**
|
||||
* Mary
|
||||
*/
|
||||
public const MR = 'mr';
|
||||
|
||||
/**
|
||||
* Aşgabat
|
||||
*/
|
||||
public const AG = 'ag';
|
||||
|
||||
/**
|
||||
* Arkadag
|
||||
*/
|
||||
public const AK = 'ak';
|
||||
|
||||
/**
|
||||
* Ahal
|
||||
*/
|
||||
public const AH = 'ah';
|
||||
|
||||
/**
|
||||
* Lebap
|
||||
*/
|
||||
public const LB = 'lb';
|
||||
|
||||
/**
|
||||
* Balkan
|
||||
*/
|
||||
public const BN = 'bn';
|
||||
|
||||
/**
|
||||
* Daşoguz
|
||||
*/
|
||||
public const DZ = 'dz';
|
||||
|
||||
/**
|
||||
* Regions
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function values(): array
|
||||
{
|
||||
return [
|
||||
self::AG => __('Ashgabat'),
|
||||
self::AK => __('Arkadag'),
|
||||
self::MR => __('Mary'),
|
||||
self::AH => __('Ahal'),
|
||||
self::LB => __('Lebap'),
|
||||
self::BN => __('Balkan'),
|
||||
self::DZ => __('Dashoguz'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Default region
|
||||
*/
|
||||
public static function default(): string
|
||||
{
|
||||
return self::AG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Label for given region
|
||||
*/
|
||||
public static function label(string $region = 'ag'): string
|
||||
{
|
||||
return static::values()[$region] ?? '';
|
||||
}
|
||||
}
|
||||
13
app/Modules/Region/region-helpers.php
Normal file
13
app/Modules/Region/region-helpers.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
use App\Modules\Region\Repositories\RegionRepository;
|
||||
|
||||
/**
|
||||
* Regions
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
function regions(): array
|
||||
{
|
||||
return RegionRepository::values();
|
||||
}
|
||||
Reference in New Issue
Block a user