Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateUserRequest $request)
 {
     $id = Auth::user()->id;
     if ($request->file('photo')) {
         $file = $request->file('photo');
         $name = 'Appmm_' . time() . '.' . $file->getClientOriginalExtension();
         // $path = public_path().'/upload/users/';
         // $file->move($path,$name);
         Storage::disk('users')->put($name, \File::get($file));
     }
     $users = new User($request->all());
     $users->iduser_create = $id;
     $users->photo = $name;
     $users->save();
     $profiles = new Profile();
     $profiles->user_id = $users->id;
     $profiles->save();
     Session::flash('message', 'El usuario ' . $users->name . '  Fue creado exitosamente');
     //guarda el valor de los campos enviados desde el form en un array
     $data = $request->all();
     //se envia el array y la vista lo recibe en llaves individuales {{ $email }} , {{ $subject }}...
     \Mail::send('emails.message', $data, function ($message) use($request) {
         //remitente
         $message->from($request->email, $request->name);
         //asunto
         $message->subject($request->name);
         //receptor
         $message->to(env('CONTACT_MAIL'), env('CONTACT_NAME'));
     });
     return redirect()->route('admin.usuarios.index');
 }
Exemplo n.º 2
0
 /**
  * Store a newly created User in storage.
  *
  * @param CreateUserRequest $request
  *
  * @return Response
  */
 public function store(CreateUserRequest $request)
 {
     $input = $request->all();
     $input['objectId'] = str_random(10);
     $input['password'] = bcrypt($input['password']);
     if ($request->file('image')) {
         $input['profileimage'] = json_encode($this->uploadImage($request->file('profileimage'), '/posts_photo/'));
     }
     $user = $this->userRepository->create($input);
     Flash::success('User saved successfully.');
     return redirect(route('users.index'));
 }
Exemplo n.º 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(CreateUserRequest $request, $id)
 {
     /*$this->validate($request, [
     			'fname' => 'required|max:255',
     			'lname' => 'required|max:255',
     		]);*/
     $user = User::find($id);
     $user->fname = $request->fname;
     $user->lname = $request->lname;
     $user->save();
     if ($request->hasFile('image')) {
         $request->file('image')->move(public_path('profpics'), $request->file('image')->getClientOriginalName());
         $user->image = 'profpics/' . $request->file('image')->getClientOriginalName();
         $user->save();
     } else {
         dd('No image was found');
     }
     return view('home', compact('user', $user));
 }