44 lines
888 B
PHP
44 lines
888 B
PHP
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\Service;
|
|
use App\Services\Base\BaseService;
|
|
|
|
|
|
class ServiceService extends BaseService {
|
|
|
|
public function __construct() {
|
|
parent::__construct(Service::class);
|
|
}
|
|
|
|
|
|
public function create($data)
|
|
{
|
|
$image = ImageService::upload_image($data['image'], "service");
|
|
|
|
parent::create([
|
|
'title' => $data['title'],
|
|
'description' => $data['description'],
|
|
'image' => $image
|
|
]);
|
|
|
|
return true;
|
|
}
|
|
|
|
public function update($id ,$data)
|
|
{
|
|
if (isset($data['image']) && !empty($data['image'])) {
|
|
$Oldimage = Service::find($id)->image ;
|
|
$updated_image = ImageService::update_image($data['image'],$Oldimage, 'service');
|
|
$data['image'] = $updated_image;
|
|
}
|
|
|
|
parent::update($id,$data);
|
|
}
|
|
|
|
|
|
}
|