/** * Execute the job. * * @param FlatCmService $service * @param WebsiteRepositoryInterface $websiteRepository */ public function handle(FlatCmService $service, WebsiteRepositoryInterface $websiteRepository) { if ($service->process($this->identifier, $this->username, $this->email, $this->password)) { $website = $websiteRepository->create(['identifier' => $this->identifier, 'username' => $this->username, 'email' => $this->email, 'is_active' => true, 'url' => 'http://' . $this->identifier . '.' . env('CMS_BASE_URL')]); $organization = Organization::findOrFail($this->organization_id); $website->organization()->associate($organization); $website->save(); //fire event } else { //fire event } }
/** * * Activate CMS INSTANCE * @param WebsiteRequest $request * @param FlatCmService $service * @param WebsiteRepositoryInterface $websiteRepository * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @internal param FlatCmService $service * @internal param WebsiteRepositoryInterface $websiteRepository */ public function store(WebsiteRequest $request, FlatCmService $service) { $identifier = str_slug($this->organization->name, "-"); $username = $request->get('username'); $email = $request->get('email'); $password = $request->get('password'); //$this->dispatch(new CreateWebsite($this->organization->id, $identifier, $username, $email, $password)); if ($service->process($identifier, $username, $email, $password)) { $website = Website::create(['identifier' => $identifier, 'username' => $username, 'email' => $email, 'is_active' => true, 'url' => 'http://' . $identifier . '.' . env('CMS_BASE_URL')]); $organization = Organization::findOrFail($this->organization->id); $website->organization()->associate($organization); $website->save(); Flash::success(Lang::get('website.create-success')); } else { Flash: error: Lang::get('website.create-failed'); } return redirect(action('WebsiteController@index')); }