Skip to content

Commit

Permalink
Merge pull request #6 from meteorid-labs/feat/logistic
Browse files Browse the repository at this point in the history
Feat - Add ignore migration
  • Loading branch information
Aslam97 authored Dec 16, 2022
2 parents 534d4ce + 2324e2c commit c5421bc
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 11 deletions.
29 changes: 24 additions & 5 deletions src/Shipper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

class Shipper
{
/**
* Indicates if Passport migrations will be run.
*
* @var bool
*/
public static $runsMigrations = true;

/**
* Create a new Meteor Shipper client instance.
*
Expand All @@ -21,6 +28,18 @@ public function __construct(
$this->apiUrl = $apiUrl ?? 'https://merchant-api.shipper.id';
}

/**
* Configure Shipper to not register its migrations.
*
* @return static
*/
public static function ignoreMigrations()
{
static::$runsMigrations = false;

return new static;
}

/**
* Create a new instance of the class.
*
Expand All @@ -37,7 +56,7 @@ public static function make(...$args)
*
* @return string
*/
final public function getApiUrl()
public function getApiUrl()
{
return $this->apiUrl;
}
Expand All @@ -47,7 +66,7 @@ final public function getApiUrl()
*
* @return string
*/
final public function getApiKey()
public function getApiKey()
{
return $this->apiKey;
}
Expand All @@ -58,7 +77,7 @@ final public function getApiKey()
* @param string $apiKey
* @return $this
*/
final public function setApiKey($apiKey)
public function setApiKey($apiKey)
{
$this->apiKey = $apiKey;

Expand All @@ -70,7 +89,7 @@ final public function setApiKey($apiKey)
*
* @return $this
*/
final public function useSandbox()
public function useSandbox()
{
$this->apiUrl = 'https://merchant-api-sandbox.shipper.id';

Expand All @@ -82,7 +101,7 @@ final public function useSandbox()
*
* @return $this
*/
final public function useProduction()
public function useProduction()
{
$this->apiUrl = 'https://merchant-api.shipper.id';

Expand Down
46 changes: 40 additions & 6 deletions src/ShipperServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Meteor\Shipper;

class ShipperServiceProvider extends \Illuminate\Support\ServiceProvider
use Illuminate\Support\ServiceProvider;

class ShipperServiceProvider extends ServiceProvider
{
/**
* Register the application services.
Expand All @@ -25,17 +27,49 @@ public function register()
*/
public function boot()
{
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->registerMigrations();
$this->registerPublishing();
$this->registerCommands();
}

/**
* Register the Passport migration files.
*
* @return void
*/
protected function registerMigrations()
{
if ($this->app->runningInConsole() && Shipper::$runsMigrations) {
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
}
}

/**
* Register the package's publishable resources.
*
* @return void
*/
protected function registerPublishing()
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../config/shipper.php' => config_path('meteor/shipper.php'),
], 'meteor.shipper.config');
__DIR__.'/../database/migrations' => database_path('migrations'),
], 'meteor.shipper.migrations');

$this->publishes([
__DIR__.'/../database/migrations/' => database_path('migrations'),
], 'meteor.shipper.migrations');
__DIR__.'/../config/shipper.php' => config_path('meteor/shipper.php'),
], 'meteor.shipper.config');
}
}

/**
* Register the Shipper Artisan commands.
*
* @return void
*/
protected function registerCommands()
{
if ($this->app->runningInConsole()) {
$this->commands([
Console\ImportLogistic::class,
]);
Expand Down

0 comments on commit c5421bc

Please sign in to comment.