Skip to content

Instantly share code, notes, and snippets.

@jsdecena
Created March 8, 2018 00:16
Show Gist options
  • Save jsdecena/1926e94b62123158804e51ccbc0297b7 to your computer and use it in GitHub Desktop.
Save jsdecena/1926e94b62123158804e51ccbc0297b7 to your computer and use it in GitHub Desktop.
Carousel Repository
<?php
namespace App\Shop\Carousels\Repositories;
use App\Shop\Carousels\Carousel;
use App\Shop\Carousels\Exceptions\CreateCarouselErrorException;
use Illuminate\Database\QueryException;
class CarouselRepository
{
/**
* CarouselRepository constructor.
* @param Carousel $carousel
*/
public function __construct(Carousel $carousel)
{
$this->model = $carousel;
}
/**
* @param array $data
* @return Carousel
* @throws CreateCarouselErrorException
*/
public function createCarousel(array $data) : Carousel
{
try {
return $this->model->create($data);
} catch (QueryException $e) {
throw new CreateCarouselErrorException($e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment