Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = new User();
     $user->name = 'mugekural';
     $user->surname = str_random(10);
     $user->email = $user->name . '@gmail.com';
     $user->is_active = true;
     $user->password = bcrypt('12345');
     $user->type = 'App\\Supplier';
     $user->save();
     $supplier = new Supplier();
     $supplier->phone = '023123';
     $supplier->id = $user->id;
     $supplier->save();
     $user2 = new User();
     $user2->name = str_random(10);
     $user2->surname = str_random(10);
     $user2->email = $user2->name . '@gmail.com';
     $user2->is_active = true;
     $user2->type = 'App\\Customer';
     $user2->save();
     $customer = new Customer();
     $customer->phone = "053247557437";
     $customer->id = $user2->id;
     $customer->save();
     $instagram = new InstagramAccount();
     $instagram->instagram_id = "1231231";
     $instagram->access_token = "asdaddads";
     $instagram->username = "******";
     $instagram->full_name = "omer faruk";
     $instagram->bio = "fdsfasfdsf";
     $instagram->website = "string";
     $instagram->profile_picture = "";
     $supplier->instagramAccount()->save($instagram);
     $product = new Product();
     $product->supplier_id = $supplier->id;
     $product->id = "235";
     $product->is_active = true;
     $product->title = "kitap";
     $product->description = "martı";
     $product->price = "340";
     $product->save();
     $instagram2 = new InstagramAccount();
     $instagram2->instagram_id = "700797";
     $instagram2->access_token = "fjfjjfjfjf";
     $instagram2->username = "******";
     $instagram2->full_name = "muge kural";
     $instagram2->bio = "comp stud";
     $instagram2->website = "some string";
     $instagram2->profile_picture = "";
     $customer->instagramAccount()->save($instagram2);
 }
Ejemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $rules = array('firstname' => 'required', 'surname' => 'required', 'customeremail' => 'required|email', 'pass' => 'required', 'phone' => 'required', 'rpass' => 'required|same:pass');
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         // get the error messages from the validator
         $messages = $validator->messages();
         // redirect our user back to the form with the errors from the validator
         return back()->withInput()->withErrors($messages);
     } else {
         if (User::where('email', $request->input('customeremail'))->first()) {
             return redirect()->action('AuthenticationController@showRegister')->withErrors(['messages' => "Sistemde mail adresi kayıtlı"]);
         }
         $user = new User();
         $user->name = trim($request->input('firstname'));
         $user->surname = trim($request->input('surname'));
         $user->setAsCustomer();
         $user->is_active = false;
         $user->email = $request->input('customeremail');
         $user->password = bcrypt($request->input('pass'));
         $user->save();
         $customer = new Customer();
         $customer->phone = $request->input('phone');
         $customer->id = $user->id;
         $customer->save();
         if (Session::has('user_instagram_info')) {
             $instagramInfo = Session::pull('user_instagram_info');
             $instagramAccount = new InstagramAccount();
             $instagramAccount->instagram_id = $instagramInfo->user->id;
             $instagramAccount->username = $instagramInfo->user->username;
             $instagramAccount->access_token = $instagramInfo->access_token;
             $instagramAccount->full_name = $instagramInfo->user->full_name;
             $instagramAccount->bio = $instagramInfo->user->bio;
             $instagramAccount->website = $instagramInfo->user->website;
             $instagramAccount->profile_picture = $instagramInfo->user->profile_picture;
             $customer->instagramAccount()->save($instagramAccount);
         }
         Storage::makeDirectory($user->id);
         return redirect()->action('AuthenticationController@showRegister')->with('success', ['Successful']);
     }
 }