New models for node and location admin pages.
This commit is contained in:
parent
96d3aa767f
commit
09d23deed6
10 changed files with 152 additions and 78 deletions
|
@ -44,7 +44,7 @@ class LocationRepository
|
|||
public function create(array $data)
|
||||
{
|
||||
$validator = Validator::make($data, [
|
||||
'short' => 'required|regex:/^[a-z0-9_.-]{1,10}$/i|unique:locations,short',
|
||||
'short' => 'required|regex:/^[\w.-]{1,20}$/i|unique:locations,short',
|
||||
'long' => 'required|string|min:1|max:255',
|
||||
]);
|
||||
|
||||
|
@ -73,9 +73,11 @@ class LocationRepository
|
|||
*/
|
||||
public function edit($id, array $data)
|
||||
{
|
||||
$location = Models\Location::findOrFail($id);
|
||||
|
||||
$validator = Validator::make($data, [
|
||||
'short' => 'regex:/^[a-z0-9_.-]{1,10}$/i',
|
||||
'long' => 'string|min:1|max:255',
|
||||
'short' => 'required|regex:/^[\w.-]{1,20}$/i|unique:locations,short,' . $location->id,
|
||||
'long' => 'required|string|min:1|max:255',
|
||||
]);
|
||||
|
||||
// Run validator, throw catchable and displayable exception if it fails.
|
||||
|
@ -84,15 +86,7 @@ class LocationRepository
|
|||
throw new DisplayValidationException($validator->errors());
|
||||
}
|
||||
|
||||
$location = Models\Location::findOrFail($id);
|
||||
|
||||
if (isset($data['short'])) {
|
||||
$location->short = $data['short'];
|
||||
}
|
||||
|
||||
if (isset($data['long'])) {
|
||||
$location->long = $data['long'];
|
||||
}
|
||||
$location->fill($data);
|
||||
|
||||
return $location->save();
|
||||
}
|
||||
|
|
Reference in a new issue