restore composer.json, add mysqli extension

This commit is contained in:
2026-04-15 17:02:52 +05:00
commit 77cf56a348
4317 changed files with 1397107 additions and 0 deletions

49
app/Models/Region.php Executable file
View File

@@ -0,0 +1,49 @@
<?php
namespace App\Models;
use App\Traits\LogOptionsTrait;
use Illuminate\Support\Facades\App;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;
class Region extends Model
{
use LogsActivity, LogOptionsTrait;
protected $guarded = ['id'];
protected $casts = [
'name' => 'array',
'cash' => 'boolean'
];
protected static $logName = 'regions';
protected static $logOnlyDirty = true;
protected static $logAttributes = ['name', 'cash'];
protected static $submitEmptyLogs = false;
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function cities()
{
return $this->hasMany(City::class, 'region_id', 'id');
}
public function getName(): string
{
return (string) $this->name[App::getLocale()] ?? null;
}
public function deliveryPrice()
{
return $this->hasMany(DeliveryPrice::class, 'region_id', 'id');
}
public function getDeliveryPrice($powerId): ?float
{
$deliveryPrice = collect($this->deliveryPrice)->where('power_id', $powerId)->first();
return $deliveryPrice ? $deliveryPrice['price'] : null;
}
}