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(); } } }
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'); }
public function show($id) { $companyModel = new Company(); $company = $companyModel->findOrfail($id); response()->json($company->toArray()); }