You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WF-Website/src/Model/ImageModel.php

63 lines
1.4 KiB

<?php
namespace Model;
use Entity\ImageEntity;
use Gateway\ImageGateway;
use Gateway\Gateway;
class ImageModel extends Model
{
public function createImgModel(int $idImg, string $imgPath) : bool
{
return $this -> gateway -> createImgGateway($idImg, $imgPath);
}
public function createImgModelWithoutId (string $imgPath) : int
{
$idImg = $this->gateway ->getLastId() ;
$this -> gateway -> createImgGateway($idImg, $imgPath, false);
return $idImg;
}
public function getImgById(int $idImg) : ?ImageEntity
{
$res = $this -> gateway -> findImgById($idImg);
if ($res)
{
return new ImageEntity(
$res[0]['id_img'],
$res[0]['imgpath']
);
}
return null;
}
public function getAllImg() : array
{
$res = $this -> gateway -> findAllImg();
$images = [];
foreach ($res as $img)
{
$images[] = new ImageEntity(
$img['id_img'],
$img['imgpath']
);
}
return $images;
}
public function deleteImgModel(int $idImg) : bool
{
return $this -> gateway -> deleteImgGateway($idImg);
}
public function updateImgModel(int $idImg, string $imgPath) : bool
{
return $this -> gateway -> updateImgGateway($idImg, $imgPath);
}
}