mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-21 00:46:27 +02:00
to keep
This commit is contained in:
parent
65dacb5302
commit
4c27d8ccf2
13 changed files with 121 additions and 137 deletions
|
@ -16,18 +16,6 @@ namespace models;
|
|||
*/
|
||||
class Phone extends \descartes\Model
|
||||
{
|
||||
/**
|
||||
* Return list of phones.
|
||||
* @param int $id_user : User id
|
||||
* @param int $limit : Number of user to return
|
||||
* @param int $offset : Number of user to skip
|
||||
*/
|
||||
public function list($id_user, $limit, $offset)
|
||||
{
|
||||
return $this->_select('phone', ['id_user' => $id_user], null, false, $limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a phone by his id
|
||||
* @param int $id : Phone id
|
||||
|
@ -37,24 +25,27 @@ namespace models;
|
|||
{
|
||||
return $this->_select_one('phone', ['id' => $id]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a phone by his number
|
||||
* @param string $number : phone number
|
||||
* @return array
|
||||
* Return list of phones.
|
||||
* @param int $id_user : User id
|
||||
* @param int $limit : Number of user to return
|
||||
* @param int $offset : Number of user to skip
|
||||
*/
|
||||
public function get_by_number (string $number)
|
||||
public function list_for_user($id_user, $limit, $offset)
|
||||
{
|
||||
return $this->_select_one('phone', ['number' => $number]);
|
||||
return $this->_select('phone', ['id_user' => $id_user], null, false, $limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a phone by his number and user
|
||||
* @param string $number : phone number
|
||||
* @param int $id_user : user id
|
||||
* @return array
|
||||
*/
|
||||
public function get_by_number_and_user (string $number, int $id_user)
|
||||
public function get_by_number_for_user (string $number, int $id_user)
|
||||
{
|
||||
return $this->_select_one('phone', ['number' => $number, 'id_user' => $id_user]);
|
||||
}
|
||||
|
@ -71,23 +62,14 @@ namespace models;
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find all phones
|
||||
* @return array
|
||||
*/
|
||||
public function get_all ()
|
||||
{
|
||||
return $this->_select('phone');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a phone
|
||||
* @param int $id : phone id
|
||||
* @return array
|
||||
*/
|
||||
public function delete ($id)
|
||||
public function delete_for_user ($id_user, $id)
|
||||
{
|
||||
return $this->_delete('phone', ['id' => $id]);
|
||||
return $this->_delete('phone', ['id_user' => $id_user, 'id' => $id]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,13 +91,11 @@ namespace models;
|
|||
* Update a phone
|
||||
* @param int $id : Id of the phone
|
||||
* @param int $id_user : User to insert phone for
|
||||
* @param string $number : The number of the phone
|
||||
* @param string $adapter : The adapter to use the phone
|
||||
* @param string JSON $adapter_datas : A json string representing the datas of the adapter (for exemple credentials of an api)
|
||||
* @param array $phone : updated datas
|
||||
* @return mixed bool : false on error, true on success
|
||||
*/
|
||||
public function update ($id, $phone)
|
||||
public function update_for_user ($id_user, $id, $phone)
|
||||
{
|
||||
return (bool) $this->_update('phone', $phone, ['id' => $id]);
|
||||
return (bool) $this->_update('phone', $phone, ['id_user' => $id_user, 'id' => $id]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue