mardi 5 juillet 2016

Get model from controller

How can I get the model, or pass the model, from a child class to a parent?

I need the model so I can get the table name associated to that model (as shown here).

I make the request from my child controller:

class UserQuestions extends ResourceController
{
    public function getUserQuestions(Request $request)
    {
        $input = $request->all();
        return $this->getFilterables($input);

In my parent Resource Controller:

protected function getFilterables($input)
{
    DB::table(Model::getTable())->whereIn($filter_field, $filters_array)->get()

The response is a 500 error. I'm tailing the Laravel logs, but am getting no error there.

I've also tried passing it through:

return $this->getFilterables(UserQuestion, $input);

This also does not work.

How can I get the model?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire