public function update(ServiceMonth $service_month, Request $request)
 {
     $input['hours_used'] = $request->input('hours_logged');
     $input['description'] = $request->input('description');
     $service_month->update($input);
     return $service_month->toJson();
 }
Пример #2
0
 private static function generateServiceMonths($plan)
 {
     $plan_id = $plan->id;
     $month = $plan->start_date->format('m');
     for ($i = 0; $i < 12; $i++) {
         $first_of_month = Carbon::createFromDate($plan->start_date->format('Y'), $month++, 1);
         $args = ['start_date' => $first_of_month, 'service_plan_id' => $plan_id, 'client_id' => $plan->client_id];
         if ($first_of_month < \Carbon\Carbon::now()) {
             $args['hours_used'] = 0;
         }
         ServiceMonth::create($args);
     }
 }
Пример #3
0
 /** @test */
 public function it_generates_pretty_name_based_on_start_date()
 {
     $plan = factory(\RTMatt\MonthlyService\ServicePlan::class)->create();
     $month = \RTMatt\MonthlyService\ServiceMonth::create(['service_plan_id' => $plan->id, 'client_id' => $plan->client_id, 'start_date' => Carbon::now()]);
     $this->assertEquals(Carbon::now()->format('M'), $month->pretty_name);
 }