-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from binaryk/search-coverage
Search coverage
- Loading branch information
Showing
21 changed files
with
748 additions
and
312 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
namespace Binaryk\LaravelRestify\Contracts; | ||
|
||
use Illuminate\Http\Request; | ||
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest; | ||
|
||
/** | ||
* @author Eduard Lupacescu <[email protected]> | ||
|
@@ -16,11 +16,11 @@ interface RestifySearchable | |
const MATCH_INTEGER = 'integer'; | ||
|
||
/** | ||
* @param Request $request | ||
* @param RestifyRequest $request | ||
* @param array $fields | ||
* @return array | ||
*/ | ||
public function serializeForIndex(Request $request, array $fields = []); | ||
public function serializeForIndex(RestifyRequest $request, array $fields = []); | ||
|
||
/** | ||
* @return array | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Binaryk\LaravelRestify\Exceptions; | ||
|
||
use Exception; | ||
|
||
/** | ||
* @author Eduard Lupacescu <[email protected]> | ||
*/ | ||
class InstanceOfException extends Exception | ||
{ | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,50 +2,45 @@ | |
|
||
namespace Binaryk\LaravelRestify\Repositories; | ||
|
||
use Binaryk\LaravelRestify\Traits\AuthorizableModels; | ||
use Binaryk\LaravelRestify\Contracts\RestifySearchable; | ||
use Binaryk\LaravelRestify\Traits\InteractWithSearch; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\DelegatesToResource; | ||
use Illuminate\Support\Str; | ||
|
||
/** | ||
* @author Eduard Lupacescu <[email protected]> | ||
*/ | ||
abstract class Repository | ||
abstract class Repository implements RestifySearchable | ||
{ | ||
use AuthorizableModels; | ||
use InteractWithSearch, | ||
DelegatesToResource; | ||
|
||
/** | ||
* This is named `resource` because of the forwarding properties from DelegatesToResource trait. | ||
* @var Model | ||
*/ | ||
public $modelInstance; | ||
public $resource; | ||
|
||
/** | ||
* Create a new resource instance. | ||
* | ||
* @param \Illuminate\Database\Eloquent\Model $resource | ||
* @param \Illuminate\Database\Eloquent\Model $model | ||
*/ | ||
public function __construct($resource) | ||
public function __construct($model) | ||
{ | ||
$this->modelInstance = $resource; | ||
$this->resource = $model; | ||
} | ||
|
||
/** | ||
* Get the fields displayed by the resource. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return array | ||
*/ | ||
abstract public function fields(Request $request); | ||
|
||
/** | ||
* Get the underlying model instance for the resource. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Model | ||
*/ | ||
public function model() | ||
{ | ||
return $this->modelInstance; | ||
return $this->resource; | ||
} | ||
|
||
/** | ||
|
@@ -77,4 +72,14 @@ public static function query() | |
{ | ||
return static::newModel()->query(); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function toArray() | ||
{ | ||
$model = $this->model(); | ||
|
||
return $model->toArray(); | ||
} | ||
} |
Oops, something went wrong.