コード例 #1
0
 public function __construct($companyId = null)
 {
     parent::__construct();
     if ($companyId !== null) {
         $this->company = Company::instance()->find($companyId);
     } else {
         $this->company = new Company();
     }
     $this->exists = $this->company->exists();
     if ($this->exists) {
         $this->prependSiteTitle(lang('Companies.EditCompany', $this->company->name));
     } else {
         $this->prependSiteTitle(lang('Companies.AddCompany'));
     }
     if ($this->isPostBack()) {
         $this->validate(['name' => [new NotNullOrEmpty()]]);
         if (!$this->hasErrors()) {
             $this->company->save(['name' => input()->get('name'), 'ip' => request()->getIp()]);
             if ($this->exists) {
                 $this->setMessage(lang('Companies.CompanyUpdated'), 'success');
             } else {
                 $this->setMessage(lang('Companies.CompanySaved'), 'success');
             }
             // Refresh
             response()->refresh();
         }
     }
 }
コード例 #2
0
 public function __construct($companyId)
 {
     parent::__construct();
     $this->companyId = $companyId;
     $this->companies = Company::instance()->all();
     $this->prependSiteTitle(lang('Companies.Companies'));
     $this->mainMenu->getItem(1)->addClass('active');
 }
コード例 #3
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('PageNotFound.PageNotFound'));
     $this->mainMenu->getItem(0)->addClass('active');
 }