Guest User

Untitled

a guest
May 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <IfModule mod_rewrite.c>
  2. <IfModule mod_negotiation.c>
  3. Options -MultiViews
  4. </IfModule>
  5.  
  6. # To switch to PHP 7
  7. AddType application/x-httpd-php56 .php
  8.  
  9. RewriteEngine On
  10. RewriteCond %{HTTP_HOST} ^www.example.com [NC]
  11. RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
  12.  
  13. RewriteEngine On
  14.  
  15. # Redirect Trailing Slashes If Not A Folder...
  16. RewriteCond %{REQUEST_FILENAME} !-d
  17. RewriteRule ^(.*)/$ /$1 [L,R=301]
  18.  
  19. # Handle Front Controller...
  20. RewriteCond %{REQUEST_FILENAME} !-d
  21. RewriteCond %{REQUEST_FILENAME} !-f
  22. RewriteRule ^ index.php [L]
  23.  
  24. # Handle Authorization Header
  25. RewriteCond %{HTTP:Authorization} .
  26. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  27. </IfModule>
  28.  
  29. use AppHttpRequestsProductRequest;
  30.  
  31. public function update(ProductRequest $request, $id)
  32. {
  33. $product = Product::findOrFail($id);
  34. $product->update( $request->all() );
  35.  
  36. $msgResponse = [...message...];
  37.  
  38. return Redirect::to('/products')->with($msgResponse);
  39. }
  40.  
  41. <?php
  42. namespace AppHttpRequests;
  43.  
  44. use IlluminateFoundationHttpFormRequest;
  45. use IlluminateValidationRule;
  46.  
  47. class ProductRequest extends FormRequest{
  48.  
  49. public function authorize(){
  50. return true;
  51. }
  52.  
  53. public function rules()
  54. {
  55. return [
  56. 'title' => 'required|max:10|...',
  57. 'otherfield' => ['required', Rule::in([...]),],
  58. ...
  59. ];
  60. }
  61. }
  62.  
  63. /**
  64. * The URI to redirect to if validation fails.
  65. *
  66. * @var string
  67. */
  68. protected $redirect;
  69.  
  70. /**
  71. * The route to redirect to if validation fails.
  72. *
  73. * @var string
  74. */
  75. protected $redirectRoute;
  76.  
  77. /**
  78. * The controller action to redirect to if validation fails.
  79. *
  80. * @var string
  81. */
  82. protected $redirectAction;
  83.  
  84. try {
  85. $request->validate([ /* rules */ ]);
  86. } catch (ValidationException $e) {
  87. $e->redirectTo(route('route.name'));
  88. throw $e;
  89. }
Add Comment
Please, Sign In to add comment