792e45bd12
State abbreviations, if used at all, are not neccessarily 2 characters outside the US and zip codes aren't always 5 digits either. It's probably a good idea not to enforce US centric length requirements to these fields in the Location model.
24 lines
540 B
PHP
24 lines
540 B
PHP
<?php
|
|
|
|
class Location extends Elegant {
|
|
|
|
|
|
protected $softDelete = true;
|
|
protected $table = 'locations';
|
|
protected $rules = array(
|
|
'name' => 'required|alpha_space|min:3',
|
|
'address' => 'required|alpha_space|min:5',
|
|
'address2' => 'alpha_space|min:5',
|
|
'city' => 'required|alpha_space|min:3',
|
|
'state' => 'required|alpha|min:2',
|
|
'country' => 'required|alpha|min:2|max:2',
|
|
'zip' => 'alpha_dash|min:3',
|
|
);
|
|
|
|
public function has_users()
|
|
{
|
|
return $this->hasMany('User', 'location_id')->count();
|
|
}
|
|
|
|
}
|