public function testKeyDelete()
 {
     $admin = User::find(1);
     $property = factory(App\Property::class)->create();
     $newKey = new Key();
     $newKey->taken_at = "2016-05-04 19:34:16";
     $newKey->returned_at = "2016-05-04 19:34:19";
     $newKey->pin = "7776";
     $newKey->property_id = $property->id;
     $newKey->user_id = $admin->id;
     $newKey->save();
     $this->actingAs($admin)->withSession(['foo' => 'bar'])->visit($this->modelUrl . (string) $newKey->id)->press('Delete')->seePageIs($this->modelUrl)->assertResponseStatus('200');
 }
Exemplo n.º 2
0
 public function checkUrlId($id)
 {
     $url_id = Key::find($id);
     if ($url_id) {
         return true;
     } else {
         return false;
     }
 }
 public function read(int $id)
 {
     if (!$this->keyOwnsList(\App\Key::find($_GET['key_id']), $id)) {
         return $this->error('Permission denied or non existent');
     }
     $response = ['list' => \App\ItemList::find($id), 'items' => []];
     $items = \App\Item::where('list_id', $id)->get();
     if (!empty($items)) {
         $response['items'] = $items;
     }
     return response()->json($response);
 }
 public function resendBallot($id)
 {
     $voter = Voter::find($id);
     if ($voter->voted == true) {
         return Redirect::to('/dashboard/voter')->with('message', 'User already voted. Cannot resend ballot');
     }
     $voter->key->delete();
     $key = Key::createKey($voter);
     //$this->sendEmail($voter->email,"Hello, ".$voter->first_name. ', http://election.yesalumnibd.org/ballot?key='.$key->key);
     $this->sendEmail($voter->email, "Dear YES Alumni,\n\n        \nHope you are well. This is your official email for voting. The link below has been uniquely generated in your name; so you can only vote once. Click on the URL, and you will be directed to the ballot page where you can cast your vote.\n        \nPlease note that the voting system will ONLY be active from 12:00AM to 11:59PM of Tuesday, 26 July, 2016. You must cast your vote within this time window.\n        \nAfter you have submitted your votes, you will be lead to an end page - that is the confirmation of your vote. If you face any problems during voting, please contact me at the given information below; the necessary actions will be taken.\n        \nThe results will be published after 5:00PM on Wednesday, 27 July, 2016.\n\n" . 'The ballot link: http://election.yesalumnibd.org/ballot?key=' . $key->key . "\n\n        \nThis event marks a great significance in the practice of democracy for the YES Alumni association in Bangladesh. Wishing you and the association all the very best!\n\n        \nBest regards,\n\n        \nMuhammad Maruf Ibne Wali\n        \nElection Commissioner\n        \nYES Alumni EC Elections 2016\n        \nPhone: 01716788220\n        \nemail: marufwali@yahoo.com");
     return Redirect::to('/dashboard/voter')->with('message', 'Ballot was resent to ' . $voter->first_name . '. Link: election.yesalumnibd.org/ballot?key=' . $key->key);
 }
Exemplo n.º 5
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(\Illuminate\Http\Request $request, Closure $next)
 {
     $key = $request->header('x-api-key');
     if (empty($key)) {
         return response()->json(['error' => 'Empty key']);
     }
     $key = \App\Key::where('key', $key)->first();
     if (empty($key)) {
         return response()->json(['error' => 'Invalid key']);
     }
     $_GET['key_id'] = $key->id;
     return $next($request);
 }
Exemplo n.º 6
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $key = Key::where('key', $request->input('key'))->first();
     if ($key == null) {
         $message = "You can't vote!";
         return view('form.success')->with('message', $message);
     }
     if ($key->voted) {
         $message = "You already voted.";
         return view('form.success')->with('message', $message);
     }
     return $next($request);
 }
