Berkarar/plugins/tps/shops/models/Shop.php

62 lines
1.2 KiB
PHP
Raw Normal View History

2022-08-28 19:50:26 +00:00
<?php namespace Tps\Shops\Models;
use Model;
/**
* Model
*/
class Shop extends Model
{
use \October\Rain\Database\Traits\Validation;
2023-08-04 08:35:28 +00:00
2022-08-28 19:50:26 +00:00
public $implement = ['RainLab.Translate.Behaviors.TranslatableModel'];
/**
* @var string The database table used by the model.
*/
public $table = 'tps_shops_';
/**
* @var array Validation rules
*/
public $rules = [
];
2023-08-04 08:35:28 +00:00
2022-09-13 14:01:10 +00:00
public $fillable = ["name", "floor", "phone", "instagram_name", "instagram_link"];
2022-08-28 19:50:26 +00:00
public $attachOne = [
2023-07-26 13:31:34 +00:00
'badge' => 'System\Models\File'
];
public $attachMany = [
2022-08-28 19:50:26 +00:00
'badge' => 'System\Models\File',
2023-07-26 13:31:34 +00:00
'images' => 'System\Models\File',
2022-08-28 19:50:26 +00:00
];
public $belongsTo = [
'category' => [
'Tps\Shops\Models\Category'
],
2022-09-13 14:01:10 +00:00
'user' => [
'RainLab\User\Models\User'
],
2022-08-28 19:50:26 +00:00
];
2023-08-04 08:35:28 +00:00
2022-09-15 19:49:54 +00:00
public $hasMany = [
'reports' => [
'Tps\Shops\Models\ReportDetail',
]
];
2022-08-28 19:50:26 +00:00
public $translatable = ['name','description','open_time'];
2023-08-04 08:35:28 +00:00
public function getCategoryFieldAttribute() {
return $this->category->name;
}
2023-08-11 15:29:02 +00:00
public function scopeFilterName($query, $name)
{
return $query->where('name', 'LIKE', '%' . $name . '%');
}
2022-08-28 19:50:26 +00:00
}