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.
70 lines
1.8 KiB
70 lines
1.8 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 AdminFloor extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $table = 'admin_floor';
|
|
|
|
protected $fillable
|
|
= [
|
|
'name',
|
|
'image_url',
|
|
'building_floor',
|
|
'open_time',
|
|
'close_time'
|
|
];
|
|
|
|
protected $hidden
|
|
= [
|
|
'updated_at',
|
|
'deleted_at'
|
|
];
|
|
|
|
public static function getName($id)
|
|
{
|
|
$name = self::query()->where('id', $id)->value('name') ?? '';
|
|
return AdminTranslationService::getTranslationTypeName($id, 4, $name);
|
|
}
|
|
|
|
public static function getData(): array
|
|
{
|
|
return self::query()->where('status', 1)->select(['id', 'name'])->get()
|
|
->each(
|
|
function ($item) {
|
|
$item['name']
|
|
= AdminTranslationService::getTranslationTypeName(
|
|
$item['id'],
|
|
4,
|
|
$item['name']
|
|
);
|
|
return $item;
|
|
}
|
|
)->toArray() ?? [];
|
|
}
|
|
|
|
public static function getFirst($id)
|
|
{
|
|
$item = self::query()->where(['status' => 1, 'id' => $id])->first();
|
|
if ($item) {
|
|
$item['name'] = AdminTranslationService::getTranslationTypeName(
|
|
$item['id'],
|
|
4,
|
|
$item['name']
|
|
);
|
|
}
|
|
return $item;
|
|
}
|
|
|
|
public function getCreatedAtAttribute($value): string
|
|
{
|
|
return $value ? date("Y-m-d H:i:s", strtotime($value)) : $value;
|
|
}
|
|
}
|
|
|