I've got a Controller (UsersController) with a function :
public function project_donated($project_id)
{
return Donation
::groupBy('donations.project_id')
->selectRaw('sum(donations.amount) as sum, donations.project_id, projects.*')
->where('donations.project_id', $project_id)
->join('projects', 'donations.project_id', '=', 'projects.id')
->get()
->toArray();
}
This function works fine.
I return this function into the same UserController to my view with :
$project_donated = $this->project_donated($project_id);
return view('users.show', compact('user', 'countries', 'donation_user' , 'user_donated', 'project_donated'));
But, I cannot defind $project_id into my controller, I need to specify it into my view, so into my view, I had this line :
<?php
$project_id = $ngo->project->ngo->id;
$project_donated = UsersController::project_donated($project_id);
?>
But I've got an error : Class 'UsersController' not found.
I'm not sure I'm doing this the right way.
via Kaherdin