AssetRequest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace App\Http\Requests;
4 
7 
8 class AssetRequest extends Request
9 {
15  public function authorize()
16  {
17  return true;
18  }
19 
25  public function rules()
26  {
27  $rules = [
28  'name' => 'min:2|max:255',
29  'model_id' => 'required|integer',
30  'status_id' => 'required|integer',
31  'company_id' => 'integer',
32  'warranty_months' => 'integer|min:0|max:240',
33  'physical' => 'integer',
34  'checkout_date' => 'date|max:10|min:10',
35  'checkin_date' => 'date|max:10|min:10',
36  'supplier_id' => 'integer',
37  'asset_tag' => 'required|min:2|max:255|unique:assets,asset_tag,NULL,deleted_at',
38  'status' => 'integer',
39  ];
40 
41  $model = AssetModel::find($this->request->get('model_id'));
42 
43  if ($model->fieldset)
44  {
45  $rules += $model->fieldset->validation_rules();
46  }
47 
48 
49 
50  return $rules;
51 
52  }
53 
54  public function response(array $errors)
55  {
56  return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
57  }
58 }
rules()
Get the validation rules that apply to the request.
authorize()
Determine if the user is authorized to make this request.