/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('voters')->delete();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 100; $i++) {
         Voter::create(['first_name' => $faker->firstName, 'middle_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => $faker->email, 'contact_number' => $faker->phoneNumber, 'batch_number' => rand(1, 12)]);
     }
 }
Ejemplo n.º 2
0
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['first_name' => 'required|max:130', 'middle_name' => 'max:30|alpha', 'last_name' => 'max:30|alpha', 'email' => 'required|email|unique:voters', 'contact_number' => 'max:99999999999999999999', 'batch_number' => 'required|min:1|max:120']);
     if ($validator->fails()) {
         return back()->withErrors($validator)->withInput();
     } else {
         $voter = Voter::create($request->all());
         return view('dashboard.home')->with('message', 'Voter added Successfully.');
     }
 }
Ejemplo n.º 3
0
 public function vote(VoteOnPoll $request)
 {
     $poll = Option::findOrFail($request->input('option.0'))->poll;
     foreach ($request->input('option') as $option) {
         Option::findOrFail($option)->increment('votes');
     }
     if ($poll->ip_checking == 1) {
         $voter = Voter::create(['poll_id' => $poll->id, 'ip_address' => $request->ip()]);
     }
     session()->flash('flash_message', ['title' => 'Success!', 'message' => 'Your vote has been counted.', 'type' => 'success']);
     return redirect('poll/' . $poll->slug . '/result');
 }