From ae329f41607bff2fbaa65e62695be467f925588e Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 22 May 2017 21:32:22 -0700 Subject: [PATCH] Department model --- app/Models/Department.php | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 app/Models/Department.php diff --git a/app/Models/Department.php b/app/Models/Department.php new file mode 100644 index 0000000000..95c8e2702c --- /dev/null +++ b/app/Models/Department.php @@ -0,0 +1,63 @@ + 'max:255', + 'user_id' => 'required', + 'location_id' => 'numeric', + 'company_id' => 'numeric', + ]; + + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = [ + 'user_id', + 'name', + 'location_id', + 'company_id', + 'manager_id', + 'notes', + ]; + + + public function company() + { + return $this->belongsTo('\App\Models\Company', 'company_id'); + } + + /** + * Even though we allow allow for checkout to things beyond users + * this method is an easy way of seeing if we are checked out to a user. + * @return mixed + */ + public function users() + { + return $this->hasMany('\App\Models\User', 'department_id'); + } + +}