Exemplo n.º 7
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $url = Key::findOrFail($id);
     $hits_count = Hit::all()->count();
     //Jit vs time
     $hits = Hit::where('url_id', $url->id)->select(DB::raw('date(created_at) as date'), DB::raw('count(id) as hits'))->groupBy(DB::raw('date(created_at)'))->distinct()->get();
     //Referral websites Data
     $referral_data = Redirected_websites::where('url_id', $url->id)->select(DB::raw('website_name as website'), DB::raw('count(website_name) as hits'))->groupBy('website_name')->distinct()->get();
     //country vs hits graph
     $country_data = Redirected_websites::where('url_id', $url->id)->select(DB::raw('(select(country_name) from countries where id =country_id) as country'), DB::raw('count(country_id) as hits'))->groupBy('country')->distinct()->get();
     //city vs hits graph
     $city_data = Redirected_websites::where('url_id', $url->id)->select(DB::raw('(select(city_name) from cities where id =city_id) as city'), DB::raw('count(city_id) as hits'))->groupBy('city')->distinct()->get();
     //Browser vs hits graph
     $browser_data = Redirected_websites::where('url_id', $url->id)->select(DB::raw('(select(browser_name) from browsers where id =browser_id) as browser'), DB::raw('count(browser_id) as hits'))->groupBy('browser')->distinct()->get();
     //Operating System vs hits graph
     $os_data = Redirected_websites::where('url_id', $url->id)->select(DB::raw('(select(operating_system) from operating_systems where id = os_id) as os'), DB::raw('count(os_id) as hits'))->groupBy('os')->distinct()->get();
     //platform Data
     $query1 = Redirected_websites::where('url_id', $url->id)->select(DB::raw('"Desktop"  as device'), DB::raw('count(is_desktop) as hit'))->where('is_desktop', 1)->groupBy('is_desktop')->get();
     $query2 = Redirected_websites::where('url_id', $url->id)->select(DB::raw('"Mobile"  as device'), DB::raw('count(is_mobile) as hits'))->where('is_mobile', 0)->groupBy('is_mobile')->get();
     $query3 = Redirected_websites::where('url_id', $url->id)->select(DB::raw('"Tablet"  as device'), DB::raw('count(is_tablet) as hits'))->where('is_tablet', 0)->groupBy('is_tablet')->get();
     $platform = array();
     array_push($platform, ['Desktop' => $query1, 'Mobile' => $query2, 'Tablet' => $query3]);
     return response()->json(['Total_hits' => $hits_count, 'Hits_data' => $this->hitsTransformer->transform($hits), 'City_data' => $this->cityTransformer->transform($city_data), 'Country_data' => $this->countryTransformer->transform($country_data), 'Browser_data' => $this->browserTransformer->transform($browser_data), 'Os_data' => $this->osTransformer->transform($os_data), 'Platforms_visit' => $platform]);
 }
Exemplo n.º 8
0
 public function getKeys($username)
 {
     $key = Key::where('username', $username)->first();
     return $key;
 }
Exemplo n.º 9
0
 public static function createKey($voter)
 {
     return Key::create(['voter_id' => $voter->id, 'key' => rand(1, 999999999), 'voted' => false]);
 }
 public function removeContractor(Request $request, $id)
 {
     $keyId = $request->Input('key_id');
     $key = Key::findOrFail($keyId);
     $key->delete();
     return Redirect::route('properties.show', [$id]);
 }
 public function addContractor(Request $request, $id)
 {
     $contractorId = $request->Input('contractor_id');
     $key = Key::findOrFail($id);
     $contractor = User::findOrFail($contractorId);
     $contractor->keys()->save($key);
     $contractor->save();
     return Redirect::route('keys.show', $id);
 }
 public function removeKey(Request $request, $id)
 {
     $keyId = $request->Input('key_id');
     $key = Key::find($keyId);
     $key->delete();
     return Redirect::route('contractors.show', $id);
 }
Exemplo n.º 13
0
 public function updateUrlTitle(Request $request)
 {
     $keys = Key::find($request->id);
     $keys->title = $this->get_title($request->link);
     $keys->update();
     return $keys->title;
 }
Exemplo n.º 14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Key::where('user_id', '=', 2)->find('id');
     Key::destroy($id);
 }
Exemplo n.º 15
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Voter::created(function ($voter) {
         Key::createKey($voter);
     });
 }