phpvms/app/Services/NewsService.php
Nabeel S 12848091a2
Laravel 9 Update (#1413)
Update to Laravel 9 and PHP 8+

Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
2022-03-14 11:45:18 -04:00

45 lines
848 B
PHP

<?php
namespace App\Services;
use App\Contracts\Service;
use App\Events\NewsAdded;
use App\Repositories\NewsRepository;
class NewsService extends Service
{
private NewsRepository $newsRepo;
public function __construct(NewsRepository $newsRepo)
{
$this->newsRepo = $newsRepo;
}
/**
* Add a news item
*
* @param array $attrs
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return mixed
*/
public function addNews(array $attrs)
{
$news = $this->newsRepo->create($attrs);
event(new NewsAdded($news));
return $news;
}
/**
* Delete something from the news items
*
* @param int $id ID of the news row to delete
*/
public function deleteNews($id)
{
$this->newsRepo->delete($id);
}
}