Fixes for #759 - location heirarchy
This commit is contained in:
+10
-3
@@ -10,13 +10,20 @@ class Location extends Elegant
|
||||
'city' => 'required|alpha_space|min:3|max:255',
|
||||
'state' => 'alpha_space|min:2|max:32',
|
||||
'country' => 'required|alpha_space|min:2|max:2|max:2',
|
||||
'address' => 'required|alpha_space|min:5|max:80',
|
||||
'address' => 'alpha_space|min:5|max:80',
|
||||
'address2' => 'alpha_space|min:5|max:80',
|
||||
'zip' => 'alpha_space|min:3|max:10',
|
||||
);
|
||||
|
||||
public function has_users()
|
||||
{
|
||||
public function has_users() {
|
||||
return $this->hasMany('User', 'location_id')->count();
|
||||
}
|
||||
|
||||
public function parent() {
|
||||
return $this->belongsTo('Location', 'parent_id');
|
||||
}
|
||||
|
||||
public function childLocations() {
|
||||
return $this->hasMany('Location')->where('parent_id','=',$this->id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user