Skip to content

Commit

Permalink
Resove conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryk committed Dec 22, 2019
2 parents cc6d31e + f6043db commit 3331837
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 31 deletions.
3 changes: 1 addition & 2 deletions src/Contracts/RestifySearchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Http\Request;

/**
* @package Binaryk\LaravelRestify\Contracts;
* @author Eduard Lupacescu <[email protected]>
*/
interface RestifySearchable
Expand Down Expand Up @@ -42,7 +41,7 @@ public static function getInFields();
* Find matches in the table by given value
* Returns an array like:
* [ 'table_column_name' => 'type' ], type can be: text, bool, boolean, int, integer, number
* e.g. [ 'id' => 'int' ]
* e.g. [ 'id' => 'int' ].
*
* To use this filter we have to send in query:
* [ 'match' => [ 'id' => 1 ] ]
Expand Down
5 changes: 0 additions & 5 deletions src/Controllers/RestIndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

namespace Binaryk\LaravelRestify\Controllers;

use Binaryk\LaravelRestify\Tests\Fixtures\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

/**
* @package Binaryk\LaravelRestify\Controllers;
* @author Eduard Lupacescu <[email protected]>
*/
trait RestIndexController
Expand Down
4 changes: 1 addition & 3 deletions src/Http/Middleware/BeforeEach.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
namespace Binaryk\LaravelRestify\Http\Middleware;

use Binaryk\LaravelRestify\Events\RestifyBeforeEach;
use Binaryk\LaravelRestify\Events\RestifyServiceProviderRegistered;
use Binaryk\LaravelRestify\Restify;
use Binaryk\LaravelRestify\RestifyServiceProvider;
use Closure;

/**
Expand All @@ -23,6 +20,7 @@ class BeforeEach
public function handle($request, Closure $next)
{
RestifyBeforeEach::dispatch($request);

return $next($request);
}
}
2 changes: 1 addition & 1 deletion src/Http/Middleware/RestifyInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function handle($request, Closure $next)
$path = trim(Restify::path(), '/') ?: '/';

$isRestify = $request->is($path) ||
$request->is(trim($path . '/*', '/')) ||
$request->is(trim($path.'/*', '/')) ||
$request->is('restify-api/*');

if ($isRestify) {
Expand Down
8 changes: 4 additions & 4 deletions src/LaravelRestifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public function register()
protected function registerPublishing()
{
$this->publishes([
__DIR__ . '/Commands/stubs/RestifyServiceProvider.stub' => app_path('Providers/RestifyServiceProvider.php'),
__DIR__.'/Commands/stubs/RestifyServiceProvider.stub' => app_path('Providers/RestifyServiceProvider.php'),
], 'restify-provider');

$this->publishes([
__DIR__ . '/../config/config.php' => config_path('restify.php'),
__DIR__.'/../config/config.php' => config_path('restify.php'),
], 'restify-config');

if ( ! $this->app->configurationIsCached()) {
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'laravel-restify');
if (! $this->app->configurationIsCached()) {
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-restify');
}
}
}
20 changes: 10 additions & 10 deletions src/Traits/AuthorizableModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function authorizable()
*/
public function authorizeToViewAny(Request $request)
{
if ( ! static::authorizable()) {
if (! static::authorizable()) {
return;
}

Expand All @@ -58,7 +58,7 @@ public function authorizeToViewAny(Request $request)
*/
public static function authorizedToViewAny(Request $request)
{
if ( ! static::authorizable()) {
if (! static::authorizable()) {
return true;
}

Expand Down Expand Up @@ -198,11 +198,11 @@ public function authorizedToForceDelete(Request $request)
*/
public function authorizedToAdd(Request $request, $model)
{
if ( ! static::authorizable()) {
if (! static::authorizable()) {
return true;
}

$method = 'add' . class_basename($model);
$method = 'add'.class_basename($model);

return method_exists(Gate::getPolicyFor($this->model()), $method)
? Gate::check($method, $this->model())
Expand All @@ -218,11 +218,11 @@ public function authorizedToAdd(Request $request, $model)
*/
public function authorizedToAttachAny(Request $request, $model)
{
if ( ! static::authorizable()) {
if (! static::authorizable()) {
return true;
}

$method = 'attachAny' . Str::singular(class_basename($model));
$method = 'attachAny'.Str::singular(class_basename($model));

return method_exists(Gate::getPolicyFor($this->model()), $method)
? Gate::check($method, [$this->model()])
Expand All @@ -238,11 +238,11 @@ public function authorizedToAttachAny(Request $request, $model)
*/
public function authorizedToAttach(Request $request, $model)
{
if ( ! static::authorizable()) {
if (! static::authorizable()) {
return true;
}

$method = 'attach' . Str::singular(class_basename($model));
$method = 'attach'.Str::singular(class_basename($model));

return method_exists(Gate::getPolicyFor($this->model()), $method)
? Gate::check($method, [$this->model(), $model])
Expand All @@ -259,11 +259,11 @@ public function authorizedToAttach(Request $request, $model)
*/
public function authorizedToDetach(Request $request, $model, $relationship)
{
if ( ! static::authorizable()) {
if (! static::authorizable()) {
return true;
}

$method = 'detach' . Str::singular(class_basename($model));
$method = 'detach'.Str::singular(class_basename($model));

return method_exists(Gate::getPolicyFor($this->model()), $method)
? Gate::check($method, [$this->model(), $model])
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/InteractWithSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use Illuminate\Http\Request;

/**
* @package Binaryk\LaravelRestify\Traits;
* @author Eduard Lupacescu <[email protected]>
*/
trait InteractWithSearch
{
use AuthorizableModels;

static $defaultPerPage = 15;
public static $defaultPerPage = 15;

/**
* @return array
Expand Down Expand Up @@ -45,6 +44,7 @@ public static function getMatchByFields()
{
return static::$match ?? [];
}

/**
* @return array
*/
Expand Down
1 change: 0 additions & 1 deletion tests/Fixtures/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class User extends Authenticatable implements Passportable, MustVerifyEmail, Res
use Notifiable,
InteractWithSearch;


public static $search = ['id'];
public static $match = [
'id' => 'int',
Expand Down
4 changes: 1 addition & 3 deletions tests/InteractWithModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Binaryk\LaravelRestify\Tests\Fixtures\User;

/**
* @package Binaryk\LaravelRestify\Tests;
* @author Eduard Lupacescu <[email protected]>
*/
trait InteractWithModels
Expand All @@ -14,12 +13,11 @@ public function mockUsers($count = 1)
{
$users = collect([]);
$i = 0;
while($i < $count) {
while ($i < $count) {
$users->push(factory(User::class)->create());
$i++;
}

return $users;
}

}

0 comments on commit 3331837

Please sign in to comment.