vendredi 14 décembre 2018

Laravel Call to a member function follows() on a non-object issue

My UserController includes the following:

public function doaction($domain, $some_id)
{
  $user = User::find(Sentry::getUser()->id);
  $user->doactions()->attach($some_id);
  $response = array('message' => 'doactioned', 'url' => 'http://'.$domain.'.'.Config::get('database.domain').'/undoaction/'.$some_id);
  return Response::json($response);
}

My routes.php includes also the following line:

Route::get('/{name}/doaction/{some_id}', array('as' => 'doaction', 'uses' => 'UserController@doaction'));

I am trying to call this front he frontend:

<a href="" class="tumblerclone-btn"> <i class="glyphicon glyphicon-plus"></i> Do action here </a>

And once its pressed (the URL is echoed properly), it leads me to an error:

Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to a member function doactions() on a non-object

The highlighted code part of the error is:

public function doaction($domain, $some_id)
{
  $user = User::find(Sentry::getUser()->id);
  $user->doactions()->attach($some_id);
  $response = array('message' => 'doactioned', 'url' => 'http://'.$domain.'.'.Config::get('database.domain').'/undoaction/'.$some_id);
  return Response::json($response);
}

Any ideas are appreciated in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire