Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Mar 29, 2021
1 parent feb5b76 commit f18af8f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
24 changes: 12 additions & 12 deletions src/Bazar.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Bazar\Exceptions\InvalidCurrencyException;
use Bazar\Http\Middleware\HandleInertiaRequests;
use Closure;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Route;

Expand All @@ -21,9 +20,9 @@ abstract class Bazar
/**
* The default currency.
*
* @var string|null
* @var string
*/
protected static $currency = null;
protected static $currency;

/**
* Get the version.
Expand Down Expand Up @@ -74,14 +73,15 @@ public static function currency(string $currency = null): string
*/
public static function routes(Closure $callback): void
{
Route::as('bazar.')->prefix('bazar')->middleware([
'web',
'auth',
'verified',
'can:manage-bazar',
HandleInertiaRequests::class,
])->group(static function (Router $router) use ($callback): void {
$callback($router);
});
Route::as('bazar.')
->prefix('bazar')
->middleware([
'web',
'auth',
'verified',
'can:manage-bazar',
HandleInertiaRequests::class,
])
->group($callback);
}
}
15 changes: 6 additions & 9 deletions src/BazarServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Auth\Events\Logout;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Routing\Route;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Gate;
Expand Down Expand Up @@ -106,15 +105,13 @@ protected function registerRoutes(): void
public function registerRouteBindings(): void
{
foreach ($this->bindings as $contract => $abstract) {
if (is_subclass_of($abstract, Model::class)) {
$key = strtolower(class_basename($contract));
$key = strtolower(class_basename($contract));

$this->app['router']->bind($key, static function (string $value, Route $route) use ($key, $abstract) {
return Str::is('bazar.*', $route->getName())
? $abstract::proxy()->resolveRouteBinding($value, $route->bindingFieldFor($key))
: $value;
});
}
$this->app['router']->bind($key, static function (string $value, Route $route) use ($key, $abstract) {
return Str::is('bazar.*', $route->getName())
? $abstract::proxy()->resolveRouteBinding($value, $route->bindingFieldFor($key))
: $value;
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Models/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

interface Shipping extends Taxable
{
/**
/**
* Get the shippable model for the shipping.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
Expand Down

0 comments on commit f18af8f

Please sign in to comment.