/**
  * Create a new command instance.
  *
  * @return void
  */
 public function __construct(TrackingRepository $trackingRepo, BillboardRepository $billboardRepo)
 {
     parent::__construct();
     $this->trackingRepository = $trackingRepo;
     $this->billboardRepository = $billboardRepo;
     Carbon::setToStringFormat('Y_m');
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \Carbon\Carbon::setToStringFormat('d/m/Y');
     view()->composer('admin.templates.principal', function ($view) {
         $view->with('usuario', auth()->user());
     });
 }
 public function testResetToStringFormat()
 {
     $d = Carbon::now();
     Carbon::setToStringFormat('123');
     Carbon::resetToStringFormat();
     $this->assertSame($d->toDateTimeString(), '' . $d);
 }
Example #4
0
 public function __construct(array $data)
 {
     if (class_exists('\\Carbon\\Carbon')) {
         $format = 'D, d M o H:i:s e';
         \Carbon\Carbon::setToStringFormat($format);
     }
     parent::__construct($data);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $locale = $request->cookie('locale', Config::get('app.locale'));
     App::setLocale($locale);
     Carbon::setLocale($locale);
     Carbon::setToStringFormat('Y-m-d H:i:s');
     return $next($request);
 }
function feedhistory($connection = 'default', $limit)
{
    $annotations = Annotation::on($connection)->with('Attachments')->where('id', '<', $limit)->orderBy('id', 'desc')->take(20)->get();
    Carbon::setToStringFormat(DateTime::ISO8601);
    $result = [];
    foreach ($annotations as $annotation) {
        $result[] = json_decode($annotation->toJson());
    }
    return json_encode($result);
}
Example #7
0
 public function __construct(array $data)
 {
     if (class_exists('\\Carbon\\Carbon')) {
         $format = 'D, d M o H:i:s e';
         \Carbon\Carbon::setToStringFormat($format);
     }
     parent::__construct($data);
     if (isset($this->data['discussion'])) {
         $this->discussion = new Discussion($this->data['discussion']);
     }
 }
Example #8
0
 public function __construct($data = null, $status = 200, $headers = array(), $options = 0)
 {
     if ($data instanceof \Exception) {
         $data = array("code" => $data->getCode(), "error" => $data->getMessage());
     } else {
         // move the prepare function here
         Carbon::setToStringFormat('Y-m-d\\TH:i:s.z\\Z');
         $data = ParseHelper::prepareResponse($data);
     }
     parent::__construct($data, $status, $headers, $options);
 }
 public function getCheck()
 {
     $meds = \WQS\Medication::all();
     foreach ($meds as $med) {
         $taken = Carbon::parse($med->last_taken);
         if ($med->interval < Carbon::now()->diffInHours($taken)) {
             $med->can_take = 1;
         }
         Carbon::setToStringFormat('g:i a');
         $med->next = $taken->addHours($med->interval);
     }
     return view('med-check')->with('meds', $meds);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('auth/login');
         }
     }
     // Also set locale per request
     app()->setLocale($this->auth->user()->locale);
     // And set default string format for dates
     Carbon::setToStringFormat('j-M-Y h:i A');
     return $next($request);
 }
 public function getAllMessages()
 {
     try {
         Carbon::setToStringFormat(self::PLUGIN_DATE_FORMAT);
         $date_from = Carbon::now()->subMonth()->toDateString();
         $date_to = Carbon::now()->toDateString();
         $mandrill = new Mandrill($this->getSetting('MandrillApiKey'));
         $result = $mandrill->messages->search('*', $date_from, $date_to);
     } catch (Mandrill_Error $e) {
         // Mandrill errors are thrown as exceptions
         // echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
         // A mandrill error occurred: Mandrill_ServiceUnavailable - Service Temporarily Unavailable
         throw $e;
     }
     return $result;
 }
Example #12
0
 /**
  * Get a plain attribute (not a relationship).
  *
  * @param  string  $key
  * @return mixed
  */
 protected function getAttributeValue($key)
 {
     $value = $this->getAttributeFromArray($key);
     // If the attribute has a get mutator, we will call that then return what
     // it returns as the value, which is useful for transforming values on
     // retrieval from the model to a form that is more useful for usage.
     if ($this->hasGetMutator($key)) {
         return $this->mutateAttribute($key, $value);
     } elseif (in_array($key, $this->getDateField())) {
         if ($value) {
             Carbon::setToStringFormat('d-m-Y');
             return (new Carbon($value, 'US/Eastern'))->setTimezone('Asia/Kuala_Lumpur');
         }
     } elseif (in_array($key, $this->getDateTimeField())) {
         if ($value) {
             Carbon::setToStringFormat('d-m-Y H:i:s');
             return (new Carbon($value, 'US/Eastern'))->setTimezone('Asia/Kuala_Lumpur');
         }
     }
     return $value;
 }
Example #13
0
 /**
  * Runs the current application.
  *
  * @param InputInterface  $input  An Input instance
  * @param OutputInterface $output An Output instance
  *
  * @return int 0 if everything went fine, or an error code
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $name = $this->getCommandName($input);
     // Did the user enter an environment option?
     if (true === $input->hasParameterOption(['--env', '-e'])) {
         $this->environment = $input->getParameterOption(['--env', '-e']);
     } else {
         if ($name === 'publish') {
             $this->environment = 'production';
         }
     }
     // Load config
     $this->config = new Config($this->environment);
     // Set local timezone
     date_default_timezone_set($this->getSetting('timezone', 'America/New_York'));
     // Set default date format
     Carbon::setToStringFormat($this->config->get('date_format', 'Y-m-d H:i:s'));
     // Register events
     $this->registerEvents();
     return parent::doRun($input, $output);
 }
Example #14
0
 public function __construct()
 {
     $this->query = \App\Statcache::Week()->get();
     \Carbon\Carbon::setToStringFormat('d/m/Y');
 }
 /**
  * Create a new command instance.
  *
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     Carbon::setToStringFormat('Y_m');
 }
Example #16
0
// Date difference
printf($outputString, "Berlin", "Brisbane, Australia", $dtBerlin->diffInHours($brisbane, false));
printf($outputString, "Berlin", "New York City, America", $dtBerlin->diffInHours($newYorkCity, false));
$septEighteen2014 = Carbon::createFromDate(2014, 9, 18, $dtBerlin->getTimezone());
printf("difference between now and %s in \n\thours: %d, \n\tdays: %d, \n\tweeks: %d, \n\tweekend days: %d, \n\tweek days: %s, \n\thuman readable: %s\n", $septEighteen2014->toFormattedDateString(), $dtBerlin->diffInHours($septEighteen2014), $dtBerlin->diffInDays($septEighteen2014), $dtBerlin->diffInWeeks($septEighteen2014), $dtBerlin->diffInWeekendDays($septEighteen2014), $dtBerlin->diffInWeekDays($septEighteen2014), $dtBerlin->diffForHumans($septEighteen2014));
// Date formatting
echo $dtBerlin->toDateString() . "\n";
echo $dtBerlin->toFormattedDateString() . "\n";
echo $dtBerlin->toTimeString() . "\n";
echo $dtBerlin->toDateTimeString() . "\n";
echo $dtBerlin->toDayDateTimeString() . "\n";
echo $dtBerlin->toRfc1036String() . "\n";
echo $dtBerlin->toAtomString() . "\n";
echo $dtBerlin->toCookieString() . "\n";
echo $dtBerlin->toRssString() . "\n";
$dtBerlin->setToStringFormat('l jS \\of F Y');
echo $dtBerlin . "\n";
echo (int) $dtBerlin->isLeapYear() . "\n";
// is* range of functions test
printf("Is yesterday? %s\n", $dtBerlin->isYesterday() ? "yes" : "no");
printf("Is a Thursday? %s\n", $dtBerlin->isThursday() ? "yes" : "no");
printf("Is in the future? %s\n", $dtBerlin->isFuture() ? "yes" : "no");
printf("Is a leap year? %s\n", $dtBerlin->isLeapYear() ? "yes" : "no");
// first and last of the month
printf("First of the month %s\n", $dtBerlin->firstOfMonth());
printf("Last of the month %s\n", $dtBerlin->lastOfMonth());
// nthOf* function test
printf("Start of the month %s\n", $dtBerlin->startOfMonth());
printf("End of the month %s\n", $dtBerlin->endOfMonth());
printf("End of the decade %s\n", $dtBerlin->endOfDecade());
// Date manipulation
Example #17
0
 public function handle($request, Closure $next)
 {
     Carbon::setLocale('it');
     Carbon::setToStringFormat('d/m/Y');
     return $next($request);
 }
 /**
  * @see https://laravel.com/docs/5.1/authentication#protecting-routes Authentication
  */
 public function __construct()
 {
     $this->middleware('auth', ['except' => ['create', 'store', 'show', 'index']]);
     Carbon::setToStringFormat('Y-m-d');
 }
