install
This commit is contained in:
10
app/Modules/OrderStatus/Interfaces/HasStatus.php
Normal file
10
app/Modules/OrderStatus/Interfaces/HasStatus.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\OrderStatus\Interfaces;
|
||||
|
||||
/**
|
||||
* @property string $status
|
||||
*
|
||||
* @phpstan-require-extends \Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
interface HasStatus {}
|
||||
64
app/Modules/OrderStatus/OrderStatusModule.php
Normal file
64
app/Modules/OrderStatus/OrderStatusModule.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\OrderStatus;
|
||||
|
||||
use App\Modules\Makeable;
|
||||
use App\Modules\ModuleContract;
|
||||
|
||||
class OrderStatusModule 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 [];
|
||||
}
|
||||
}
|
||||
120
app/Modules/OrderStatus/Repositories/OrderStatusRepository.php
Normal file
120
app/Modules/OrderStatus/Repositories/OrderStatusRepository.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\OrderStatus\Repositories;
|
||||
|
||||
class OrderStatusRepository
|
||||
{
|
||||
/**
|
||||
* Pending orders are brand new orders that have not been processed yet.
|
||||
*/
|
||||
public const PENDING = 'pending';
|
||||
|
||||
/**
|
||||
* Orders that has been registered..
|
||||
*/
|
||||
public const REGISTER = 'register';
|
||||
|
||||
/**
|
||||
* Orders that has been registered..
|
||||
*/
|
||||
public const PROCESSING = 'processing';
|
||||
|
||||
/**
|
||||
* Orders fulfilled completely.
|
||||
*/
|
||||
public const COMPLETED = 'completed';
|
||||
|
||||
/**
|
||||
* Order that has been cancelled.
|
||||
*/
|
||||
public const CANCELLED = 'cancelled';
|
||||
|
||||
/**
|
||||
* Mobile device
|
||||
*/
|
||||
public const MOBILE_DEVICE = 'mobile';
|
||||
|
||||
/**
|
||||
* Default status value
|
||||
*/
|
||||
public static function defaultStatus(): string
|
||||
{
|
||||
return static::PENDING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Status Values
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function statusValues(): array
|
||||
{
|
||||
return [
|
||||
null => '-',
|
||||
self::PENDING => __('Pending'),
|
||||
self::REGISTER => __('Registered'),
|
||||
self::PROCESSING => __('Processing'),
|
||||
self::COMPLETED => __('Completed'),
|
||||
self::CANCELLED => __('Cancelled'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tailwind
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function statusClasses(): array
|
||||
{
|
||||
return [
|
||||
null => '-',
|
||||
self::PENDING => 'warning',
|
||||
self::REGISTER => 'info',
|
||||
self::PROCESSING => 'info',
|
||||
self::COMPLETED => 'success',
|
||||
self::CANCELLED => 'danger',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Status icons
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function statusIcons(): array
|
||||
{
|
||||
return [
|
||||
null => '-',
|
||||
'success' => 'check-circle',
|
||||
'info' => 'information-circle',
|
||||
'primary' => 'clipboard-list',
|
||||
'danger' => 'ban',
|
||||
'warning' => 'exclamation-circle',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* HEX Colors
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function statusColors(): array
|
||||
{
|
||||
return [
|
||||
null => '-',
|
||||
self::PENDING => '#F5573B',
|
||||
self::REGISTER => '#F2CB22',
|
||||
self::PROCESSING => '#8FC15D',
|
||||
self::COMPLETED => '#098F56',
|
||||
self::CANCELLED => '#d70206',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatted status for given "status"
|
||||
*/
|
||||
public static function statusFormatted(string $status = 'pending'): string
|
||||
{
|
||||
return static::statusValues()[$status] ?? __('None');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user