/** * 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; }
public static function exists($month, $year) { return Cost::where(DB::raw('MONTH(created_at)'), '=', $month)->where(DB::raw('YEAR(created_at)'), '=', $year)->first(); }
public function get($month, $year) { return \App\Models\Cost::where(DB::raw('MONTH(created_at)'), '=', $month)->where(DB::raw('YEAR(created_at)'), '=', $year)->first(); }