コード例 #1
0
ファイル: UsersController.php プロジェクト: alfons83/tfg
 /**
  * Update the specified resource in storage.
  *
  * @param  Request $request
  * @param  int $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $user = User::findOrFail($id);
     $user->fill($request->all());
     $user->save();
     if (Input::file('image') and Input::file('image')->isValid()) {
         $destinationPath = 'uploads/users/user_' . $user->id . '/';
         // upload path
         $extension = Input::file('image')->getClientOriginalExtension();
         // getting image extension
         $fileName = rand(11111, 99999) . '.' . $extension;
         // renameing image
         // Metemos la foto en el sistema
         Input::file('image')->move($destinationPath, $fileName);
         // uploading file to given path
         // Borramos las fotos del sistema
         $photos = UserProfile::where('user_id', $user->id)->get();
         if ($photos) {
             File::delete(array_pluck($photos, 'path'));
         }
         // Borramos las fotos de la BD
         UserProfile::where('user_id', $user->id)->delete();
         // Metemos la foto en la BD
         UserProfile::create(['path' => $destinationPath . $fileName, 'user_id' => $user->id]);
         //return redirect('/uploads/'.$fileName);
     }
     return redirect()->back();
 }
コード例 #2
0
 public function run()
 {
     DB::table('user_profiles')->delete();
     for ($i = 0; $i < $this->num_records; $i++) {
         $array = ['user_id' => $this->getRandRec(), 'image_id' => $this->getRandRec(), 'about_me' => $this->getFaker()->text];
         UserProfile::create($array);
     }
 }
コード例 #3
0
ファイル: UserTableSeeder.php プロジェクト: blozixdextr/adtw
 public function clients($limit = 1000)
 {
     $faker = $this->faker;
     for ($i = 0; $i < $limit; $i++) {
         $user = User::create(['name' => $faker->firstName, 'email' => $faker->freeEmail, 'password' => bcrypt('1'), 'last_activity' => \Carbon\Carbon::createFromTimestamp($faker->unixTime), 'role' => 'user', 'type' => 'client', 'provider' => 'local', 'balance' => rand(0, 100)]);
         $profile = UserProfile::create(['first_name' => $user->name, 'last_name' => $faker->lastName, 'user_id' => $user->id]);
         LogMapper::log('client_register', $user->id);
         NotificationMapper::registration($user);
     }
 }