Created
June 23, 2020 18:56
-
-
Save erikfig/e80851a5abd1c83d97f503ec0acda8a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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