117 lines
3.2 KiB
PHP
117 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\ManagementTools\Entities;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MtScoreCard extends Model
|
|
{
|
|
protected $table = 'mt_score_cards';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'is_active' => 'boolean',
|
|
'points' => 'float',
|
|
];
|
|
|
|
public function scopeForBusiness($query, $business_id)
|
|
{
|
|
return $query->where('business_id', $business_id);
|
|
}
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('is_active', true);
|
|
}
|
|
|
|
public function scopeOrdered($query)
|
|
{
|
|
return $query->orderBy('sort_order')->orderBy('title');
|
|
}
|
|
|
|
public static function colorPresets(): array
|
|
{
|
|
return [
|
|
'green' => [
|
|
'label' => __('managementtools::lang.color_green'),
|
|
'bg' => '#dcfce7',
|
|
'border' => '#16a34a',
|
|
'text' => '#166534',
|
|
'badge' => 'label-success',
|
|
],
|
|
'red' => [
|
|
'label' => __('managementtools::lang.color_red'),
|
|
'bg' => '#fee2e2',
|
|
'border' => '#dc2626',
|
|
'text' => '#991b1b',
|
|
'badge' => 'label-danger',
|
|
],
|
|
'blue' => [
|
|
'label' => __('managementtools::lang.color_blue'),
|
|
'bg' => '#dbeafe',
|
|
'border' => '#2563eb',
|
|
'text' => '#1e40af',
|
|
'badge' => 'label-primary',
|
|
],
|
|
'orange' => [
|
|
'label' => __('managementtools::lang.color_orange'),
|
|
'bg' => '#ffedd5',
|
|
'border' => '#ea580c',
|
|
'text' => '#9a3412',
|
|
'badge' => 'label-warning',
|
|
],
|
|
'yellow' => [
|
|
'label' => __('managementtools::lang.color_yellow'),
|
|
'bg' => '#fef9c3',
|
|
'border' => '#ca8a04',
|
|
'text' => '#854d0e',
|
|
'badge' => 'label-warning',
|
|
],
|
|
'purple' => [
|
|
'label' => __('managementtools::lang.color_purple'),
|
|
'bg' => '#f3e8ff',
|
|
'border' => '#9333ea',
|
|
'text' => '#6b21a8',
|
|
'badge' => 'label-default',
|
|
],
|
|
'teal' => [
|
|
'label' => __('managementtools::lang.color_teal'),
|
|
'bg' => '#ccfbf1',
|
|
'border' => '#0d9488',
|
|
'text' => '#115e59',
|
|
'badge' => 'label-info',
|
|
],
|
|
'gray' => [
|
|
'label' => __('managementtools::lang.color_gray'),
|
|
'bg' => '#f1f5f9',
|
|
'border' => '#64748b',
|
|
'text' => '#334155',
|
|
'badge' => 'label-default',
|
|
],
|
|
];
|
|
}
|
|
|
|
public function colorStyle(): array
|
|
{
|
|
$presets = self::colorPresets();
|
|
|
|
return $presets[$this->color_key] ?? $presets['gray'];
|
|
}
|
|
|
|
public function pointsFormatted(): string
|
|
{
|
|
$points = (float) $this->points;
|
|
if ($points > 0) {
|
|
return '+'.number_format($points, 0);
|
|
}
|
|
|
|
return number_format($points, 0);
|
|
}
|
|
|
|
public function iconClass(): string
|
|
{
|
|
return $this->icon ?: 'fa-star';
|
|
}
|
|
}
|