mercredi 11 juillet 2018

Calling a method inside another method and passing a parameter in a controller

The first method has a condition of the query and it returns the count of the query specified.The 2nd method calls the 1st method. First question, how can i pass the parameter $compid to Method countEmployee from Method userSummary? Second question, Is this the right thing to call method countEmployee inside method userSummary?

1st Method

public function countEmployee($compid){
                    $query = User::query();
                    $company = $query;
                    // $thgarments = $query;
                    $company->whereHas('company', function ($q) {
                        $q->where('company_id','=', $compid);
                    });
                    $company->where('emp_status','=', 'Regular');
                    $totalemployee = $company->count();

                    return $totalemployee;
    }

2nd Method

public function userSummary()
{
     $tenghwa = countEmployee(2);
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire