0

I'm new to Laravel so I'm not familiar with errors in the framework .I'm trying to get the user to make a post but I'm getting the above error .Could you please tell where I'm going wrong ?Thank you

This is my HomeController class:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $r)
    {
        if(Input::has('status-text'))
        {
            $text = e(Input::get('status-text'));
            $userStatus = new Status();
            $userStatus->status_text = $text;
            $userStatus->save();
            Flash::success('Your status has been posted');
            return redirect(route('home'));

                }


        return view('home');
    }
}

And this is my web.php class :

<?php


Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::any('/home', ['as'=> 'home','uses' =>'HomeController@index']);
1
  • add use Input; top of controller Commented Jun 14, 2017 at 19:20

1 Answer 1

1

Don't use Input::get(), use $r->get() as you're injecting the request as a dependency to the index method already, and Input:: is merely a alias to access the underlaying Request.

Sign up to request clarification or add additional context in comments.

9 Comments

I changed it to $text = e($request->get('status-text')); and still got the same error message
@Russkiy You aliased $request as $r...so use $r->get not $request->get
That didn't help too :/
@Ohgodwhy my apologies, you edited your answer and my display didn't show. I know it isn't required, I saw your initial answer ($request instead of what OP used).
@Derek No worries!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.