public static function insert($data) { try { $props = ['product_id' => $data['product_id'], 'photo_name' => $data['photo_name'], 'rank' => Model_Photo::query()->where(array('product_id' => $data['product_id']))->max('rank') + 1, 'created_at' => date('Y-m-d H:i:s', Date::forge()->get_timestamp())]; $new = Model_Photo::forge($props); $new->save(); return $new->id; } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); return false; } }