Skip to content

Commit 431e38d

Browse files
committed
Create EloquentRepository Contracts
1 parent abe0f4a commit 431e38d

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
namespace PPSpaces\Contracts;
4+
5+
interface EloquentRepository
6+
{
7+
8+
/**
9+
* Get all of the models from the database.
10+
*
11+
* @param array|mixed $columns
12+
* @return \Illuminate\Database\Eloquent\Collection|static[]
13+
*/
14+
public function all($columns = ['*']);
15+
16+
/**
17+
* Dynamically retrieve attributes on the model.
18+
*
19+
* @param array $columns
20+
* @return \Illuminate\Database\Eloquent\Model
21+
*/
22+
23+
public function get($columns);
24+
25+
/**
26+
* Get a new query of one model by their IDs.
27+
*
28+
* @param array|int $ids
29+
* @return \Illuminate\Database\Eloquent\Model
30+
*/
31+
public function find($id);
32+
33+
/**
34+
* Perform a model create operation.
35+
*
36+
* @param \Illuminate\Database\Eloquent\Model $query
37+
* @return bool
38+
*/
39+
public function create(array $attributes);
40+
41+
/**
42+
* Update the model in the database.
43+
*
44+
* @param array $attributes
45+
* @param array $options
46+
* @return bool
47+
*/
48+
public function update(array $attributes = []);
49+
50+
/**
51+
* Delete the model from the database.
52+
*
53+
* @return bool|null
54+
*
55+
* @throws \Exception
56+
*/
57+
public function delete($id);
58+
59+
/**
60+
* Get the value of the model's route key.
61+
*
62+
* @return mixed
63+
*/
64+
public function getRouteKey();
65+
66+
/**
67+
* Get the route key for the model.
68+
*
69+
* @return string
70+
*/
71+
public function getRouteKeyName();
72+
73+
/**
74+
* Retrieve the model for a bound value.
75+
*
76+
* @param mixed $value
77+
* @return \Illuminate\Database\Eloquent\Model|null
78+
*/
79+
public function resolveRouteBinding($value);
80+
81+
/**
82+
* Convert the object into something JSON serializable.
83+
*
84+
* @return array
85+
*/
86+
public function jsonSerialize();
87+
88+
/**
89+
* Convert the model to its string representation.
90+
*
91+
* @return string
92+
*/
93+
public function __toString();
94+
}

0 commit comments

Comments
 (0)