Commit 36f61572 authored by Andrea Ruggiero's avatar Andrea Ruggiero
Browse files

Fix

parent 77e18475
Pipeline #1528 failed with stage
in 0 seconds
......@@ -9,7 +9,7 @@ class AccomodationRepository extends BaseRepository
protected $table = 'accomodations';
public function getById($id) {
return $this->db->where('accomodation_id', $id)->first();
return $this->db()->where('accomodation_id', $id)->first();
}
}
\ No newline at end of file
......@@ -15,11 +15,15 @@ class BaseRepository
protected $table;
public function __construct(DatabaseManager $db) {
$this->db = $db->table($this->table);
$this->db = $db;
}
public function all() {
return $this->db->get();
return $this->db->table($this->table)->get();
}
protected function db() {
return $this->db->table($this->table);
}
}
\ No newline at end of file
......@@ -9,19 +9,19 @@ class BookingRepository extends BaseRepository
protected $table = 'bookings';
public function addBooking($user_id, $event_id) {
return $this->db->insert(['user_id' => $user_id, 'event_id' => $event_id]);
return $this->db()->insert(['user_id' => $user_id, 'event_id' => $event_id]);
}
public function deleteBooking($user_id, $event_id) {
return $this->db->where('event_id', $event_id)->where('user_id', $user_id)->delete();
return $this->db()->where('event_id', $event_id)->where('user_id', $user_id)->delete();
}
public function getBookingsByEvent($event_id) {
return $this->db->where('event_id', $event_id)->get();
return $this->db()->where('event_id', $event_id)->get();
}
public function getBookingByEventAndUser($user_id, $event_id) {
return $this->db->where('event_id', $event_id)->where('user_id', $user_id)->first();
return $this->db()->where('event_id', (int) $event_id)->where('user_id', $user_id)->first();
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ class EventRepository extends BaseRepository
protected $table = 'events';
public function get($id) {
return $this->db->where('event_id', $id)->first();
return $this->db()->where('event_id', $id)->first();
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ class RestaurantRepository extends BaseRepository
protected $table = 'restaurants';
public function get($id) {
return $this->db->where('id', $id)->first();
return $this->db()->where('id', $id)->first();
}
}
\ No newline at end of file
......@@ -9,18 +9,18 @@ class SessionRepository extends BaseRepository
protected $table = 'sessions';
public function getByToken($token) {
return $this->db->where('token', $token)->first();
return $this->db()->where('token', $token)->first();
}
public function addTokenToUser($token, $user_id) {
return $this->db->insert(['token' => $token, 'user_id' => $user_id]);
return $this->db()->insert(['token' => $token, 'user_id' => $user_id]);
}
public function removeToken($token) {
return $this->db->where('token', $token)->delete();
return $this->db()->where('token', $token)->delete();
}
public function getUserByToken($token) {
return $this->db->where('token', $token)->first();
return $this->db()->where('token', $token)->first();
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ class UserRepository extends BaseRepository
protected $table = 'users';
public function getById($id) {
return $this->db->where('user_id', $id)->first();
return $this->db()->where('user_id', $id)->first();
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -425,7 +425,7 @@
}
},
"/profile" : {
"post" : {
"get" : {
"tags" : [ "Users" ],
"summary" : "/profile",
"description" : "",
......@@ -473,7 +473,7 @@
}
},
"/accomodation" : {
"post" : {
"get" : {
"tags" : [ "Accomodations" ],
"summary" : "/accomodation",
"description" : "",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment