public function __construct($organisationId) { parent::__construct($organisationId); $this->bandwidthTotal = ModelActivity::getBandwidthByDate($organisationId); $this->bandwidthMonth = ModelActivity::getBandwidthByDate($organisationId, date('01-m-Y')); $this->bandwidthTotal = ModelActivity::getBandwidthByDate($organisationId); $this->bandwidthToday = ModelActivity::getBandwidthByDate($organisationId, Date::toDate()); $this->bandwidthMonth = ModelActivity::getBandwidthByDate($organisationId, date('01-m-Y')); $this->bandwidthTotal = ModelActivity::getBandwidthByDate($organisationId); $this->masterImagesToday = ModelActivity::getMasterImagesBydate($organisationId, Date::toDate()); $this->masterImagesMonth = ModelActivity::getMasterImagesBydate($organisationId, date('01-m-Y')); $this->masterImagesTotal = ModelActivity::getMasterImagesBydate($organisationId); $this->rendersToday = ModelActivity::getRendersByDate($organisationId, Date::toDate()); $this->rendersMonth = ModelActivity::getRendersByDate($organisationId, date('01-m-Y'), date('01-m-Y')); $this->rendersTotal = ModelActivity::getRendersByDate($organisationId); if ($this->isPostBack()) { $action = strtolower($this->input('action')); if ($action === 'delete') { $this->organisation->deleted = !$this->organisation->deleted; } if ($action === 'disable') { $this->organisation->disabled = !$this->organisation->disabled; } $this->organisation->update(); $this->setMessage(lang('Organisation updated'), 'success'); response()->refresh(); } }
public function index() { $organisationId = request()->organisation->id; $bandwidthToday = ModelActivity::getBandwidthByDate($organisationId, Date::toDate()); $bandwidthTotal = ModelActivity::getBandwidthByDate($organisationId); $masterImagesToday = ModelActivity::getMasterImagesBydate($organisationId, Date::toDate()); $masterImagesTotal = ModelActivity::getMasterImagesBydate($organisationId); $rendersToday = ModelActivity::getRendersByDate($organisationId, Date::toDate()); $rendersTotal = ModelActivity::getRendersByDate($organisationId); response()->json(['bandwidth_today' => $bandwidthToday, 'bandwidth_total' => $bandwidthTotal, 'masterimages_today' => $masterImagesToday, 'masterimages_total' => $masterImagesTotal, 'renders_today' => $rendersToday, 'renders_total' => $rendersTotal]); }
public static function daysAgo($date1, $date2) { $diff = Date::toDate(strtotime($date1)) - Date::toDate(strtotime($date2)); return floor($diff / (60 * 60 * 24)); }
protected function update() { $this->post->invoice_id->addValidation(new ValidateInputNotNullOrEmpty()); $this->post->due_date->addValidation([new ValidateInputNotNullOrEmpty(), new ValidateInputDate()]); $this->post->amount->addValidation([new ValidateInputNotNullOrEmpty(), new ValidateInputFloat()]); if (!$this->hasErrors()) { $this->invoice->invoice_id = $this->input('invoice_id'); $this->invoice->due_date = Date::toDate(strtotime($this->input('due_date'))); $this->invoice->amount_total = $this->input('amount'); $this->invoice->payed = $this->input('payed'); if ($this->file->invoice instanceof InputFile) { // Delete old invoice $tmp = explode('?', basename($this->invoice->path)); $this->deleteS3($tmp[0]); $path = $this->uploadS3($this->file->invoice->tmpname, $this->input('invoice_id') . '.' . File::getExtension($this->invoice->invoide_id)); $this->invoice->path = $path; } $this->invoice->update(); $this->setMessage(lang('Invoice has been updated'), 'success'); response()->refresh(); } }