Skip to content

Instantly share code, notes, and snippets.

@erikfig
Created June 23, 2020 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikfig/e80851a5abd1c83d97f503ec0acda8a1 to your computer and use it in GitHub Desktop.
Save erikfig/e80851a5abd1c83d97f503ec0acda8a1 to your computer and use it in GitHub Desktop.
<?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