예제 #1
0
 /**
  * Handle the command.
  *
  * @param  UpdateTotalCommand  $command
  * @return void
  */
 public function handle(UpdateTotalCommand $command)
 {
     $cost = Cost::where(DB::raw('MONTH(created_at)'), '=', $command->month)->where(DB::raw('YEAR(created_at)'), '=', $command->year)->first();
     if (!empty($cost)) {
         $cost->spend = $command->spend;
         $cost->income = $command->income;
         if ($cost->save()) {
             return $cost;
         }
     }
     return false;
 }
예제 #2
0
파일: Cost.php 프로젝트: nq2916/savings
 public static function exists($month, $year)
 {
     return Cost::where(DB::raw('MONTH(created_at)'), '=', $month)->where(DB::raw('YEAR(created_at)'), '=', $year)->first();
 }
예제 #3
0
파일: Cost.php 프로젝트: nq2916/savings
 public function get($month, $year)
 {
     return \App\Models\Cost::where(DB::raw('MONTH(created_at)'), '=', $month)->where(DB::raw('YEAR(created_at)'), '=', $year)->first();
 }