Ejemplo n.º 1
0
 public function checkUrlId($id)
 {
     $url_id = Key::find($id);
     if ($url_id) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 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 testKeyUpdate()
 {
     $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();
     $key = Key::find($newKey->id);
     $key->pin = "1234";
     $key->save();
     $this->actingAs($admin)->withSession(['foo' => 'bar'])->visit($this->modelUrl . (string) $key->id)->assertTrue($key->pin == '1234');
 }
 public function removeKey(Request $request, $id)
 {
     $keyId = $request->Input('key_id');
     $key = Key::find($keyId);
     $key->delete();
     return Redirect::route('contractors.show', $id);
 }
Ejemplo n.º 5
0
 public function updateUrlTitle(Request $request)
 {
     $keys = Key::find($request->id);
     $keys->title = $this->get_title($request->link);
     $keys->update();
     return $keys->title;
 }