2024-11-29 13:23:48 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\modules\photo;
|
|
|
|
|
2025-01-19 17:15:58 +03:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use kernel\app_modules\photo\models\Photo;
|
|
|
|
|
2024-12-09 16:35:43 +03:00
|
|
|
class PhotoModule extends \kernel\app_modules\photo\PhotoModule
|
2024-11-29 13:23:48 +03:00
|
|
|
{
|
|
|
|
|
2025-01-19 17:15:58 +03:00
|
|
|
public function getItems(string $entity, Model $model): array|string
|
|
|
|
{
|
|
|
|
$photos = Photo::where("entity", $entity)->where("entity_id", $model->id)->get();
|
|
|
|
$photoArr = [];
|
|
|
|
foreach ($photos as $photo) {
|
|
|
|
$photoArr[] =$photo->image;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $photoArr;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getItem(string $entity, string $entity_id): string
|
|
|
|
{
|
|
|
|
$photos = Photo::where("entity", $entity)->where("entity_id", $entity_id)->first();
|
|
|
|
if ($photos){
|
|
|
|
return $photos->image;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2024-11-29 13:23:48 +03:00
|
|
|
}
|