Example #1
0
 /**
  * Creates next period end from current one.
  * @param  string $start
  * @return string
  */
 function get_period_end($start)
 {
     $monthGap = 1;
     $start = Carbon\Carbon::createFromFormat('Y-m-d', $start);
     $end = $start->copy()->addMonth();
     if ($end->month - $start->month > $monthGap) {
         $end = $end->subMonths($end->month - $start->month - $monthGap)->endOfMonth();
     }
     return $end->subDay();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Read the database of allied awards
     $csv = Reader::createFromPath(storage_path('app/csv/issued_allied_awards.csv'));
     // This will read the CSV as set of data into the listed array keys
     $data = $csv->fetchAssoc(['playerName', 'playerLabel', 'awardName', 'campaign_id', 'awardedAt', 'submitterName', 'cincName', 'forumSource'], function ($row) {
         // manipulate the incoming data as it is read. This is turn it into
         // a set of data which can be immediately added to our awards table
         $drow = [];
         $drow['playerName'] = trim(strtolower($row[1]));
         $drow['playerLabel'] = trim($row[1]);
         // case as it appears in csv
         $drow['awardName'] = snake_case(strtolower(trim($row[2])));
         $drow['campaign_id'] = trim($row[3]) == '' ? null : trim($row[3]);
         $drow['awardedAt'] = trim($row[6]);
         $drow['submitterName'] = trim(strtolower($row[7]));
         $drow['cincName'] = trim(strtolower($row[8]));
         $drow['forumSource'] = trim(strtolower($row[9]));
         return $drow;
     });
     Player::unguard();
     foreach ($data as $item) {
         $award = Award::where('key', $item['awardName'])->first();
         if ($award == null) {
             Log::info(sprintf('Could not find an award with key %s', $item['awardName']));
             continue;
         }
         $submitter = Player::where('playerName', $item['submitterName'])->first();
         if ($submitter == null) {
             $submitter = Player::create(['playerName' => $item['submitterName'], 'isActive' => true]);
         }
         $cinc = Player::where('playerName', $item['cincName'])->first();
         if ($cinc == null) {
             $cinc = Player::create(['playerName' => $item['cincName'], 'isActive' => true]);
         }
         // check the rype of award we are presenting. If it's a squad award, find the squad and apply it
         // also, if there is a space in the name, its not a player name
         if ($award->awardedTo == 'squad' || preg_match('/\\s/', $item['playerName']) > 0) {
             $squad = Squad::where('key', snake_case($item['playerName']))->first();
             if ($squad == null) {
                 $squad = Squad::create(['key' => snake_case($item['playerName']), 'label' => $item['playerLabel'], 'isActive' => true]);
             }
             $squad->awards()->save($award, ['awardedBy_id' => $submitter->id, 'cinc_id' => $cinc->id, 'campaign_id' => $item['campaign_id'], 'awardedAt' => Carbon\Carbon::createFromFormat('d/m/Y', $item['awardedAt']), 'forumLink' => $item['forumSource']]);
         } else {
             $player = Player::where('playerName', $item['playerName'])->first();
             if ($player == null) {
                 $player = Player::create(['playerName' => $item['playerName'], 'isActive' => true]);
             }
             $player->awards()->save($award, ['awardedBy_id' => $submitter->id, 'cinc_id' => $cinc->id, 'campaign_id' => $item['campaign_id'], 'awardedAt' => Carbon\Carbon::createFromFormat('d/m/Y', $item['awardedAt']), 'forumLink' => $item['forumSource']]);
         }
     }
     Player::reguard();
 }
Example #3
0
function calculate_age($date)
{
    try {
        $result = Carbon\Carbon::createFromFormat('d/m/Y', $date)->diffInYears();
    } catch (\Exception $exception) {
        try {
            $result = Carbon\Carbon::createFromFormat('dmY', $date)->diffInYears();
        } catch (\Exception $exception) {
            $result = 'nascimento: ' . $date;
        }
    }
    return $result;
}
Example #4
0
 /**
  * Prepare a factory generated entity to be sent as input data.
  *
  * @param Arrayable $entity
  *
  * @return array
  */
 protected function prepareEntity($entity)
 {
     // We run the entity through the transformer to get the attributes named
     // as if they came from the frontend.
     $transformer = $this->app->make(\App\Http\Transformers\EloquentModelTransformer::class);
     $entity = $transformer->transform($entity);
     // As the hidden attribute is hidden when we get the array, we need to
     // add it back so it's part of the request.
     $entity['hidden'] = true;
     // And get a reformatted date
     $entity['date'] = Carbon\Carbon::createFromFormat('Y-m-d', substr($entity['date'], 0, 10))->toDateString();
     return $entity;
 }
