How to get wage of every month for some user iin php Laravel -


i know tittle sounds confusing, trying wages of user, when user part of project.

i've made way find month. i've separated 1 user , got months separated each other, no figuring out how wage of specific months. 1 wage can of period of month, or few months.

this code i've done far:

function calculatingwageexpenses($project_id, $project_startdate, $project_enddate){      $start_date = $project_startdate;     $end_date = $project_enddate;      $projectobj = project::find($project_id);     $usersobj = $projectobj->users()->get();      foreach ($usersobj $user) {         $timesheethours = 0;         $timesheethours += $user->timesheets()->wherebetween('date', [$start_date, $end_date])->get()->sum('hours');          $wagesobj = userwage::where('user_id', $user->id)->wherebetween('timesheets.date', [$start_date, $end_date]);          $returneddata = extractmonthsandcalculate($start_date, $end_date);     }  }  function extractmonthsandcalculate($start_date, $end_date){       $start = carbon::parse(carbon::createfromformat('y-m-d',$start_date)->todatestring());     $end = carbon::parse(carbon::createfromformat('y-m-d',$end_date)->todatestring());      $diff = $end->diffinmonths($start);      $startmonth =  carbon::createfromformat('y-m-d',$start_date)->month;      $arr = [];      ($i = $startmonth; $i <= $diff; $i++) {         $wageyear  = carbon::createfromformat('y-m-d',$start_date)->year;          $wageday = carbon::createfromdate($wageyear,$i,'01')->lastofmonth()->todatestring();         array_push($arr,$wageday);     }      dd($arr); } 

this how shows months, want find wage of user that's between $start_date , $end_date.

array of months

note: array ($arr) testing show months

wages has these fillables

protected $fillable = [         'value','currency','user_id','start_date','end_date',     ]; 

while user has these

  protected $fillable = [         'email','password','first_name','last_name','status_id','mobile','role',     ]; 

any suggestion?


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -