Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Requests;
  4.  
  5. use App\Helpers\Helper;
  6. use Illuminate\Foundation\Http\FormRequest;
  7.  
  8. class PlanRequest extends FormRequest
  9. {
  10.     /**
  11.      * Determine if the user is authorized to make this request.
  12.      *
  13.      * @return bool
  14.      */
  15.     public function authorize()
  16.     {
  17.         return true;
  18.     }
  19.  
  20.     public function rules()
  21.     {
  22.         return [
  23.             'name' => 'required|string|max:255|unique:plans,name',
  24.             'price' => 'required|numeric|min:0'
  25.         ];
  26.     }
  27.  
  28.     public function attributes()
  29.     {
  30.         return __('attributes.admin.plan');
  31.     }
  32.  
  33.     public function all($keys = null)
  34.     {
  35.         $a = parent::all();
  36.  
  37.         $a['price'] = Helper::numericToDB($a['price']);
  38.  
  39.         return $a;
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement