You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+59-1
Original file line number
Diff line number
Diff line change
@@ -26,10 +26,68 @@ use GertjanRoke\LaravelDbModel\DBModel;
26
26
27
27
class Post extends DBModel
28
28
{
29
-
public $table = 'posts';
29
+
// public $table = 'posts';
30
30
31
31
// public $connection = 'mysql';
32
32
}
33
+
```
34
+
If no table name was given it will guess it based on the class name just like the Eloquent model those.
35
+
Same for the connection, if none is set it will use the default connection.
36
+
37
+
## How to extend custom scopes
38
+
It's basically the same as for Eloquent models, you would need to prefix the methods with `scope`
39
+
```php
40
+
...
41
+
42
+
class Post extends DBModel
43
+
{
44
+
public function scopeActive()
45
+
{
46
+
$this->db->where('active', true);
47
+
48
+
return $this;
49
+
}
50
+
}
51
+
```
52
+
53
+
## Some examples
54
+
55
+
You can easly create short functions for basic where's or even more complex queries so you have it always in one location instead of everywhere in your code base.
0 commit comments