public function franchise() { $franchise = Franchise::where('user_id', '=', Auth::user()->id)->first(); if ($franchise == null) { return $this->redirect(handles('blupl/franchise::create')); } else { return view('blupl/franchises::management.index', compact('franchise')); } }
/** * Update the role. * @return mixed */ public function update($franchise, $cateegory, $id, Request $request) { $item = Franchise::find($franchise)->{$cateegory}->find($id); // dd($item); if ($item->status == 0) { foreach ($request->zone as $zone) { $item->zone()->create(['zone' => $zone]); } $item->status = 1; $item->save(); } else { if ($item->status == 1) { $massage = "Already Approve"; } else { $massage = "Reporter Not Found"; } Flash::error($massage); return $this->redirect(handles('blupl/franchise::approval/franchise/' . $franchise . '/' . $cateegory)); } Flash::success($item->name . ' Approved Successfully'); return $this->redirect(handles('blupl/franchise::approval/franchise/' . $franchise . '/' . $cateegory)); }
/** * Save the role. * * @param \Orchestra\Model\Role $role * @param array $input * @param string $type * * @return bool */ protected function saving(Eloquent $franchise, $request, $type = 'create') { // dd($request->all()); $beforeEvent = $type === 'create' ? 'creating' : 'updating'; $afterEvent = $type === 'create' ? 'created' : 'updated'; $franchise->setAttributes('accredit_category', $request->accredit_category); $franchise->setAttributes('name_franchise', $request->name_franchise); $franchise->setAttributes('name_applicant', $request->name_applicant); $franchise->setAttributes('nationality', $request->nationality); $franchise->setAttributes('passport_nid', $request->passport_nid); $franchise->setAttributes('role', $request->role); $franchise->setAttributes('date_of_birth', $request->date_of_birth); $franchise->setAttributes('country_of_birth', $request->country_of_birth); $franchise->setAttributes('phone', $request->phone); $franchise->setAttributes('passport_expire_date', $request->passport_expire_date); $franchise->setAttributes('noc', $request->accredit_category); $franchise->setAttributes('mail', $request->mail); $franchise->setAttributes('photo', $request->photo); $franchise->setAttributes('attachment', $request->attachment); $franchise->save(); // $franchises->setAttribute('phone', $input['phone']); // $franchises->setAttribute('address', $input['address']); // dd($franchise); // $this->fireEvent($beforeEvent, [$franchise]); // $this->fireEvent('saving', [$franchise]); // DB::transaction(function () use ($franchise) { // // }); // $organization = $franchises->create($request->organization); // $organization->member()->insert($request->officer); // $organization->reporter()->insert($request->reporter); // $this->fireEvent($afterEvent, [$franchise]); // $this->fireEvent('saved', [$franchise]); dd($franchise); return true; }