/** * @param $string * @param null $path * @return string */ public function parse($string, $path = null) { $headers = []; $parts = preg_split('/[\\n]*[-]{3}[\\n]/', $string, 3); if (count($parts) == 3) { $string = $parts[0] . "\n" . $parts[2]; $headers = $this->yaml->parse($parts[1]); } $file = new SplFileInfo($path, '', ''); $date = Carbon::createFromTimestamp($file->getMTime()); $dateFormat = config('fizl-pages::date_format', 'm/d/Y g:ia'); $headers['date_modified'] = $date->toDateTimeString(); if (isset($headers['date'])) { try { $headers['date'] = Carbon::createFromFormat($dateFormat, $headers['date'])->toDateTimeString(); } catch (\InvalidArgumentException $e) { $headers['date'] = $headers['date_modified']; //dd($e->getMessage()); } } else { $headers['date'] = $headers['date_modified']; } $this->execute(new PushHeadersIntoCollectionCommand($headers, $this->headers)); $viewPath = PageHelper::filePathToViewPath($path); $cacheKey = "{$viewPath}.headers"; $this->cache->put($cacheKey, $headers); return $string; }
public function whole() { $before = Input::get('period'); if (!empty($before)) { $before = Carbon::createFromTimestamp(strtotime('tomorrow') - (int) $before * 24 * 60 * 60)->toDateTimeString(); } $totalOrders = $this->orderRepo->countAll($before); $totalCustomers = $this->userRepo->countAllCustomers($before); $totalLeads = $this->leadRepo->countAll($before); $totalSystemUsers = $this->userRepo->countAllUsers($before); $totalUndefinedLeads = $this->leadRepo->countWithQuery($before, ['status' => 0]); $totalSuccessfulLeads = $this->leadRepo->countWithQuery($before, ['status' => 1]); $totalUnsuccessfulLeads = $this->leadRepo->countWithQuery($before, ['status' => -1]); $totalPendingLeads = $this->leadRepo->countWithQuery($before, ['status' => 2]); $generalPanelOrders = $this->orderRepo->countWithQuery($before, ['panel_type' => 0]); $experimentalPanels = $this->orderRepo->countWithQuery($before, ['panel_type' => 2]); $freePanels = $this->orderRepo->countWithQuery($before, ['panel_type' => 1]); $couponPanels = $this->orderRepo->countWithQuery($before, ['panel_type' => 3]); $panelLess = $this->orderRepo->countWithQuery($before, ['panel_type' => 4]); $hasPanels = $this->orderRepo->countWithQuery($before, ['panel_type' => 5]); $completedOrders = $this->orderRepo->countWithQuery($before, ['completed' => 1]); $fromLeadCustomers = $this->userRepo->countWithLead($before); $totalPanelPrice = $this->orderRepo->sumPanelPrice($before); return $this->view('admin.pages.stat.whole', compact('totalOrders', 'totalLeads', 'totalSystemUsers', 'totalCustomers', 'totalUndefinedLeads', 'totalSuccessfulLeads', 'totalPendingLeads', 'totalUnsuccessfulLeads', 'generalPanelOrders', 'experimentalPanels', 'freePanels', 'couponPanels', 'panelLess', 'hasPanels', 'completedOrders', 'fromLeadCustomers', 'totalPanelPrice')); }
/** * Series constructor. * * @param $data */ public function __construct($data) { $this->id = (int) $data->id; $this->language = (string) $data->Language; $this->name = (string) $data->SeriesName; $this->banner = (string) $data->banner; $this->overview = (string) $data->Overview; $this->firstAired = (string) $data->FirstAired !== '' ? Carbon::createFromFormat('Y-m-d', (string) $data->FirstAired)->toDateString() : null; $this->imdbId = (string) $data->IMDB_ID; if (isset($data->Actors)) { $this->actors = (array) TVDB::removeEmptyIndexes(explode('|', (string) $data->Actors)); } $this->airsDayOfWeek = (string) $data->Airs_DayOfWeek; $this->airsTime = (string) $data->Airs_Time; $this->contentRating = (string) $data->ContentRating; if (isset($data->Genre)) { $this->genres = (array) TVDB::removeEmptyIndexes(explode('|', (string) $data->Genre)); } $this->network = (string) $data->Network; $this->rating = (double) $data->Rating; $this->ratingCount = (int) $data->RatingCount; $this->runtime = (int) $data->Runtime; $this->status = (string) $data->Status; if (isset($data->added)) { // $this->added = Carbon::createFromFormat('Y-m-d H:i:s', (string)$data->added)->toDateTimeString(); } $this->fanArt = (string) $data->fanart; $this->lastUpdated = Carbon::createFromTimestamp((int) $data->lastupdated)->toDateTimeString(); $this->poster = (string) $data->poster; $this->zap2itId = (string) $data->zap2it_id; if (isset($data->AliasNames)) { $this->aliasNames = (array) TVDB::removeEmptyIndexes(explode('|', (string) $data->AliasNames)); } }
/** * @param $postData * @return mixed */ public static function normalize(&$postData) { $postId = sprintf('%d_%d', $postData['from_id'], $postData['id']); $post = PostModel::firstOrNew(['external_id' => $postId]); self::$__count_imports_posts++; if (!$post->id) { self::$__count_imports_new_posts++; } $text = ''; if ($postData['post_type'] == 'copy') { $text = isset($postData['copy_text']) && !empty($postData['copy_text']) ? $postData['copy_text'] : ''; } $text .= !empty($text) && !empty($postData['text']) ? '<br>' : ''; $text .= !empty($postData['text']) ? $postData['text'] : ''; $post->date = Carbon::createFromTimestamp($postData['date']); $post->text = $text; $post->save(); // dump($text, $post->text); if (isset($postData['attachments'])) { $attachments = self::attachmentsPost($postData['attachments']); if (sizeof($attachments) > 0) { $post->attachments()->sync($attachments, false); } } return $post; }
/** @test */ public function it_formats_given_datetime_and_carbon_instance() { $date = (new DateTime())->setTimestamp(1458779168); $this->assertEquals('Mar 24 2016', $this->helper->dateFormat($date)); $date = Carbon::createFromTimestamp(1458779168); $this->assertEquals('Mar 24 2016', $this->helper->dateFormat($date)); }
/** * @covers ::convert */ public function testConvert() { $test1 = Converter::convert(Calends::create(0, 'unix')); $this->assertEquals(['start' => Carbon::createFromTimestamp(0), 'duration' => \Carbon\CarbonInterval::seconds(0), 'end' => Carbon::createFromTimestamp(0)], $test1); $test2 = Converter::convert(Calends::create(['start' => 0, 'end' => 86400], 'unix')); $this->assertEquals(['start' => Carbon::createFromTimestamp(0), 'duration' => \Carbon\CarbonInterval::seconds(86400), 'end' => Carbon::createFromTimestamp(86400)], $test2); }
public function getSelfInstagrams() { $url = 'https://api.instagram.com/v1/users/self/media/recent/?access_token=' . env('INSTAGRAM_ACCESS_TOKEN'); $content = file_get_contents($url); $json = json_decode($content, true); foreach ($json['data'] as $images) { $imgUrl = $images['images']['standard_resolution']['url']; $description = $images['caption']['text']; $datetime_posted = $images['caption']['created_time']; $datetime_posted = Carbon::createFromTimestamp($datetime_posted)->toDateTimeString(); $username = $images['caption']['from']['username']; $profilePic = $images['caption']['from']['profile_picture']; $link = $images['link']; if (SocialMedia::where('imgUrl', $imgUrl)->exists()) { echo "This post already exists"; } else { $insta = new SocialMedia(); $insta->username = $username; $insta->profile_pic_url = $profilePic; $insta->tweet = 'N/A'; $insta->caption = $description; $insta->imgUrl = $imgUrl; $insta->message = 'N/A'; $insta->source = 'Admin-Insta'; $insta->link = $link; $insta->resize = 'fit'; $insta->approved = 'Approved'; $insta->approver_id = -1; $insta->datetime_posted = $datetime_posted; $insta->save(); echo "Saved!"; } } }
public function adminIndexAll() { $posts = Post::orderBy('updated_at', 'desc')->paginate(); return View::make('admin.dicts.list', ['columns' => ['ID', 'Пользователь', 'Текст', 'Рубрика', 'Лайки', 'Комментарии', 'Время', '', ''], 'data' => $posts->transform(function ($post) { return ['id' => $post->id, 'user' => link_to("admin/users{$post->user_id}", $post->user->name), 'text' => link_to("admin/posts/{$post->id}/edit", $post->text), 'category' => link_to("/admin/categories/{$post->category_id}/edit", $post->category->title), 'likes' => link_to("admin/posts/{$post->id}/likes", $post->likes->count()), 'comments' => link_to("admin/posts/{$post->id}/comments", $post->comments->count()), 'time' => Carbon::createFromTimestamp($post->created_at), 'edit' => link_to("/admin/posts/{$post->id}/edit", 'редактировать'), 'delete' => link_to("/admin/posts/{$post->id}/delete", 'удалить')]; }), 'actions' => [['link' => 'admin/posts/delete', 'text' => 'Удалить выбранное']], 'links' => $posts->links(), 'title' => 'Посты']); }
public function cleanValue($value) { switch ($this->typeName) { case "number": return floatval($value); break; case "string": return "" . $value; break; case "datetime": $timezone = isset($this->options['timezone']) ? $this->options['timezone'] : "UTC"; // Assuming that the value that client has given is in UTC $timeObject = Carbon::createFromTimestamp(intval($value), "UTC"); // Now convert this into the target timezone $timeObject->setTimezone($timezone); return $timeObject; break; case "date": $date = date_create($value); $date = date_format($date, 'm-d-Y'); return $date; break; default: throw new \Exception("Unknown type {$this->typeName}"); } }
/** * Returns a thread and its replies to the client. * * @var Board $board * @var integer|null $thread * @return Response */ public function getThread(Request $request, Board $board, $thread) { if (is_null($thread)) { return abort(404); } $input = $request->only('updatesOnly', 'updateHtml', 'updatedSince'); if (isset($input['updatesOnly'])) { $updatedSince = Carbon::createFromTimestamp($request->input('updatedSince', 0)); $posts = Post::where('posts.board_uri', $board->board_uri)->withEverything()->where(function ($query) use($thread) { $query->where('posts.reply_to_board_id', $thread); $query->orWhere('posts.board_id', $thread); })->where(function ($query) use($updatedSince) { $query->where('posts.updated_at', '>=', $updatedSince); $query->orWhere('posts.deleted_at', '>=', $updatedSince); })->withTrashed()->orderBy('posts.created_at', 'asc')->get(); if (isset($input['updateHtml'])) { foreach ($posts as $post) { $appends = $post->getAppends(); $appends[] = "html"; $post->setAppends($appends); } } return $posts; } else { // Pull the thread. $thread = $board->getThreadByBoardId($thread); if (!$thread) { return abort(404); } } return $thread; }
/** * @return Carbon */ protected function getOldTime() { if (!isset($this->oldTime)) { $this->oldTime = Carbon::createFromTimestamp(Setting::get('old-data')); } return $this->oldTime; }
public function scopeReporte($query, $arre) { //05/02/2016 //26/09/2016 // dd(\Carbon\Carbon::createFromFormat('d/m/Y',$arre['aprobado']['desde'])); if ($arre['Rdesde'] != "" && $arre['Rhasta'] != "") { $desde = \Carbon\Carbon::createFromTimestamp($arre['Rdesde'])->toDateTimeString(); $hasta = \Carbon\Carbon::createFromFormat('d/m/Y', $arre['Rhasta']); echo "<pre>"; var_dump($hasta->date); exit; $query->whereBetween('created_at', [$desde, $hasta]); /* $query->join('recepcion','recepcion.id','=','solicitudes.id_trecepcion') ->where('recepcion.id',7);*/ } if ($arre['aprobado']['desde'] != "" && $arre['aprobado']['hasta'] != "") { $desde1 = \Carbon\Carbon::createFromFormat('d/m/Y', $arre['aprobado']['desde']); $hasta2 = \Carbon\Carbon::createFromFormat('d/m/Y', $arre['aprobado']['hasta']); $date = \Carbon\Carbon::createFromFormat('d/m/Y', '26/01/2016'); //$hasta2 = \Carbon\Carbon::parse($arre['aprobado']['hasta'])->toDateTimeString(); // dd($desde1,$hasta2); // dd($date); $nem = \App\Models\Solicitudes::whereBetween('created_at', ['2016-01-26 00:00:00', '2016-01-26 00:00:00'])->get(); dd($nem); $query->join('usuarios_solicitudes', 'usuarios_solicitudes.id_solicitud', '=', 'solicitudes.id')->where('solicitudes.estatus', 3); // ->whereBetween('usuarios_solicitudes.fecha_registro', [$desde1, $hasta2]); } }
public function getCost(Request $request) { $credentials = new Aws\Credentials\Credentials(env('AWS_KEY'), env('AWS_SECRET')); $client = Ec2Client::factory(array('credentials' => $credentials, 'version' => 'latest', 'region' => $request->input('region'))); $terminate = Carbon::parse($request->input('terminateTime')); $terminateTime = Carbon::parse($request->input('terminateTime')); $terminate->minute = 00; $terminate->second = 00; $terminate->addHour(); $launch = Carbon::parse($request->input('launchTime')); $launchTime = Carbon::parse($request->input('launchTime')); $launch->minute = 00; $launch->second = 00; //$client = \AWS::createClient('ec2'); $result = $client->describeSpotPriceHistory(['AvailabilityZone' => $request->input('availabilityZone'), 'DryRun' => false, 'StartTime' => $launch, 'EndTime' => $terminate, 'InstanceTypes' => [$request->input('instanceType')], 'ProductDescriptions' => ['Linux/UNIX']]); $total_cost = 0.0; $total_seconds = $launch->diffInSeconds($terminate); $total_hours = $total_seconds / (60 * 60); $last_time = $terminate; $computed_seconds = 0; foreach ($result['SpotPriceHistory'] as $price) { $price['SpotPrice'] = floatval($price['SpotPrice']); $available_seconds = new Carbon($last_time = $price['Timestamp']); $available_seconds = $available_seconds->diffInSeconds(Carbon::createFromTimestamp(0)); $remaining_seconds = $total_seconds - $computed_seconds; $used_seconds = min($available_seconds, $remaining_seconds); $total_cost = $total_cost + $price['SpotPrice'] / (60 * 60) * $used_seconds; $computed_seconds = $computed_seconds + $used_seconds; $last_time = $price['Timestamp']; } return Response(['TotalCost' => $total_cost, 'PaidHours' => $launch->diffInSeconds($terminate) / (60 * 60), 'ActualHours' => $launchTime->diffInSeconds($terminateTime) / (60 * 60)]); }
/** * To criteria */ public function whereTo($date = null) { if ($date) { $date = Carbon::createFromTimestamp(strtotime($date)); $this->orm->where('date', '<=', $date->toDateString()); } }
/** * Return a timestamp as Carbon object. * * A slightly modified version of \Illuminate\Database\Eloquent\Model::asDateTime(). * * @param mixed $value * @param string|null $format * @return Carbon */ protected function __toCarbon($value, $format = null) { // If this value is already a Carbon instance, we shall just return it as is. // This prevents us having to reinstantiate a Carbon instance when we know // it already is one, which wouldn't be fulfilled by the DateTime check. if ($value instanceof Carbon) { return $value; } // If the value is already a DateTime instance, we will just skip the rest of // these checks since they will be a waste of time, and hinder performance // when checking the field. We will just return the DateTime right away. if ($value instanceof DateTime) { return Carbon::instance($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::createFromTimestamp($value); } // If the value is in simply year, month, day format, we will instantiate the // Carbon instances from that format. Again, this provides for simple date // fields on the database, while still supporting Carbonized conversion. if (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $value)) { return Carbon::createFromFormat('Y-m-d', $value)->startOfDay(); } // Use the $format if one was given. if (isset($format) && is_string($format)) { return Carbon::createFromFormat($format, $value); } // Finally, we'll let carbon work out the format (watch out for ambiguous days/months). return Carbon::parse($value); }
/** * Message sent at * * @return Carbon */ public function at() { if ($this->getProperty('ts')) { return Carbon::createFromTimestamp($this->getProperty('ts')); } return null; }
/** * Bootstrap any application services. * * @return void */ public function boot() { Validator::extend('sms', function ($attribute, $value, $parameters) { try { $sms = Sms::where('to', $value)->orderBy('id', 'desc')->firstOrFail(); $dt = Carbon::now(); $sentTime = Carbon::createFromTimestamp($sms->sent_time); $second = $dt->diffInSeconds($sentTime); if ($second < 40) { return false; } return true; } catch (ModelNotFoundException $e) { return true; } }); Validator::extend('mobile', function ($attribute, $value, $parameters) { return preg_match('/^1[3|4|5|7|8|][0-9]{9}$/', $value); }); Validator::extend('verify_code_mock', function ($attribute, $value, $parameters) { $smsData = \SmsManager::getSmsDataFromSession(); if ($smsData && $smsData['deadline_time'] >= time() && $smsData['code'] == $value || $value == '8888') { return true; } return false; }); }
public function __construct(array $params = array()) { $this->expiresAt = Carbon::createFromTimestamp($params['expires']); $this->comment = $params['comment']; $this->callback = $params['callbackurl']; $this->appli = $params['appli']; }
/** * Return a timestamp as DateTime object. * * @param mixed $value * @return \Carbon\Carbon */ protected function asDateTime($value) { // \Log::debug('asDateTime: '.$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)) { // \Log::debug('a'); return Carbon::createFromTimestamp($value); } elseif (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $value)) { // \Log::debug('b'); return Carbon::createFromFormat('Y-m-d', $value)->startOfDay(); } elseif (preg_match('/^(\\d{2}):(\\d{2})(:(\\d{2}))?$/', $value)) { // \Log::debug('c'); $value = Carbon::createFromFormat('H:i:s', $value); } elseif (!$value instanceof DateTime) { // \Log::debug('d'); if (null === $value) { return $value; } $format = $this->getDateFormat(); return Carbon::createFromFormat($format, $value); } return Carbon::instance($value); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if ($request->isMethod('get') && !$request->has('PageSpeed') && !$request->is(config('site.admin_path') . '*') && !$request->is('avatar/*') && !$request->is('my/*') && !$request->is('*/login') && !$request->is('*/authorize') && !in_array($request->path(), ['sitemap.xml', 'logout', 'login'])) { $aSiteMap = Cache::get('sitemap', []); $changefreq = 'always'; if (!empty($aSiteMap[$request->fullUrl()]['added'])) { $aDateDiff = Carbon::createFromTimestamp($aSiteMap[$request->fullUrl()]['added'])->diff(Carbon::now()); if ($aDateDiff->y > 0) { $changefreq = 'yearly'; } else { if ($aDateDiff->m > 0) { $changefreq = 'monthly'; } else { if ($aDateDiff->d > 6) { $changefreq = 'weekly'; } else { if ($aDateDiff->d > 0 && $aDateDiff->d < 7) { $changefreq = 'daily'; } else { if ($aDateDiff->h > 0) { $changefreq = 'hourly'; } else { $changefreq = 'always'; } } } } } } $aSiteMap[$request->fullUrl()] = ['added' => time(), 'lastmod' => Carbon::now()->format('Y-m-d\\TH:i:sP'), 'priority' => 1 - substr_count($request->getPathInfo(), '/') / 10, 'changefreq' => $changefreq]; Cache::forever('sitemap', $aSiteMap); } return $next($request); }
public function __construct(SplFileInfo $file, Builder $builder) { parent::__construct($file, $builder); // Get Category $this->category = $this->getCategory(); // Set tags $this->tags = $this->getHumanTags(); $this->tag_class = $this->getTagClassNames(); // Set date if ($this->has('date')) { $this->date = new Carbon($this->get('date'), date_default_timezone_get()); } else { $this->date = Carbon::createFromTimestamp($file->getMTime()); } // Set excerpt if ($this->has('excerpt')) { $this->excerpt = $this->get('excerpt'); } else { $this->excerpt = $this->getExcerpt($this->content); } // Set author $this->author = $this->get('author', $this->author); // Set Images if ($this->has('image')) { $fileinfo = pathinfo($this->get('image')); $template = $this->builder->getUrl("{$fileinfo['dirname']}/{$fileinfo['filename']}-%SIZE%.{$fileinfo['extension']}"); $this->image = ['full' => $this->builder->getUrl($this->get('image')), 'medium' => str_replace('%SIZE%', 'medium', $template), 'thumb' => str_replace('%SIZE%', 'thumb', $template)]; } // Remove content HTML comments $this->content = preg_replace('/<!--(.*)-->/Uis', '', $this->content); }
/** * {@inheritdoc} */ public function save($value) { // If this value is already a Carbon instance, we shall just return it as is. // This prevents us having to re-instantiate a Carbon instance when we know // it already is one, which wouldn't be fulfilled by the DateTime check. if ($value instanceof Carbon) { return $value; } // If the value is already a DateTime instance, we will just skip the rest of // these checks since they will be a waste of time, and hinder performance // when checking the field. We will just return the DateTime right away. if ($value instanceof DateTimeInterface) { return new Carbon($value->format('Y-m-d H:i:s.u'), $value->getTimeZone()); } // 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::createFromTimestamp($value); } // If the value is in simply year, month, day format, we will instantiate the // Carbon instances from that format. Again, this provides for simple date // fields on the database, while still supporting Carbonized conversion. if (preg_match('/^(\\d{4})-(\\d{1,2})-(\\d{1,2})$/', $value)) { return Carbon::createFromFormat('Y-m-d', $value)->startOfDay(); } // Finally, we will just assume this date is in the format used by default on // the database connection and use that format to create the Carbon object // that is returned back out to the developers after we convert it here. return Carbon::createFromFormat($this->options['format'], $value); }
function date_for_humans($time, $now = null) { $time = date_to_timestamp($time); if ($now) { $now = date_to_timestamp($now); $now = \Carbon\Carbon::createFromTimestamp($now); } $r = \Carbon\Carbon::createFromTimestamp($time)->diffForHumans($now); $r = str_replace(' seconds', '秒', $r); $r = str_replace(' minutes', '分钟', $r); $r = str_replace(' hours', '小时', $r); $r = str_replace(' days', '天', $r); $r = str_replace(' weeks', '周', $r); $r = str_replace(' months', '个月', $r); $r = str_replace(' years', '年', $r); $r = str_replace(' second', '秒', $r); $r = str_replace(' minute', '分钟', $r); $r = str_replace(' hour', '小时', $r); $r = str_replace(' day', '天', $r); $r = str_replace(' week', '周', $r); $r = str_replace(' month', '个月', $r); $r = str_replace(' year', '年', $r); $r = str_replace(' from now', '后', $r); $r = str_replace(' ago', '前', $r); $r = str_replace(' after', '后', $r); $r = str_replace(' before', '前', $r); return $r; }
/** * Execute the console command. * * @return mixed * @throws \Gitonomy\Git\Exception\RuntimeException * @throws \Gitonomy\Git\Exception\InvalidArgumentException */ public function handle() { $inspector = new Inspector($this->settings); $repository = $inspector->getRepositoryByUrl($this->argument('repositoryUrl')); $inspectedRepository = $inspector->inspectRepository($repository); $header = array_keys((array) $inspectedRepository[key($inspectedRepository)]); if (!$this->option('dry-run')) { $remote = $inspectedRepository['remote']; \Swis\GotLaravel\Models\Results::unguard(); foreach ($inspectedRepository['results'] as $result) { $insert = $result->toArray(); $insert['remote'] = $remote; $insert['author_slug'] = Str::slug($result->getAuthor()); $insert['created_at'] = Carbon::createFromTimestamp($insert['date']); try { \Swis\GotLaravel\Models\Results::updateOrCreate(array_only($insert, ['remote', 'filename', 'line']), $insert); } catch (\Exception $e) { $this->error('Couldnt insert: ' . $e->getMessage() . PHP_EOL . print_r($insert, 1)); } } } reset($inspectedRepository['results']); array_walk($inspectedRepository['results'], function (&$row) { $row = $row->toArray(); }); $this->info($inspectedRepository['remote']); $this->table($header, $inspectedRepository['results']); Artisan::call('got:normalize-names'); }
/** * Scope a query to only include activities older than a timestamp * * @param \Illuminate\Database\Eloquent\Builder * @param Carbon|int $time * @return \Illuminate\Database\Eloquent\Builder */ public function scopeOlderThan($query, $time) { if (!$time instanceof Carbon) { $time = Carbon::createFromTimestamp($time); } return $query->where('created_at', '<=', $time->toDateTimeString())->latest(); }
/** * Read last visited timestamp from file and return * timestamp as Carbon object or return zero. * * @return int|\Carbon\Carbon */ protected function getLastVisit() { if (Storage::exists('visited.txt')) { return Carbon::createFromTimestamp(Storage::get('visited.txt')); } return 0; }
/** * {@inheritDoc} */ public function init() { $this->fillFromConfig(['mode', 'minDate', 'maxDate']); $this->mode = strtolower($this->mode); $this->minDate = is_integer($this->minDate) ? Carbon::createFromTimestamp($this->minDate) : Carbon::parse($this->minDate); $this->maxDate = is_integer($this->maxDate) ? Carbon::createFromTimestamp($this->maxDate) : Carbon::parse($this->maxDate); }
public function getScrapedDate($format = 'h:iA m/d/y') { if ($this->scraped_at == 0) { return "n/a"; } return Carbon::createFromTimestamp($this->scraped_at)->format($format); }
public function testCreateFromTimestampWithString() { $d = Carbon::createFromTimestamp(0, 'UTC'); $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); $this->assertTrue($d->offset === 0); $this->assertSame('UTC', $d->tzName); }
/** * @param Request $request * @param $id * @param $code * * @return array|RedirectResponse * @Template() */ public function checkinAction(Request $request, $id, $code) { /* @var $ticket Ticket */ $ticket = $this->ticketRepo->getTicketByIdAndCode($id, $code)->getOrThrow(new NotFoundHttpException('Unknown ticket.')); // Do not allow double checkins if ($ticket->isCheckedIn()) { throw new BadRequestException('Already checked in!'); } // Do not allow checkins on the wrong day /* @var $event Event */ $event = $this->eventRepo->getNextEvent()->getOrThrow(new AccesDeniedHttpException('No event.')); $now = new Carbon(); $start = Carbon::createFromTimestamp($event->getStart()->getTimestamp()); $start->setTime(0, 0, 0); if ($ticket->isSunday()) { $start->modify('+1day'); } $end = clone $start; $end->setTime(23, 59, 59); if (!$now->between($start, $end)) { throw new BadRequestException('Wrong day!'); } // Record checkin $command = new CheckinCommand(); $command->ticket = $ticket; $this->commandBus->handle($command); return array('ticket' => $ticket); }