Example #5
0
 /**
  * Change date time to api ready timestamp
  * 
  * @param  mixed $value Your date time
  * @return int
  */
 function timestamp($value)
 {
     // If this value is an integer,
     // we will assume it is a UNIX timestamp's value
     // and return this value
     if (is_numeric($value)) {
         return $value;
     }
     // If this value is instance of MongoDate
     // we will return 'sec' value from this instance.
     if ($value instanceof MongoDate) {
         return $value->sec;
     }
     // Convert from year, month, day format (Y-m-d)
     // to Carbon instance
     if (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $value)) {
         $value = Carbon\Carbon::createFromFormat('Y-m-d', $value)->startOfDay();
     }
     if ($value instanceof DateTime) {
         return $value->getTimestamp();
     }
     return $value;
 }
Example #6
0
 /**
  * Check whether the selected target is offline or not
  */
 public static function isOffline($target)
 {
     $disabled_ips = static::whereName("disabled_ips")->first();
     if ($disabled_ips) {
         $disabled_ips = explode(' ', $disabled_ips);
         if (in_array(Request::getClientIp(), $disabled_ips)) {
             // If the current IP address is in the list of disabled
             // IP addresses, then deny access
             return true;
         }
     }
     $setting = static::whereName("{$target}_offline")->first();
     // dd($setting->value);
     if (!$setting || $setting->value == 'no') {
         return false;
     } else {
         $offline_end = static::whereName("{$target}_offline_end")->first();
         if ($offline_end->value == '' or Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $offline_end->value) > Carbon\Carbon::now()) {
             return true;
         } else {
             return false;
         }
     }
 }
Example #7
0
/**
 * Create a carbon instance from a string.
 *
 * @param string $date
 * @param string $format
 *
 * @return \Carbon\Carbon
 */
function carbon($date, $format = 'Y-m-d H:i:s')
{
    return Carbon\Carbon::createFromFormat($format, $date);
}
 public function submit_edit_activo()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         // Verifico si el usuario es un Webmaster
         if ($data["user"]->idrol == 1 || $data["user"]->idrol == 2 || $data["user"]->idrol == 3 || $data["user"]->idrol == 4) {
             // Validate the info, create rules for the inputs
             $attributes = array('servicio_clinico' => 'Servicio Clínico', 'ubicacion_fisica' => 'Ubicación Física', 'grupo' => 'Grupo', 'marca' => 'Marca', 'nombre_equipo' => 'Nombre del Equipo', 'modelo' => 'Modelo', 'numero_serie' => 'Número de Serie', 'proveedor' => 'Proveedor', 'codigo_compra' => 'Código de Compra', 'codigo_patrimonial' => 'Código Patrimonial', 'fecha_adquisicion' => 'Fecha de Adquisición', 'garantia' => 'Garantía', 'idreporte_instalacion' => 'Código de Reporte de Instalación', 'costo' => 'Precio de Compra');
             $messages = array();
             $rules = array('servicio_clinico' => 'required', 'ubicacion_fisica' => 'required', 'grupo' => 'required', 'numero_serie' => 'required', 'proveedor' => 'required', 'fecha_adquisicion' => 'required', 'garantia' => 'required|numeric', 'costo' => 'required|numeric');
             // Run the validation rules on the inputs from the form
             $validator = Validator::make(Input::all(), $rules, $messages, $attributes);
             // If the validator fails, redirect back to the form
             if ($validator->fails()) {
                 $equipo_id = Input::get('equipo_id');
                 $url = "equipos/edit_equipo" . "/" . $equipo_id;
                 return Redirect::to($url)->withErrors($validator)->withInput(Input::all());
             } else {
                 $equipo_id = Input::get('equipo_id');
                 //$url = "equipos/edit_equipo"."/".$equipo_id;
                 $activo = Activo::find($equipo_id);
                 $activo->numero_serie = Input::get('numero_serie');
                 $activo->anho_adquisicion = date('Y-m-d', strtotime(Input::get('fecha_adquisicion')));
                 $activo->garantia = Input::get('garantia');
                 $activo->fecha_garantia_fin = Carbon\Carbon::createFromFormat('Y-m-d', $activo->anho_adquisicion)->addMonths($activo->garantia);
                 $activo->idgrupo = Input::get('grupo');
                 $activo->idservicio = Input::get('servicio_clinico');
                 $activo->idproveedor = Input::get('proveedor');
                 $activo->idestado = 1;
                 $activo->idubicacion_fisica = Input::get('ubicacion_fisica');
                 $activo->costo = Input::get('costo');
                 $activo->save();
                 return Redirect::to('equipos/list_equipos')->with('message', 'Se editó correctamente el equipo.');
             }
         } else {
             return View::make('error/error', $data);
         }
     } else {
         return View::make('error/error', $data);
     }
 }
Example #9
0
 public function getUpdatedAtAttribute($updated_at)
 {
     return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $updated_at)->format('m/d/Y');
 }
