2016-09-24 09:34:08 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
|
2016-09-28 20:13:18 +01:00
|
|
|
use App\Storage;
|
2016-09-24 09:34:08 +01:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
class StoreStorageRequest extends FormRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
2016-09-28 20:13:18 +01:00
|
|
|
switch ($this->method())
|
|
|
|
{
|
|
|
|
case 'POST':
|
|
|
|
return [
|
|
|
|
'name' => 'required|unique:storages|max:255',
|
|
|
|
'source' => 'required|max:255',
|
|
|
|
];
|
|
|
|
|
|
|
|
case 'PATCH':
|
|
|
|
case 'PUT':
|
|
|
|
$storageId = intval($this->segment(3));
|
|
|
|
|
|
|
|
return [
|
|
|
|
'name' => 'required|max:255|unique:storages,name,' . $storageId
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-09-24 09:34:08 +01:00
|
|
|
}
|
|
|
|
}
|