Ejemplo n.º 1
0
 public function diffForHumans(Carbon $other = null)
 {
     $isNow = $other === null;
     if ($isNow) {
         $other = static::now($this->tz);
     }
     $isFuture = $this->gt($other);
     $delta = $other->diffInSeconds($this);
     // 4 weeks per month, 365 days per year... good enough!!
     $divs = array('second' => self::SECONDS_PER_MINUTE, 'minute' => self::MINUTES_PER_HOUR, 'hour' => self::HOURS_PER_DAY, 'day' => self::DAYS_PER_WEEK, 'week' => 4, 'month' => self::MONTHS_PER_YEAR);
     $unit = 'year';
     foreach ($divs as $divUnit => $divValue) {
         if ($delta < $divValue) {
             $unit = $divUnit;
             break;
         }
         $delta = floor($delta / $divValue);
     }
     if ($delta == 0) {
         $delta = 1;
     }
     // Código adaptado para utilizar el gestor de idiomas de Laravel
     $txt = 'carbonlocale';
     if ($isFuture) {
         return Lang::choice("{$txt}.future.{$unit}", $delta, compact('delta'));
     }
     return Lang::choice("{$txt}.past.{$unit}", $delta, compact('delta'));
 }
Ejemplo n.º 2
0
 public function pluginCallback()
 {
     $params = func_get_args();
     $value = array_shift($params);
     if (isset($params[0])) {
         return Lang::choice($value, $params[0]);
     }
     return Lang::get($value);
 }
Ejemplo n.º 3
0
 /**
  * Converts a number of seconds into a more human readable format.
  *
  * @param  int    $seconds The number of seconds
  * @return string
  */
 public function presentReadableRuntime()
 {
     if (!$this->object instanceof RuntimeInterface) {
         throw new \RuntimeException('Model must implement RuntimeInterface');
     }
     $seconds = $this->object->runtime();
     $units = ['week' => 7 * 24 * 3600, 'day' => 24 * 3600, 'hour' => 3600, 'minute' => 60, 'second' => 1];
     if ($seconds === 0) {
         return Lang::choice('deployments.second', 0, ['time' => 0]);
     }
     $readable = '';
     foreach ($units as $name => $divisor) {
         if ($quot = intval($seconds / $divisor)) {
             $readable .= Lang::choice('deployments.' . $name, $quot, ['time' => $quot]) . ', ';
             $seconds -= $quot * $divisor;
         }
     }
     return substr($readable, 0, -2);
 }
Ejemplo n.º 4
0
 /**
  * Confirm the registration procedure through a code control
  *
  * @return \Illuminate\View\View
  *
  */
 public function verifyUser($code)
 {
     if (!$code) {
         $data['errore'] = true;
         $data['titolo'] = Lang::choice("messages.errore", 0);
         $data['conferma'] = Lang::choice('messages.errore_signin', 0);
         return view('auth.confirm', $data);
     }
     $user = $this->user->where('codice_conferma', '=', $code)->first();
     if (!$user) {
         $data['errore'] = true;
         $data['titolo'] = Lang::choice("messages.errore", 0);
         $data['conferma'] = Lang::choice('messages.errore_signin', 0);
         return view('auth.confirm', $data);
     } else {
         $user->confermato = true;
         $user->codice_conferma = null;
         $user->save();
         $data['conferma'] = Lang::choice('messages.conferma_testo', 0);
         $data['errore'] = false;
         $data['titolo'] = Lang::choice('messages.conferma_titolo', 0);
         return view('auth.confirm', $data);
     }
 }