Example #10
0
 public function access_to_role_list(FunctionalTester $I)
 {
     $I->am('Admin');
     $I->wantTo('access to the permissions list');
     $I->expectTo('see the permissions list');
     /***************************************************************************************************************
      * settings
      **************************************************************************************************************/
     // we create the admin role
     $admin = $this->_createAdminRole();
     // we attach it to the logged user
     $admin->users()->attach($this->_user);
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     $I->amOnPage('/');
     $I->seeCurrentRouteIs('home');
     $I->click(trans('template.front.header.my_account'));
     $I->seeCurrentRouteIs('dashboard.index');
     $I->click(trans('template.back.header.permissions'));
     $I->seeCurrentRouteIs('permissions.index');
     $I->see(trans('breadcrumbs.admin'), '.breadcrumb');
     $I->seeLink(trans('breadcrumbs.admin'), route('dashboard.index'));
     $I->see(trans('breadcrumbs.permissions.index'), '.breadcrumb');
     $I->see(trans('permissions.page.title.management'));
     $I->see(trans('permissions.page.title.list'));
     $I->see($admin->name, '.table-list');
     $I->see($admin->slug, '.table-list');
     $I->see($admin->position, '.table-list');
     $I->see(Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $admin->created_at)->format('d/m/Y H:i:s'), '.table-list');
     $I->see(Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $admin->updated_at)->format('d/m/Y H:i:s'), '.table-list');
     $I->see(strip_tags(trans('global.table_list.results.status', ['start' => 1, 'stop' => 1, 'total' => 1])));
 }
Example #11
0
    <script type="text/javascript" src="{!! URL::to('assets/shared/countdown/jquery.countdown.min.js')!!}"></script>
</head>
<body>

    <div id="container">
        <h1>Site Offline</h1>

        <div>
            {!! Setting::value('offline_message') !!}
        </div>

        <!-- START COUNTDOWN -->
        <script src="{!! URL::to('assets/shared/countdown/countdown.js') !!}" type="text/javascript"></script>
        <?php 
$offline_end = Setting::value("{$link_type}_offline_end");
$offline_end = $offline_end ? Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $offline_end) : '';
?>

        @if ($offline_end)
            <div>
                <h3>We'll be online in:</h3>
                <div id="countdown"></div>
            </div>

            <script type="application/javascript">

                $('#countdown').countdown({
                        until: new Date({!! $offline_end->year !!}, {!! $offline_end->month !!}-1, {!! $offline_end->day !!}, {!! $offline_end->hour !!}, {!! $offline_end->minute !!}, {!! $offline_end->second !!}),
                        onExpiry: reloadPage
                    });
