32 lines
767 B
PHP
32 lines
767 B
PHP
<?php
|
|
|
|
namespace app\modules\photo;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use kernel\app_modules\photo\models\Photo;
|
|
|
|
class PhotoModule extends \kernel\app_modules\photo\PhotoModule
|
|
{
|
|
|
|
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 "";
|
|
}
|
|
|
|
} |