parent
da6d77f78d
commit
91ffe63c93
@ -1,45 +1,56 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
use Entity\CommentaryEntity;
|
use Entity\CommentaryEntity;
|
||||||
use Gateway\CommentaryGateway;
|
use Gateway\CommentaryGateway;
|
||||||
use Gateway\Gateway;
|
use Gateway\Gateway;
|
||||||
|
|
||||||
|
|
||||||
class CommentaryModel extends Model {
|
class CommentaryModel extends Model {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new comment associated with a specific quote and user.
|
||||||
|
*
|
||||||
|
* @param string $comment The content of the comment.
|
||||||
|
* @param string $idQuote The identifier of the quote the comment is associated with.
|
||||||
|
* @param string $idUser The identifier of the user who is creating the comment.
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the comment was successfully created, otherwise false.
|
||||||
|
*/
|
||||||
public function createComment(string $comment, string $idQuote, string $idUser): bool {
|
public function createComment(string $comment, string $idQuote, string $idUser): bool {
|
||||||
|
// Calls the gateway's create method to insert the new comment into the data source.
|
||||||
return $this->gateway->create($comment, $idUser, $idQuote);
|
return $this->gateway->create($comment, $idUser, $idQuote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all comments associated with a specific quote.
|
||||||
|
*
|
||||||
|
* @param int $id The unique identifier of the quote.
|
||||||
|
*
|
||||||
|
* @return CommentaryEntity[] Returns an array of CommentaryEntity objects representing all the comments for the given quote.
|
||||||
|
*/
|
||||||
public function getComment(int $id): array {
|
public function getComment(int $id): array {
|
||||||
|
// Initialize an empty array to store the comment objects.
|
||||||
$com = [];
|
$com = [];
|
||||||
|
|
||||||
|
// Fetch all comments related to the given quote ID using the gateway's findByQuote method.
|
||||||
$res = $this->gateway->findByQuote($id);
|
$res = $this->gateway->findByQuote($id);
|
||||||
foreach ($res as $comments){
|
|
||||||
$com[] = new CommentaryEntity($comments["id_comment"], $comments["comment"], $comments["datec"], $comments["username"], $comments["imgpath"]);
|
|
||||||
}
|
|
||||||
return $com;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getComments(): array {
|
// Loop through each comment in the result and create a CommentaryEntity object for each.
|
||||||
$res = $this->gateway->findAll();
|
|
||||||
foreach ($res as $comments) {
|
foreach ($res as $comments) {
|
||||||
$com[] = new CommentaryEntity($comments["id_comment"], $comments["comment"], $comments["date"]);
|
$com[] = new CommentaryEntity(
|
||||||
|
$comments["id_comment"], // Comment ID
|
||||||
|
$comments["comment"], // The content of the comment
|
||||||
|
$comments["datec"], // The date the comment was created
|
||||||
|
$comments["username"], // The username of the user who made the comment
|
||||||
|
$comments["imgpath"] // The image path associated with the user who made the comment
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $com;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteComment(int $id_comment): bool {
|
// Return the array of CommentaryEntity objects.
|
||||||
return $this -> gateway -> delete($id_comment);
|
return $com;
|
||||||
}
|
|
||||||
|
|
||||||
public function updateComment(int $id_comment, string $comment): bool {
|
|
||||||
|
|
||||||
$c = $this -> getComment($id_comment);
|
|
||||||
|
|
||||||
if($c){
|
|
||||||
$c -> setComment($comment);
|
|
||||||
return $this->gateway -> update($c);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Model;
|
|
||||||
use Gateway\FavoriteGateway;
|
|
||||||
use Entity\FavoriteEntity;
|
|
||||||
use Gateway\Gateway;
|
|
||||||
|
|
||||||
class FavoriteModel extends Model
|
|
||||||
{
|
|
||||||
public function createFavoriteModel(int $idUser, int $idQuote) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> createFavoriteGateway($idUser, $idQuote);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFavoriteById(int $idUser, int $idQuote) : ?FavoriteEntity
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findFavoriteById($idUser, $idQuote);
|
|
||||||
|
|
||||||
if ($res)
|
|
||||||
{
|
|
||||||
return new FavoriteEntity (
|
|
||||||
$res[0]['user_f'],
|
|
||||||
$res[0]['quote_f'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFavoriteByUser(int $idUser) : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findFavoriteByUser($idUser);
|
|
||||||
|
|
||||||
$favorites = [];
|
|
||||||
|
|
||||||
foreach ($res as $favorite)
|
|
||||||
{
|
|
||||||
$favorites = new FavoriteEntity (
|
|
||||||
$favorite['user_f'],
|
|
||||||
$favorite['quote_f']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $favorites;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllFavorite() : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findAllFavorite();
|
|
||||||
|
|
||||||
$favorites = [];
|
|
||||||
|
|
||||||
foreach ($res as $favorite)
|
|
||||||
{
|
|
||||||
$favorites = new FavoriteEntity (
|
|
||||||
$favorite['user_f'],
|
|
||||||
$favorite['quote_f']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $favorites;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeFavorite(int $idUser, int $idQuote) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> deleteFavoriteGateway($idUser, $idQuote);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
|
|
||||||
use Entity\ImageEntity;
|
use Entity\ImageEntity;
|
||||||
use Gateway\ImageGateway;
|
use Gateway\ImageGateway;
|
||||||
use Gateway\Gateway;
|
use Gateway\Gateway;
|
||||||
|
|
||||||
|
|
||||||
class ImageModel extends Model
|
class ImageModel extends Model
|
||||||
{
|
{
|
||||||
public function createImgModel(int $idImg, string $imgPath) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> createImgGateway($idImg, $imgPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getImgById(int $idImg) : ?ImageEntity
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findImgById($idImg);
|
|
||||||
|
|
||||||
if ($res)
|
/**
|
||||||
{
|
* Retrieves all images from the database.
|
||||||
return new ImageEntity(
|
*
|
||||||
$res[0]['id_img'],
|
* @return ImageEntity[] Returns an array of ImageEntity objects representing all the images.
|
||||||
$res[0]['imgpath']
|
*/
|
||||||
);
|
public function getAllImg() : array {
|
||||||
}
|
// Fetch all images using the gateway's findAllImg method.
|
||||||
return null;
|
$res = $this->gateway->findAllImg();
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllImg() : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findAllImg();
|
|
||||||
|
|
||||||
|
// Initialize an empty array to store the ImageEntity objects.
|
||||||
$images = [];
|
$images = [];
|
||||||
|
|
||||||
foreach ($res as $img)
|
// Loop through each image in the result and create an ImageEntity object for each.
|
||||||
{
|
foreach ($res as $img) {
|
||||||
$images[] = new ImageEntity(
|
$images[] = new ImageEntity(
|
||||||
$img['id_img'],
|
$img['id_img'], // Image ID
|
||||||
$img['imgpath']
|
$img['imgpath'] // Image path (location or URL of the image)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $images;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Return the array of ImageEntity objects.
|
||||||
public function deleteImgModel(int $idImg) : bool
|
return $images;
|
||||||
{
|
|
||||||
return $this -> gateway -> deleteImgGateway($idImg);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function updateImgModel(int $idImg, string $imgPath) : bool
|
?>
|
||||||
{
|
|
||||||
return $this -> gateway -> updateImgGateway($idImg, $imgPath);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +1,60 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
|
|
||||||
use Entity\quizEntity;
|
use Entity\quizEntity;
|
||||||
use Gateway\QuizGateway;
|
use Gateway\QuizGateway;
|
||||||
use Gateway\Gateway;
|
use Gateway\Gateway;
|
||||||
|
|
||||||
|
|
||||||
class QuizModel extends Model{
|
class QuizModel extends Model{
|
||||||
|
|
||||||
public function createQuiz(int $id_quiz, int $nb_questions) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> create($id_quiz, $nb_questions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getQuiz(int $id_quiz): ?quizEntity
|
/**
|
||||||
{
|
* Retrieves a quiz by its unique identifier.
|
||||||
$q = $this -> gateway -> findQuizById($id_quiz);
|
*
|
||||||
|
* @param int $id_quiz The unique identifier of the quiz to retrieve.
|
||||||
|
*
|
||||||
|
* @return quizEntity|null Returns a quizEntity object if found, otherwise null.
|
||||||
|
*/
|
||||||
|
public function getQuiz(int $id_quiz): ?quizEntity{
|
||||||
|
// Attempt to find the quiz by its ID using the gateway's findQuizById method.
|
||||||
|
$q = $this->gateway->findQuizById($id_quiz);
|
||||||
|
|
||||||
|
// If the quiz is found, create and return a new quizEntity object with the quiz details.
|
||||||
if ($q) {
|
if ($q) {
|
||||||
return new quizEntity(
|
return new quizEntity(
|
||||||
$q[0]['id_quiz'],
|
$q[0]['id_quiz'], // Quiz ID
|
||||||
$q[0]['nb_quest']
|
$q[0]['nb_quest'] // The number of questions in the quiz
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteQuiz(int $id_quiz) : bool
|
// If no quiz is found, return null.
|
||||||
{
|
return null;
|
||||||
return $this -> gateway -> delete($id_quiz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllQuiz() : array
|
/**
|
||||||
{
|
* Retrieves all quizzes from the database.
|
||||||
$q = $this -> gateway -> findAll();
|
*
|
||||||
|
* @return quizEntity[] Returns an array of quizEntity objects representing all the quizzes.
|
||||||
|
*/
|
||||||
|
public function getAllQuiz() : array{
|
||||||
|
// Fetch all quizzes using the gateway's findAll method.
|
||||||
|
$q = $this->gateway->findAll();
|
||||||
|
|
||||||
|
// Initialize an empty array to store the quiz objects.
|
||||||
$quizzes = [];
|
$quizzes = [];
|
||||||
|
|
||||||
|
// Loop through each quiz in the result and create a quizEntity object for each.
|
||||||
foreach ($q as $quiz) {
|
foreach ($q as $quiz) {
|
||||||
$quizzes[] = new quizEntity(
|
$quizzes[] = new quizEntity(
|
||||||
$quiz['id_quiz'],
|
$quiz['id_quiz'], // Quiz ID
|
||||||
$quiz['nb_questions']
|
$quiz['nb_questions'] // The number of questions in the quiz
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $quizzes;
|
|
||||||
|
|
||||||
|
// Return the array of quizEntity objects.
|
||||||
|
return $quizzes;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,91 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Model;
|
|
||||||
|
|
||||||
use Entity\ResultsEntity;
|
|
||||||
use Gateway\ResultsGateway;
|
|
||||||
use Gateway\Gateway;
|
|
||||||
|
|
||||||
class ResultsModel extends Model
|
|
||||||
{
|
|
||||||
|
|
||||||
public function createResultsModel(int $idQuiz, int $idUser, int $score, int $time) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> createResultsGateway($idQuiz, $idUser, $score, $time);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResultsByQuiz(int $idQuiz) : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findResultsByQuiz($idQuiz);
|
|
||||||
|
|
||||||
$results = [];
|
|
||||||
|
|
||||||
foreach ($res as $result)
|
|
||||||
{
|
|
||||||
$results[] = new ResultsEntity (
|
|
||||||
$result['user_r'],
|
|
||||||
$result['quiz_r'],
|
|
||||||
$result['score'],
|
|
||||||
$result['time']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResultsByUser(int $idUser) : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findResultsByUser($idUser);
|
|
||||||
|
|
||||||
$results = [];
|
|
||||||
|
|
||||||
foreach ($res as $result)
|
|
||||||
{
|
|
||||||
$results[] = new ResultsEntity (
|
|
||||||
$result['user_r'],
|
|
||||||
$result['quiz_r'],
|
|
||||||
$result['score'],
|
|
||||||
$result['time']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResultsById(int $idQuiz, int $idUser) : ?ResultsEntity
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findResultsById($idQuiz, $idUser);
|
|
||||||
|
|
||||||
if ($res)
|
|
||||||
{
|
|
||||||
return new ResultsEntity (
|
|
||||||
$res['user_r'],
|
|
||||||
$res['quiz_r'],
|
|
||||||
$res['score'],
|
|
||||||
$res['time']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllResults() : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findAllResults();
|
|
||||||
|
|
||||||
$results = [];
|
|
||||||
|
|
||||||
foreach ($res as $result)
|
|
||||||
{
|
|
||||||
$results[] = new ResultsEntity (
|
|
||||||
$result['user_r'],
|
|
||||||
$result['quiz_r'],
|
|
||||||
$result['score'],
|
|
||||||
$result['time']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateResultsModel(int $idQuiz, int $idUser, ?int $score, ?int $time) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> updateResults($idQuiz, $idUser, $score, $time);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +1,126 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
use Entity\SourceEntity;
|
use Entity\SourceEntity;
|
||||||
use Enum\TypeSourceEnum;
|
use Enum\TypeSourceEnum;
|
||||||
|
|
||||||
|
|
||||||
class SourceModel extends Model
|
class SourceModel extends Model
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new source with the provided title, date, and type.
|
||||||
|
*
|
||||||
|
* @param string $title The title of the source.
|
||||||
|
* @param string $date The date associated with the source.
|
||||||
|
* @param TypeSourceEnum $type The type of the source (e.g., Movie, Book, etc.).
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the source was successfully created, false otherwise.
|
||||||
|
*/
|
||||||
public function createSource(string $title, string $date, TypeSourceEnum $type) : bool
|
public function createSource(string $title, string $date, TypeSourceEnum $type) : bool
|
||||||
{
|
{
|
||||||
$q = new SourceEntity(-1,$title, $date, TypeSourceEnum::Movie/*$type*/);
|
// Create a new SourceEntity with the given title, date, and type.
|
||||||
|
// Note: The type is hardcoded as "Movie" in this implementation.
|
||||||
|
$q = new SourceEntity(-1, $title, $date, TypeSourceEnum::Movie);
|
||||||
|
|
||||||
return $this -> gateway -> create($q);
|
// Use the gateway to insert the new source and return the result.
|
||||||
|
return $this->gateway->create($q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a source by its unique identifier.
|
||||||
|
*
|
||||||
|
* @param int $id_source The unique identifier of the source.
|
||||||
|
*
|
||||||
|
* @return SourceEntity|null Returns a SourceEntity object if found, or null if no source is found with the given ID.
|
||||||
|
*/
|
||||||
public function getSourceById(int $id_source) : ?SourceEntity
|
public function getSourceById(int $id_source) : ?SourceEntity
|
||||||
{
|
{
|
||||||
$res = $this -> gateway -> findById($id_source);
|
// Fetch the source by ID using the gateway's findById method.
|
||||||
|
$res = $this->gateway->findById($id_source);
|
||||||
if ($res)
|
|
||||||
return new sourceEntity(
|
// If a source is found, return a SourceEntity object.
|
||||||
$res[0]["id_source"],
|
if ($res) {
|
||||||
$res[0]["title"],
|
return new SourceEntity(
|
||||||
$res[0]["dates"],
|
$res[0]["id_source"], // Source ID
|
||||||
TypeSourceEnum::Movie//from($res[0]["type"])
|
$res[0]["title"], // Title of the source
|
||||||
|
$res[0]["dates"], // Date associated with the source
|
||||||
|
TypeSourceEnum::Movie // Hardcoded to "Movie" type; you may consider dynamically mapping this
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
// Return null if no source is found.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a source by its title.
|
||||||
|
*
|
||||||
|
* @param string $title The title of the source to search for.
|
||||||
|
*
|
||||||
|
* @return SourceEntity|null Returns a SourceEntity object if found, or null if no source is found with the given title.
|
||||||
|
*/
|
||||||
public function getSourceByTitle(string $title) : ?SourceEntity
|
public function getSourceByTitle(string $title) : ?SourceEntity
|
||||||
{
|
{
|
||||||
|
// Fetch the source by title using the gateway's findByTitle method.
|
||||||
$res = $this->gateway->findByTitle($title);
|
$res = $this->gateway->findByTitle($title);
|
||||||
if ($res)
|
|
||||||
return new sourceEntity(
|
|
||||||
$res[0]["id_source"],
|
|
||||||
$res[0]["title"],
|
|
||||||
$res[0]["dates"],
|
|
||||||
TypeSourceEnum::Movie//from($res[0]["type"])
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSourceByDate(string $date) : array
|
|
||||||
{
|
|
||||||
$res = $this->gateway->findByDate($date);
|
|
||||||
$src = [];
|
|
||||||
foreach ($res as $sources) {
|
|
||||||
$src[] = new sourceEntity(
|
|
||||||
$sources["id_source"],
|
|
||||||
$sources["title"],
|
|
||||||
$sources["dates"],
|
|
||||||
TypeSourceEnum::from($sources["type"])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $src;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSourceByType(TypeSourceEnum $type) : array
|
// If a source is found, return a SourceEntity object.
|
||||||
{
|
if ($res) {
|
||||||
$res = $this->gateway->findByType($type);
|
return new SourceEntity(
|
||||||
$src = [];
|
$res[0]["id_source"], // Source ID
|
||||||
foreach ($res as $sources) {
|
$res[0]["title"], // Title of the source
|
||||||
$src[] = new sourceEntity(
|
$res[0]["dates"], // Date associated with the source
|
||||||
$sources["id_source"],
|
TypeSourceEnum::Movie // Hardcoded to "Movie" type; dynamic mapping could be considered
|
||||||
$sources["title"],
|
|
||||||
$sources["dates"],
|
|
||||||
TypeSourceEnum::from($sources["type"])
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $src;
|
// Return null if no source is found.
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all sources from the database.
|
||||||
|
*
|
||||||
|
* @return SourceEntity[] Returns an array of SourceEntity objects representing all the sources.
|
||||||
|
*/
|
||||||
public function getAllSources() : array
|
public function getAllSources() : array
|
||||||
{
|
{
|
||||||
$res = $this -> gateway -> findAll();
|
// Fetch all sources from the gateway's findAll method.
|
||||||
|
$res = $this->gateway->findAll();
|
||||||
|
|
||||||
|
// Initialize an empty array to store the SourceEntity objects.
|
||||||
$src = [];
|
$src = [];
|
||||||
|
|
||||||
|
// Loop through the result and create a SourceEntity object for each source.
|
||||||
foreach ($res as $sources) {
|
foreach ($res as $sources) {
|
||||||
$src[] = new SourceEntity(
|
$src[] = new SourceEntity(
|
||||||
$sources["id_source"],
|
$sources["id_source"], // Source ID
|
||||||
$sources["title"],
|
$sources["title"], // Title of the source
|
||||||
$sources["dates"],
|
$sources["dates"], // Date associated with the source
|
||||||
TypeSourceEnum::Movie
|
TypeSourceEnum::Movie // Hardcoded to "Movie" type; you may consider dynamically mapping this
|
||||||
//TypeSourceEnum::from($sources["type"])
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $src;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteSource(int $id_source) : bool
|
// Return the array of SourceEntity objects.
|
||||||
{
|
return $src;
|
||||||
return $this -> gateway -> delete($id_source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateSource(int $id_source, string $title, string $date) : bool
|
/**
|
||||||
|
* Checks if a source with the given name and type exists.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the source to check.
|
||||||
|
* @param string $type The type of the source to check (e.g., Movie, Book, etc.).
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the source exists, false otherwise.
|
||||||
|
*/
|
||||||
|
public function existSource(string $name, string $type) : bool
|
||||||
{
|
{
|
||||||
$q = $this -> getSourceById($id_source);
|
// Retrieve the source by title using the getSourceByTitle method.
|
||||||
|
$q = $this->getSourceByTitle($name);
|
||||||
|
|
||||||
if ($q){
|
// Check if the source exists and return the result.
|
||||||
$q -> setTitle($title);
|
|
||||||
$q -> setDate($date);
|
|
||||||
return $this -> gateway -> update($q);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function existSource(string $name, string $type) : bool{
|
|
||||||
$q = $this -> getSourceByTitle($name);
|
|
||||||
return isset($q[0]);
|
return isset($q[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in new issue