Example #19
0
 /**
  * Constructor
  *
  * Build all the dependencies
  *
  * @var array $config  an EE config array
  */
 public function __construct($config = array())
 {
     Carbon::setToStringFormat(Carbon::ISO8601);
     $this->singleton('config', function ($app) use($config) {
         return $config;
     });
     $this->bind('db', function ($app) {
         return Model::resolveConnection(Model::getGlobalConnection());
     });
     $this->singleton('Field', function ($app) {
         return new Field();
     });
     $this->singleton('FieldRepository', function ($app) {
         return new FieldRepository($app->make('Field'));
     });
     $this->singleton('Channel', function ($app) {
         $channel = new Channel();
         $channel->setFieldRepository($app->make('FieldRepository'));
         return $channel;
     });
     $this->singleton('Site', function ($app) {
         return new Site();
     });
     $this->singleton('UploadPref', function ($app) {
         return new UploadPref();
     });
     $this->singleton('CategoryField', function ($app) {
         return new CategoryField();
     });
     $this->singleton('MemberField', function ($app) {
         return new MemberField();
     });
     $this->singleton('CategoryFieldRepository', function ($app) {
         return new CategoryFieldRepository($app->make('CategoryField'));
     });
     $this->singleton('MemberFieldRepository', function ($app) {
         return new MemberFieldRepository($app->make('MemberField'));
     });
     $this->singleton('ChannelRepository', function ($app) {
         return new ChannelRepository($app->make('Channel'));
     });
     $this->singleton('SiteRepository', function ($app) {
         return new SiteRepository($app->make('Site'));
     });
     $this->singleton('UploadPrefRepository', function ($app) {
         if (isset($app['config']['upload_prefs'])) {
             return new ConfigUploadPrefRepository($app['config']['upload_prefs']);
         }
         return new UploadPrefRepository($app->make('UploadPref'));
     });
     $this->singleton('Asset', function ($app) {
         return new Asset();
     });
     $this->singleton('File', function ($app) {
         return new File();
     });
     $this->singleton('GridCol', function ($app) {
         return new GridCol();
     });
     $this->singleton('GridRow', function ($app) {
         return new GridRow();
     });
     $this->singleton('MatrixCol', function ($app) {
         return new MatrixCol();
     });
     $this->singleton('MatrixRow', function ($app) {
         return new MatrixRow();
     });
     $this->singleton('PlayaEntry', function ($app) {
         return new PlayaEntry();
     });
     $this->singleton('RelationshipEntry', function ($app) {
         return new RelationshipEntry();
     });
     $this->singleton('HydratorFactory', function ($app) {
         return new HydratorFactory($app->make('db'), $app->make('SiteRepository'), $app->make('UploadPrefRepository'), $app->make('Asset'), $app->make('File'), $app->make('GridCol'), $app->make('GridRow'), $app->make('MatrixCol'), $app->make('MatrixRow'), $app->make('PlayaEntry'), $app->make('RelationshipEntry'));
     });
     $this->singleton('Category', function ($app) {
         $category = new Category();
         $category->setCategoryFieldRepository($app->make('CategoryFieldRepository'));
         $category->setChannelRepository($app->make('ChannelRepository'));
         return $category;
     });
     $this->singleton('Member', function ($app) {
         $member = new Member();
         $member->setMemberFieldRepository($app->make('MemberFieldRepository'));
         return $member;
     });
     $this->singleton('Title', function ($app) {
         $app->make('Category');
         $app->make('Member');
         $title = new Title();
         $title->setChannelRepository($app->make('ChannelRepository'));
         $title->setSiteRepository($app->make('SiteRepository'));
         $title->setHydratorFactory($app->make('HydratorFactory'));
         return $title;
     });
     $this->singleton('Entry', function ($app) {
         $app->make('Title');
         $entry = new Entry();
         $entry->setFieldRepository($app->make('FieldRepository'));
         return $entry;
     });
 }
Example #20
0
 /**
  * The constructor.
  */
 public function __construct()
 {
     Carbon::setToStringFormat(\DateTime::ISO8601);
 }
 /**
  * Use CORS {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS CORS},
  * and force HTTPS on API.
  */
 public function __construct()
 {
     $this->middleware('cors');
     $this->middleware('secure');
     Carbon::setToStringFormat('d/m/Y');
 }
Example #22
0
 public function getEndDateAttribute($value)
 {
     Carbon::setToStringFormat('Y-m-d H:i:s');
     return new Carbon($value, 'US/Eastern');
 }
Example #23
0
    }
    $capsule = new Illuminate\Database\Capsule\Manager();
    $capsule->addConnection($db_config);
    $capsule->setFetchMode(PDO::FETCH_CLASS);
    $capsule->setEventDispatcher($event_dispatcher);
    $capsule->setAsGlobal();
    $capsule->bootEloquent();
    $connection = $capsule->connection();
    class_alias('\\Illuminate\\Database\\Eloquent\\Model', 'DLModel');
}
//
// Setup default date format
// Use a string representing an RFC2822 or ISO 8601 date
// http://tools.ietf.org/html/rfc2822#page-14
//
\Carbon\Carbon::setToStringFormat('Y-m-d\\TH:i:sP');
// Setup paginator
$connection->setPaginator(new Hook\Pagination\Environment());
// Setup Schema Grammar
// $connection->setSchemaGrammar();
// Setup cache manager
$connection->setCacheManager(function () {
    $cache_driver = Router::config('cache');
    if ($cache_driver == "filesystem") {
        $config = array('files' => new \Illuminate\Filesystem\Filesystem(), 'config' => array('cache.driver' => 'file', 'cache.path' => storage_dir() . '/cache'));
    } else {
        if ($cache_driver == "database") {
            $config = array('db' => \DLModel::getConnectionResolver(), 'encrypter' => Hook\Security\Encryption\Encrypter::getInstance(), 'config' => array('cache.driver' => 'database', 'cache.connection' => 'default', 'cache.table' => 'cache', 'cache.prefix' => ''));
        }
    }
    return new Illuminate\Cache\CacheManager($config);