CompanyRequest.php 869 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Http\Requests;
  3. use Request;
  4. use App\Models\Company;
  5. use Illuminate\Foundation\Http\FormRequest;
  6. class CompanyRequest extends FormRequest
  7. {
  8. /**
  9. * Determine if the user is authorized to make this request.
  10. *
  11. * @return bool
  12. */
  13. public function authorize()
  14. {
  15. return true;
  16. }
  17. /**
  18. * Get the validation rules that apply to the request.
  19. *
  20. * @return array
  21. */
  22. public function rules()
  23. {
  24. $id = Request::route('id');
  25. $company = Company::find($id);
  26. if ($company->width && $company->height) {
  27. $image_val = 'dimensions:width='.$company->width.',height='.$company->height;
  28. }
  29. else {
  30. $image_val = '';
  31. }
  32. return [
  33. 'value' => 'required|max:50',
  34. 'image' => $image_val
  35. ];
  36. }
  37. }