Ejemplo n.º 5
0
 public function NotifyUserForPlanExpire()
 {
     $response = new ServiceResponse();
     $Plans = DB::select("SELECT pph.UserID, DATEDIFF(pph.EndDate, CURRENT_DATE()) AS TimeLeft, pph.PlanName FROM paymentplanshistory pph LEFT JOIN paymentplanshistory pph2 ON pph.UserID = pph2.UserID AND DATEDIFF(pph2.StartDate, pph.EndDate)=1\nWHERE pph.IsActive = 1 AND IFNULL(pph2.PaymentHistoryID,'') = '' AND DATEDIFF(pph.EndDate, CURRENT_DATE()) IN (0,3,5,7)");
     if ($Plans && count($Plans) > 0) {
         foreach ($Plans as $Plan) {
             $message = Lang::choice("messages.PlanWillExpireInDays", $Plan->TimeLeft, array("plan" => $Plan->PlanName, "day" => $Plan->TimeLeft));
             $userNotificationEntity = new UserNotificationEntity();
             $userNotificationEntity->Description = $message;
             $userNotificationEntity->UserID = $Plan->UserID;
             $userNotificationEntity->CreatedDate = date(Constants::$DefaultDateTimeFormat);
             $userNotificationEntity->save();
             $notificationEntity = new NotificationEntity();
             $notificationEntity->UserID = $Plan->UserID;
             $notificationEntity->NotificationType = Constants::$NotificationType['General'];
             $notificationEntity->Message = $message;
             $notificationEntity->CreatedDate = date(Constants::$DefaultDateTimeFormat);
             $notificationEntity->save();
         }
         $response->IsSuccess = true;
     }
     return $response;
 }
Ejemplo n.º 6
0
 public function testChoice()
 {
     $this->assertEquals('Articles', Lang::choice('content::messages.article', 10, [], 'en'));
 }
 /**
  * Get language helper functions.
  *
  * @return array
  */
 protected function getLanguageHelpers()
 {
     return ['lang' => function ($args, $named) {
         return Lang::get($args[0], $named);
     }, 'choice' => function ($args, $named) {
         return Lang::choice($args[0], $args[1], $named);
     }];
 }
Ejemplo n.º 8
0
 public function compose($view)
 {
     $view->title = trans(Route::currentRouteName() . '_title');
     $view->text_total = Lang::choice('tickets.total', $view->tickets->total(), ['title' => strtolower($view->title)]);
 }
 /**
  * Get language helper functions.
  *
  * @return array
  */
 protected function getLanguageHelpers()
 {
     return ['lang' => function ($args, $named) {
         return \Illuminate\Support\Facades\Lang::get($args[0], $named);
     }, 'choice' => function ($args, $named) {
         return \Illuminate\Support\Facades\Lang::choice($args[0], $args[1], $named);
     }];
 }
Ejemplo n.º 10
0
 public function postCompensation(Request $request)
 {
     if ($request->has('id') && $request->has('end_repair')) {
         $id = $request->get('id');
         $end_repair = str_replace('.', '-', $request->get('end_repair'));
         $end_repair = Carbon::parse($end_repair)->timestamp;
         $compensation = Compensation::find($id);
         if ($end_repair > $compensation->shift_end) {
             $end_repair = $compensation->shift_end;
         }
         if ($compensation->begin > $end_repair) {
             return 'Введенные данные не были правильны пожалуйста повторите';
         }
         $price_for_one_second = $compensation->shift_sum / ($compensation->shift_end - $compensation->shift_start);
         $in_repair_second = $end_repair - $compensation->begin;
         $sum = round($price_for_one_second * $in_repair_second, 2);
         $driver = Driver::getDriverInfoByCar($this->city->db, $compensation->gn);
         if (empty($driver)) {
             return 'Извините водитель не найден на такой машине';
         }
         //driver operations here
         $compensation->end = $end_repair;
         $compensation->save();
         $user = $request->user();
         $difference = Carbon::createFromTimestamp($end_repair)->diffInHours(Carbon::createFromTimestamp($compensation->begin));
         if ($difference == 0) {
             $difference = Carbon::createFromTimestamp($end_repair)->diffInMinutes(Carbon::createFromTimestamp($compensation->begin));
             $log_description = $user->name . " компенсировал водителю {$compensation->gn} за {$difference} мин";
         } else {
             $log_description = $this->getRole($user) . " " . $user->name . " компенсировал водителю {$compensation->gn} за {$difference} " . Lang::choice('message.times', $difference, [], 'ru');
         }
         $user->userLogs('compensation', $user->name, $log_description, $this->city->index);
         return "Компенсация в размере {$sum} за {$difference} часов";
     }
     return 'Извините произошла ошибка повторите позже';
 }