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');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $this->validate($request, ['taken_at' => '', 'return_at' => '', 'user_id' => 'required', 'property_id' => 'required', 'pin' => 'required']);
     $takenAt = $request->input('taken_at');
     $returnedAt = $request->input('returned_at');
     $userId = $request->input('user_id');
     $propertyId = $request->input('property_id');
     $pin = $request->input('pin');
     $newKey = new Key();
     $newKey->taken_at = $takenAt;
     $newKey->returned_at = $returnedAt;
     $newKey->user_id = $userId;
     $newKey->property_id = $propertyId;
     $newKey->pin = $pin;
     $newKey->save();
     return Redirect::route('keys.show', [$newKey->id]);
 }
Exemplo n.º 3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // if ($request->ajax()) {
     $key = $this->getUniqueRandomKey();
     $url = $request->input('user_url');
     $data = new Key();
     $data->url = $url;
     $data->user_id = $request->input('user_id');
     $data->ip = $request->getClientIp();
     $data->key = $key;
     $data->save();
     //checking the url repetition and if repeated then returning the old key
     if ($this->checkUserUrlRepetition($url)) {
         $repeated_key = DB::table('keys')->where('keys.url', '=', $url)->where('user_id', '=', 2)->value('key');
         $full_url = "http://ucut.in/" . $repeated_key;
     } else {
         $full_url = "http://ucut.in/" . $key;
     }
     return response()->json(['message' => 'successful', 'url' => $full_url]);
     //}
 }
 public function addContractor(Request $request, $id)
 {
     $contractorId = $request->Input('contractor_id');
     $pin = $request->Input('pin');
     $key = new Key();
     $key->pin = $pin;
     $key->user_id = $contractorId;
     $key->property_id = $id;
     $key->taken_at = "0000-00-00 00:00:00";
     $key->returned_at = "0000-00-00 00:00:00";
     $key->save();
     return Redirect::route('properties.show', [$id]);
 }
 public function addKey(Request $request, $id)
 {
     $propertyId = $request->Input('property_id');
     $pin = $request->Input('pin');
     $contractor = User::find($id);
     $key = new Key();
     $key->pin = $pin;
     $key->user_id = $id;
     $key->property_id = $propertyId;
     $key->taken_at = "0000-00-00 00:00:00";
     $key->returned_at = "0000-00-00 00:00:00";
     $key->save();
     return Redirect::route('contractors.show', $id);
 }