29 lines
361 B
PHP
29 lines
361 B
PHP
<?php
|
|
|
|
class Category extends Elegant {
|
|
|
|
protected $softDelete = true;
|
|
|
|
/**
|
|
* Category validation rules
|
|
*/
|
|
protected $rules = array(
|
|
'name' => 'required|min:2',
|
|
);
|
|
|
|
|
|
public function has_models()
|
|
{
|
|
return $this->hasMany('Model', 'category_id')->count();
|
|
}
|
|
|
|
public function models()
|
|
{
|
|
return $this->hasMany('Model', 'category_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|