Example #1
0
 public function postRegister(Request $request)
 {
     $messages = ['email.required' => 'กรุณาใส่อีเมล์', 'email.email' => 'กรุณาใส่อีเมล์ให้ถูกต้อง', 'email.unique' => 'อีเมล์ดังกล่าวมีในระบบแล้ว', 'password.required' => 'กรุณาใส่พาสเวิร์ด', 'password.min' => 'พาสเวิร์ดต้องยาวกว่าหรือเท่ากับ 6 ตัวอักษร'];
     $validator = Validator::make($request->all(), ['email' => 'required|email|unique:ch_member,email', 'password' => 'required|min:6'], $messages);
     //$request->session()->put('data', 'value');
     if ($validator->fails()) {
         return redirect('/register')->withErrors($validator)->withInput();
     }
     $member = new \App\Models\Member();
     $member->email = $request->email;
     $member->password = Hash::make($request->password);
     $member->type = 1;
     $member->active = 0;
     $nextMonth = date('Y-m-d H:i:s', mktime(date("H"), date("i"), date("s"), date("m") + 1, date("d"), date("Y")));
     $member->active_til = $nextMonth;
     $member->save();
     $request->session()->put('member', $member);
     return redirect('member');
 }
Example #2
0
function seed_member()
{
    if (!class_exists('Faker\\Factory')) {
        return false;
    }
    $faker = Faker\Factory::create();
    for ($i = 0; $i < 100; $i++) {
        $user = new App\Models\Member();
        $user->fullname = $faker->name;
        $user->usermail = $faker->freeEmail;
        $user->password = app('hash')->make($faker->password);
        $user->mobile = $faker->phoneNumber;
        $user->address = $faker->address;
        $user->zipcode = $faker->postcode;
        $user->country = 'SG';
        $user->online = 0;
        $user->status = $faker->numberBetween(0, 2);
        $user->activation_code = app('hash')->make($user->usermail);
        $user->save();
    }
}