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