Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return View::make('home');
});

Route::get('/about', function () {
    return View::make('about');
});

Route::get('/contact', function () {
    return View::make('contact');
});

Route::post('contact', function()
{
    $data = Request::all();
    $rules = array(
        'subject' => 'required',
        'message' => 'required'
    );

    $validator = Validator::make($data, $rules);

    if($validator-> fails())
    {
        return Redirect::to('contact')->withErrors($validator)->withInput();
    }

    return 'Your message has been sent';
});


The above Laravel Code returning the below error

Non-static method Illuminate\Http\Request::all() should not be called statically


What I have tried:

I tried changing $request->all();
Posted
Updated 9-May-20 22:56pm

1 solution

php - Laravel Request::all() Should Not Be Called Statically - Stack Overflow[^] may help you to understand why and how to correct it.
 
Share this answer
 
Comments
kirupabshankar 10-May-20 10:11am    
Please help me to correct it as I am beginner
phil.o 10-May-20 12:16pm    
Have you followed the advise of the first answer from the link I provided?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900