예제 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(RegistrationFormRequest $request)
 {
     $input = Request::all();
     $file = Request::file('picture');
     //move the file to the public folder
     $kid = \p4\Kid::create(Request::all());
     /*
      *save the user uploaded picture in the images directory
      * store the path in the database
      */
     if (Request::hasFile('picture')) {
         $filename = time() . '-' . $file->getClientOriginalName();
         $file = $file->move(public_path() . '/images/', $filename);
         $kid->picture = 'images/' . $filename;
         $kid->save();
     }
     $kidid = $kid->id;
     //get the authenticated user
     $user = Auth::user();
     //associate the kid to the user
     $user->kids()->attach($kid);
     //Give the kid an attendance of sign out
     $attendance = \p4\Attendance::create(['kid_id' => $kidid, 'attendancestatus' => 0]);
     //flash a success message when a kid is added to the database
     \Session::flash('flash_message', $kid->fullname . ' Has been registered in Sign-In Whiz');
     return redirect('/childregister/create');
 }
예제 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $kid = \p4\Kid::firstOrCreate(['id' => 20]);
     $kid->firstname = 'Juluis';
     $kid->lastname = 'Go';
     $kid->birthday = 2010 - 05 - 07;
     $kid->picture = 'images/kid4.jpg';
     $kid->save();
     $kid = \p4\Kid::firstOrCreate(['id' => 21]);
     $kid->firstname = 'Pah';
     $kid->lastname = 'Lim';
     $kid->birthday = 2010 - 00 - 07;
     $kid->picture = 'images/kid4.jpg';
     $kid->save();
     $kid = \p4\Kid::firstOrCreate(['id' => 22]);
     $kid->firstname = 'Jus';
     $kid->lastname = 'Stry';
     $kid->birthday = 2011 - 05 - 10;
     $kid->picture = 'images/kid4.jpg';
     $kid->save();
     $kid = \p4\Kid::firstOrCreate(['id' => 23]);
     $kid->firstname = 'Mary';
     $kid->lastname = 'Store';
     $kid->birthday = 2012 - 05 - 07;
     $kid->picture = 'images/kid4.jpg';
     $kid->save();
     $kid = \p4\Kid::firstOrCreate(['id' => 24]);
     $kid->firstname = 'Juluis';
     $kid->lastname = 'Go';
     $kid->birthday = 2012 - 05 - 07;
     $kid->picture = 'images/kid4.jpg';
     $kid->save();
     $kid = \p4\Kid::firstOrCreate(['id' => 25]);
     $kid->firstname = 'Brett';
     $kid->lastname = 'Lunz';
     $kid->birthday = 2013 - 05 - 07;
     $kid->picture = 'images/kid4.jpg';
     $kid->save();
     $faker = \Faker\Factory::create();
     foreach (range(1, 15) as $index) {
         Kid::create(['firstname' => $faker->firstName(), 'lastname' => $faker->lastName(), 'birthday' => $faker->dateTimeThisDecade->format('Y-m-d'), 'picture' => 'images/kid4.jpg', 'created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString()]);
     }
 }