Пример #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $this->validate($request, ['firstname' => 'required', 'lastname' => 'required', 'email' => 'required|email|unique:users,email', 'phone' => 'phone:US']);
     $input = $request->all();
     $input['type'] = 'tenant';
     $input['username'] = $input['email'];
     $tenant = Tenant::create($input);
     if (isset($input['lease_id'])) {
         $lease = Lease::find($input['lease_id']);
         //$tenant->leases()->attach($lease);
         $lease->tenants()->attach($tenant);
         return redirect()->action('LeaseController@show', [$lease->apartment->name, $lease->id]);
     }
     return redirect('tenants');
 }
Пример #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(tenantRequest $request)
 {
     $input = $request->all();
     Tenant::create($input);
     return Redirect::route('tenants.index');
 }