/** * Store a newly created resource in storage. * * @param CreateTravelCompaniesRequest $request * * @return Response */ public function store(CreateTravelCompaniesRequest $request) { $email = $request->email; $password = $request->password; $name = $request->name; $phone = $request->phone; $slug = str_slug($request->name); TravelCompany::create(['email' => $email, 'name' => $name, 'phone' => $phone, 'slug' => $slug]); $travel_company = TravelCompany::all()->last(); TravelCompanyStaff::create(['email' => $email, 'name' => $name, 'phone' => $phone, 'password' => $password, 'travel_company_id' => $travel_company->id, 'type' => 1]); return redirect()->route('admin.travel-companies.index'); }
/** * @param Request $request * * @return \Illuminate\Http\RedirectResponse */ public function add_staff(Request $request) { $this->validate($request, ['name' => 'required', 'username' => 'unique:travel_company_staffs', 'email' => 'required|unique:travel_company_staffs', 'password' => 'required']); $input = array_add($request->all(), 'travel_company_id', Auth::travel_company_staff()->get()->travel_company->id); TravelCompanyStaff::create($input); return redirect()->route('company_settings'); }