Example #12
0
    $out .= '<i class="fa fa-undo"></i> &nbsp;' . $text;
    $out .= '</button>';
    $out .= Form::close();
    return $out;
});
Form::macro('edit', function ($route, $id, $text = '', $tooltip = false) {
    $model = explode('.', $route);
    $model = ucfirst(substr($model[1], 0, -1));
    $tooltip = $tooltip ? $tooltip : 'Editar ' . $model;
    $out = '<a data-toggle="tooltip" data-placement="top" data-original-title="' . $tooltip . '" href="' . route($route . '.edit', $id) . '" class="btn btn-fw btn-success btn-sm">';
    $out .= '<i class="fa fa-pencil"></i> &nbsp;' . $text;
    $out .= '</a>';
    return $out;
});
HTML::macro('dataBr', function ($data_from_bd) {
    return Carbon\Carbon::createFromFormat('Y-m-d', $data_from_bd)->format('d/m/Y');
});
HTML::macro('cancel', function ($route, $title = 'Cancelar', $tooltip = '') {
    $out = '<a href="' . route($route . '.index') . '" class="btn btn-info btn-sm">';
    $out .= $title;
    $out .= '</a>';
    return $out;
});
HTML::macro('details', function ($route, $id, $title = '', $tooltip = false) {
    $model = explode('.', $route);
    $model = ucfirst(substr($model[1], 0, -1));
    $tooltip = $tooltip ? $tooltip : 'Ver ' . $model;
    $out = '<a href="' . route($route . '.show', [$id]) . '" class="btn btn-fw btn-info btn-sm" data-toggle="tooltip" data-original-title="' . $tooltip . '">';
    $out .= '<i class="fa fa-info-circle"></i> &nbsp;' . $title;
    $out .= '</a>';
    return $out;
Example #13
0
function _startDate($dat, $option)
{
    return ++$dat;
    return $dat;
    $date = Carbon\Carbon::createFromFormat('Y-m-d', $dat);
    if ($date->year == $option->start_year) {
        $temp = $date->month;
    } else {
        $temp = ($date->year - $option->start_year) * 12 + $date->month;
    }
    return $temp - $option->start_mounth + 1;
}
Example #14
0
 function datetime($time)
 {
     return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $time)->format(config('site.date_time_format', 'm/d/Y g:i a'));
 }
Example #15
0
 public function getUpdatedAtAttribute($date)
 {
     return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('c');
 }
Example #16
0
 function to_carbon($value, $alternateFormat = null, $defaultTime = null)
 {
     // If it's already a Carbon object, return it.
     if ($value instanceof Carbon\Carbon) {
         return $value;
     }
     // If this value is an integer, we will assume it is a UNIX timestamp's value
     // and format a Carbon object from this timestamp. This allows flexibility
     // when defining your date fields as they might be UNIX timestamps here.
     if (is_numeric($value)) {
         return Carbon\Carbon::createFromTimestamp($value);
     }
     $value = str_replace('/', '-', $value);
     $value = str_replace('\\', '-', $value);
     // Try to convert it using strtotime().
     if (($date = strtotime($value)) !== false) {
         return Carbon\Carbon::createFromTimestamp($date);
     } elseif (!$value instanceof DateTime) {
         $alternateFormat = $alternateFormat ?: 'Y-m-d H:i:s';
         return Carbon\Carbon::createFromFormat($alternateFormat, $value);
     }
     return Carbon\Carbon::instance($value);
 }
Example #17
0
function carbon(string $date, string $format = 'Y-m-d H:i:s') : Carbon\Carbon
{
    return Carbon\Carbon::createFromFormat($format, $date);
}
 /**
  * Create a new Submission for the given user
  *
  * @return Response
  */
 public function addNewSubmission()
 {
     $data = Input::all();
     // dd($data);
     // $data['date'] = Carbon\Carbon::createFromFormat('m/d/Y H:i:s', $data['newDate'].' 09:00:00');
     $data['created_at'] = Carbon\Carbon::createFromFormat('m/d/Y H:i:s', $data['newDate'] . ' 09:00:00');
     $data['updated_at'] = Carbon\Carbon::createFromFormat('m/d/Y H:i:s', $data['newDate'] . ' 09:00:00');
     $validator = Validator::make($data, Submission::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     try {
         $result = RideShareLogModel::postSubmissionData();
         Session::flash('alert_success', 'Successfully saved New Submission.');
         return Redirect::to('/admin#user='******'submission']['user_id']);
     } catch (\Exception $e) {
         Session::flash('alert_danger', 'Failed to save New Submission: ' . $e->getMessage());
         return Redirect::to('/admin#user='******'user_id'));
     }
 }
Example #19
0
<?php

$carbon = new \Carbon\Carbon();
$carbon->setLocale('ru');
$date_register = $carbon->createFromFormat('Y-m-d H:i:s', $this->userinfo->created_at, 'UTC');
?>
<div id="js-page-profile">
    <div class="title-block">
        <h3 class="title">Профиль</h3>
    </div>

    <div class="row">
        <div class="col-xs-4 col-md-6">
            <div class="card card-default">
                <div class="card-header">
                    <div class="header-block">
                        <p class="title">Мои данные</p>
                    </div>
                </div>
                <div class="card-block">
                    <table class="table table-striped table-hover table-sm">
                        <tbody>
                            <tr>
                                <td>#ID:</td>
                                <td><strong><?php 
echo $this->userinfo->uid;
?>
</strong></td>
                            <tr>
                            </tr>
                                <td>Дата регистрации:</td>
function dateAsFinnish($date)
{
    return Carbon\Carbon::createFromFormat('Y-m-d', $date)->format('d.m.Y');
}
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('periods')->delete();
     $carbon = new \Carbon\Carbon();
     $format = 'Y-m-d H:i:s';
     $dur = 5;
     $p_start = '2015-11-01 15:00:00';
     $periods = [];
     for ($i = 1; $i <= 4; ++$i) {
         if ($i == 1) {
             $periods[$i] = ['start' => $p_start, 'end' => $carbon->createFromFormat($format, $p_start)->addDays($dur)];
         } else {
             $periods[$i] = ['start' => $periods[$i - 1]['end'], 'end' => $carbon->createFromFormat($format, $periods[$i - 1]['end'])->addDays($dur)];
         }
     }
     DB::table('periods')->insert($periods);
 }
Example #22
-1
 function datetime($time)
 {
     try {
         return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $time)->format(config('site.date_time_format', 'm/d/Y g:i a'));
     } catch (InvalidArgumentException $e) {
         return;
     }
 }
Example #23
-1
function _toTime($value, $format = 'd.m.Y H:i:s', $default = '-')
{
    if (empty($value)) {
        return $default;
    }
    $value = substr($value, 0, 19);
    return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $value)->format($format);
}
 function npmso_email_date_format($date)
 {
     if (actually_empty($date)) {
         return null;
     }
     $carbon_date = Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date);
     return $carbon_date->format('D, M j, Y');
 }