1

I am building this website and I want to pass url parameters

http://movies.com/people?genre=action

Should generate all the people listed with genre=action

This is my route

Route::resource(Str::slug(trans('main.people')), 'ActorController');

This is my ActorController

public function index($input)
{

if (isset($input['genre']) && $input['genre'] != 'all')
    {
        return $this->actor->where('genre', 'like', '$input');

        return View::make('Actor.All')->withActors($actors);
    }
    else
    {

         return View::make('Actor.All')->withActors($actors);
}
}

I keep receiving this error ErrorException Missing argument 1 for ActorController::index()

4
  • try using laravel's input class : http://laravel.com/docs/requests#basic-input Commented Feb 7, 2014 at 7:02
  • Hi the Input class here only grabs GET/POST data. How do I send input from the URL? Commented Feb 7, 2014 at 7:10
  • input from the URL is GET data Commented Feb 7, 2014 at 7:13
  • @Stephenmelb the input class will fetch query strings fine, but you'll need to do it manually Commented Feb 7, 2014 at 7:21

1 Answer 1

1

Query strings aren't passed down automatically to controller's method, you need to fetch them manually:

public function index()
{
  if(Input::has('genre') && Input::get('genre') != 'all') {
     $this->actor->where('genre', 'like', Input::get('genre'));

  }
  return View::make('Actor.all')->withActors($this->actor);
}
Sign up to request clarification or add additional context in comments.

7 Comments

Hi I think its passing the variable but now I am getting Call to undefined method Lib\Repository\Actor\DbActor::where()
Because I'm only guessing where you're taking that $actor variable from, I suppose you inizialize it in the constructor? Is it an DB class, right?
public function __construct(DbActor $actor, ActorValidator $validator, Options $options) { $this->actor = $actor; $this->options = $options; $this->validator = $validator; }
Does your class has a where method? It doesn't look like an Eloquent model, what is it?
Its eloquent but my actor class doesnt have a where method
|

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.