Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
namespace Simbora\v1\Place\Repositories;
use Simbora\v1\Place\Models\Place;
class PlaceRepository
{
protected $place;
public function __construct(Place $place)
{
$this->place = $place;
}
public function all($sortBy, $state)
{
$data = $this->place->orderBy($sortBy);
if ($state) {
return $data->where('state', 'like', $state)->get();
}
return $data->get();
}
public function store($attributes)
{
return $this->place->create($attributes);
}
public function update(array $attributes, $id)
{
return $this->place->find($id)->update($attributes);
}
public function delete($id)
{
return $this->place->find($id)->delete();
}
public function __call($name, $params)
{
return call_user_func_array([$this->place, $name], $params);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment