Files
cheerstothe_season_2.0/app/Models/ManageRestaurant.php

65 lines
1.6 KiB
PHP
Raw Normal View History

2024-05-28 18:52:27 +05:30
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
2024-05-30 15:28:17 +05:30
use Illuminate\Database\Eloquent\SoftDeletes;
2024-05-30 17:05:09 +05:30
use Illuminate\Support\Str;
2024-05-30 15:28:17 +05:30
2024-05-28 18:52:27 +05:30
use Illuminate\Database\Eloquent\Model;
2024-05-30 19:41:43 +05:30
use App\Models\ManageState;
2024-06-03 20:26:36 +05:30
use App\Models\IamPrincipalRestaurantRole;
2024-05-30 19:41:43 +05:30
2024-05-28 18:52:27 +05:30
class ManageRestaurant extends Model
{
2024-05-30 15:28:17 +05:30
use SoftDeletes;
2024-05-28 18:52:27 +05:30
use HasFactory;
2024-05-30 15:28:17 +05:30
protected $table = 'manage_restaurants';
protected $fillable = [
2024-05-30 17:05:09 +05:30
'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio',
'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longitude',
2024-06-27 16:31:01 +05:30
'is_active', 'created_by', 'modified_by', 'phone_number','time_hours','max_numb_day','max_numb_week','max_numb_month'
2024-05-30 15:28:17 +05:30
];
2024-05-30 17:05:09 +05:30
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
if (empty($model->short_id)) {
$model->short_id = static::generateUniqueShortId();
}
});
}
protected static function generateUniqueShortId()
2024-05-28 18:52:27 +05:30
{
2024-05-30 17:05:09 +05:30
do {
$shortId = Str::random(4);
} while (static::where('short_id', $shortId)->exists());
return $shortId;
2024-05-28 18:52:27 +05:30
}
2024-05-31 12:35:52 +05:30
public function operatingHours()
{
return $this->hasMany(OperatingHour::class,'manage_restaurant_xid', 'id');
}
2024-05-30 19:41:43 +05:30
public function state()
{
return $this->belongsTo(ManageState::class, 'state_xid', 'id');
}
2024-06-03 20:26:36 +05:30
2024-06-12 17:44:31 +05:30
2024-07-01 19:29:55 +05:30
public function timeInterval()
{
return $this->hasMany(RestaurantTimeInterval::class, 'manage_restaurants_xid', 'id');
}
2024-06-12 17:44:31 +05:30
2024-05-28 18:52:27 +05:30
}