Esempio n. 1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, Request $request)
 {
     $user = User::findOrFail($id);
     $user->delete();
     $message = $user->full_name . ' was deleted successfully!';
     if ($request->ajax()) {
         return response()->json(['id' => $user->id, 'message' => $message]);
     }
     Session::flash('message', $message);
     return redirect()->route('admin.users.index');
 }
Esempio n. 2
0
 public function getORM()
 {
     //        $user = User::first();
     //        $user = User::orderBy('created_at', 'desc')->first();
     //        return dd($user->age);
     //        return dd($user->categories);
     $users = User::select('users.first_name', 'users.birthdate')->leftJoin('categories', 'users.id', '=', 'categories.user_id')->where('users.first_name', '<>', 'Nery')->orderBy('users.birthdate', 'ASC')->get();
     return dd($users);
     $u = User::with('categories')->get();
     return dd($u);
 }
Esempio n. 3
0
 /**
  * Run the database seeds.
  * Crea 5 usuarios y por cada uno crea 2 categorias y 3 cuentas.
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 10; $i++) {
         $user = User::create(array('email' => $faker->unique()->email, 'password' => '123456', 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'birthdate' => $faker->dateTimeBetween($startDate = '-24 years', $endDate = '-18 years')->format('Y-m-d')));
         //categories
         for ($j = 0; $j < 2; $j++) {
             Category::create(array('name' => $faker->word, 'description' => $faker->text(100), 'user_id' => $user->id));
         }
         //accounts
         Account::create(array('name' => 'Cash', 'starting_balance' => $faker->randomFloat(2), 'current_balance' => $faker->randomFloat(2), 'notes' => $faker->text(100), 'user_id' => $user->id));
         Account::create(array('name' => 'Debit Card', 'starting_balance' => $faker->randomFloat(2), 'current_balance' => $faker->randomFloat(2), 'notes' => $faker->text(100), 'user_id' => $user->id));
         Account::create(array('name' => 'Credit Card', 'starting_balance' => $faker->randomFloat(2), 'current_balance' => $faker->randomFloat(2), 'notes' => $faker->text(100), 'user_id' => $user->id));
     }
 }
Esempio n. 4
0
 public static function filterAndPaginate($name, $type)
 {
     return User::name($name)->type($type)->orderBy('id', 'ASC')->paginate();
 }
Esempio n. 5
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['first_name' => $data['first_name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }