You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\AdminTranslationService;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class AdminFloorRegion extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $table = 'admin_floor_region';
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'floor_id',
|
|
'open_time',
|
|
'close_time',
|
|
'status'
|
|
];
|
|
|
|
protected $hidden
|
|
= [
|
|
'updated_at',
|
|
'deleted_at'
|
|
];
|
|
|
|
public function getCreatedAtAttribute($value): string
|
|
{
|
|
return $value ? date("Y-m-d H:i:s", strtotime($value)) : $value;
|
|
}
|
|
|
|
/**
|
|
* @param int $floor_id
|
|
* @return array
|
|
*/
|
|
public static function getFloorRegion(int $floor_id): array
|
|
{
|
|
$columns = ['id', 'name'];
|
|
return self::query()->where('floor_id', $floor_id)->where('status', 1)
|
|
->select($columns)
|
|
->get()->each(function ($item) {
|
|
$item['name'] = AdminTranslationService::getTranslationTypeName(
|
|
$item['id'],
|
|
5,
|
|
$item['name']
|
|
);
|
|
return $item;
|
|
})->toArray();
|
|
}
|
|
|
|
public static function getName($id)
|
|
{
|
|
$name = self::query()->where('id', $id)->where('status', 1)->value('name') ?? '';
|
|
return AdminTranslationService::getTranslationTypeName($id, 5, $name);
|
|
}
|
|
}
|
|
|