| @@ 9-45 (lines=37) @@ | ||
| 6 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
|
| 7 | use Timegridio\Concierge\Models\Business; |
|
| 8 | ||
| 9 | class Humanresource extends EloquentModel |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * The attributes that are mass assignable. |
|
| 13 | * |
|
| 14 | * @var array |
|
| 15 | */ |
|
| 16 | protected $fillable = ['name', 'capacity']; |
|
| 17 | ||
| 18 | protected $guarded = ['id', 'slug']; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * Has many human resources. |
|
| 22 | * |
|
| 23 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
| 24 | */ |
|
| 25 | public function business() |
|
| 26 | { |
|
| 27 | return $this->belongsTo(Business::class); |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * TODO: Check slug setting can be moved to a more proper place. |
|
| 32 | * |
|
| 33 | * Save the model to the database. |
|
| 34 | * |
|
| 35 | * @param array $options |
|
| 36 | * |
|
| 37 | * @return bool |
|
| 38 | */ |
|
| 39 | public function save(array $options = []) |
|
| 40 | { |
|
| 41 | $this->attributes['slug'] = str_slug($this->attributes['name']); |
|
| 42 | ||
| 43 | return parent::save($options); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| @@ 7-58 (lines=52) @@ | ||
| 4 | ||
| 5 | use Illuminate\Database\Eloquent\Model; |
|
| 6 | ||
| 7 | class ServiceType extends Model |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * The attributes that are mass assignable. |
|
| 11 | * |
|
| 12 | * @var array |
|
| 13 | */ |
|
| 14 | protected $fillable = ['name', 'description', 'business_id']; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * The attributes that aren't mass assignable. |
|
| 18 | * |
|
| 19 | * @var array |
|
| 20 | */ |
|
| 21 | protected $guarded = ['id', 'slug']; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * Has many services. |
|
| 25 | * |
|
| 26 | * @return Illuminate\Database\Query Relationship |
|
| 27 | */ |
|
| 28 | public function services() |
|
| 29 | { |
|
| 30 | return $this->hasMany(Service::class); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * Belongs to Business. |
|
| 35 | * |
|
| 36 | * @return Illuminate\Database\Query Relationship |
|
| 37 | */ |
|
| 38 | public function business() |
|
| 39 | { |
|
| 40 | return $this->belongsTo(Business::class); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * TODO: Check slug setting can be moved to a more proper place. |
|
| 45 | * |
|
| 46 | * Save the model to the database. |
|
| 47 | * |
|
| 48 | * @param array $options |
|
| 49 | * |
|
| 50 | * @return bool |
|
| 51 | */ |
|
| 52 | public function save(array $options = []) |
|
| 53 | { |
|
| 54 | $this->attributes['slug'] = str_slug($this->attributes['name']); |
|
| 55 | ||
| 56 | return parent::save($options); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||