'required|min:1|max:255|unique' ); use ValidatingTrait; public $modelRules = [ 'model_id' => 'required|exists:models,id', 'quantity' => 'required|integer|min:1', 'pivot_id' => 'integer|exists:kits_models,id' ]; public $licenseRules = [ 'license_id' => 'required|exists:licenses,id', 'quantity' => 'required|integer|min:1', 'pivot_id' => 'integer|exists:kits_licenses,id' ]; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name' ]; use Searchable; /** * The attributes that should be included when searching the model. * * @var array */ protected $searchableAttributes = ['name']; /** * The relations and their attributes that should be included when searching the model. * * @var array */ protected $searchableRelations = []; /** * Establishes the kits -> models relationship * * @author [A. Gianotto] [] * @since [v2.0] * @return \Illuminate\Database\Eloquent\Relations\Relation */ public function models() { return $this->belongsToMany('\App\Models\AssetModel', 'kits_models', 'kit_id', 'model_id')->withPivot('id', 'quantity'); } /** * Establishes the kits -> licenses relationship * * @author [A. Gianotto] [] * @since [v4.3] * @return \Illuminate\Database\Eloquent\Relations\Relation */ public function licenses() { return $this->belongsToMany('\App\Models\License', 'kits_licenses', 'kit_id', 'license_id')->withPivot('id', 'quantity'); } /** * ----------------------------------------------- * BEGIN QUERY SCOPES * ----------------------------------------------- **/ }