Skip to content

Commit

Permalink
Merge pull request #26 from suraj-webkul/refactor
Browse files Browse the repository at this point in the history
[refactor] refactor the datatransfer crud actions.
  • Loading branch information
devansh-webkul authored Oct 9, 2024
2 parents d947858 + 05dd138 commit ef441b9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 35 deletions.
15 changes: 7 additions & 8 deletions docs/1.x/advanced/override-core-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Use Concord's registerModel() method in your module's service provider (ServiceP
namespace Webkul\Category\Providers;

use Illuminate\Support\ServiceProvider;
use Webkul\Product\Contracts\Product as ProductContract;
use Webkul\Category\Models\Product;

class CategoryServiceProvider extends ServiceProvider
{
Expand All @@ -44,15 +46,13 @@ class CategoryServiceProvider extends ServiceProvider
{
// ...

$this->app->concord->registerModel(
\Webkul\Product\Contracts\Product::class, \App\Http\Product::class
);
$this->app->concord->registerModel(ProductContract::class, Product::class);
}
}
```

- Replace `\Webkul\Product\Contracts\Product::class` with the interface you wish to override.
- Replace `\App\Http\Product::class` with the path to your custom model class that extends the core model you are overriding.
- Replace `Webkul\Product\Contracts\Product as ProductContract` with the interface you wish to override.
- Replace `Webkul\Category\Models\Product` with the path to your custom model class that extends the core model you are overriding.

### Implement the Custom Model Class

Expand All @@ -61,7 +61,7 @@ Your custom model class (Product in this example) should extend the base core mo
```php
<?php

namespace App\Http;
namespace App\Category\Models;

use Webkul\Product\Models\Product as ProductBaseModel;

Expand All @@ -71,7 +71,6 @@ class Product extends ProductBaseModel
}
```

Once registered, you can use dependency injection or other Laravel mechanisms to reference the interface(`\Webkul\Product\Contracts\Product::class`) throughout your application. Laravel's service container will automatically resolve your custom model implementation (`\App\Http\Product::class`) where the interface is referenced.
Once registered, you can use dependency injection or other Laravel mechanisms to reference the interface(`Webkul\Product\Contracts\Product as ProductContract`) throughout your application. Laravel's service container will automatically resolve your custom model implementation (`Webkul\Category\Models\Product`) where the interface is referenced.

By following this approach, you can effectively extend and override core models within Krayin using Concord, maintaining modularity and flexibility in your application's architecture.

17 changes: 8 additions & 9 deletions docs/2.0/advanced/override-core-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Use Concord's registerModel() method in your module's service provider (ServiceP
namespace Webkul\Category\Providers;

use Illuminate\Support\ServiceProvider;
use Webkul\Product\Contracts\Product as ProductContract;
use Webkul\Category\Models\Product;

class CategoryServiceProvider extends ServiceProvider
{
Expand All @@ -43,16 +45,14 @@ class CategoryServiceProvider extends ServiceProvider
public function boot()
{
// ...

$this->app->concord->registerModel(
\Webkul\Product\Contracts\Product::class, \App\Http\Product::class
);

$this->app->concord->registerModel(ProductContract::class, Product::class);
}
}
```

- Replace `\Webkul\Product\Contracts\Product::class` with the interface you wish to override.
- Replace `\App\Http\Product::class` with the path to your custom model class that extends the core model you are overriding.
- Replace `Webkul\Product\Contracts\Product as ProductContract` with the interface you wish to override.
- Replace `Webkul\Category\Models\Product` with the path to your custom model class that extends the core model you are overriding.

### Implement the Custom Model Class

Expand All @@ -61,7 +61,7 @@ Your custom model class (Product in this example) should extend the base core mo
```php
<?php

namespace App\Http;
namespace App\Category\Models;

use Webkul\Product\Models\Product as ProductBaseModel;

Expand All @@ -71,7 +71,6 @@ class Product extends ProductBaseModel
}
```

Once registered, you can use dependency injection or other Laravel mechanisms to reference the interface(`\Webkul\Product\Contracts\Product::class`) throughout your application. Laravel's service container will automatically resolve your custom model implementation (`\App\Http\Product::class`) where the interface is referenced.
Once registered, you can use dependency injection or other Laravel mechanisms to reference the interface(`Webkul\Product\Contracts\Product as ProductContract`) throughout your application. Laravel's service container will automatically resolve your custom model implementation (`Webkul\Category\Models\Product`) where the interface is referenced.

By following this approach, you can effectively extend and override core models within Krayin using Concord, maintaining modularity and flexibility in your application's architecture.

13 changes: 3 additions & 10 deletions docs/master/advanced/data-transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,11 @@ Errors during the import process are logged, and a detailed report is generated,

The module supports three main actions during the import process:

1. **Create**: Add new records.
2. **Update**: Update existing records if they match based on the identifier.
3. **Delete**: Remove records based on the provided data.
1. **Create**: Add new records. If records do not exist, new records will be created.

- **Create**:
If records do not exist, new records will be created.
2. **Update**: Update existing records if they match based on the identifier. If records exist, they will be updated.

- **Update**:
If records exist, they will be updated.

- **Delete**:
If records exist, they will be deleted, Before importing. If the data does not exist, a validation error will be displayed.
3. **Delete**: Remove records based on the provided data. If records exist, they will be deleted, Before importing. If the data does not exist, a validation error will be displayed.

### Edit Import Data

Expand Down
15 changes: 7 additions & 8 deletions docs/master/advanced/override-core-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Use Concord's registerModel() method in your module's service provider (ServiceP
namespace Webkul\Category\Providers;

use Illuminate\Support\ServiceProvider;
use Webkul\Product\Contracts\Product as ProductContract;
use Webkul\Category\Models\Product;

class CategoryServiceProvider extends ServiceProvider
{
Expand All @@ -44,15 +46,13 @@ class CategoryServiceProvider extends ServiceProvider
{
// ...

$this->app->concord->registerModel(
\Webkul\Product\Contracts\Product::class, \App\Http\Product::class
);
$this->app->concord->registerModel(ProductContract::class, Product::class);
}
}
```

- Replace `\Webkul\Product\Contracts\Product::class` with the interface you wish to override.
- Replace `\App\Http\Product::class` with the path to your custom model class that extends the core model you are overriding.
- Replace `Webkul\Product\Contracts\Product as ProductContract` with the interface you wish to override.
- Replace `Webkul\Category\Models\Product` with the path to your custom model class that extends the core model you are overriding.

### Implement the Custom Model Class

Expand All @@ -61,7 +61,7 @@ Your custom model class (Product in this example) should extend the base core mo
```php
<?php

namespace App\Http;
namespace App\Category\Models;

use Webkul\Product\Models\Product as ProductBaseModel;

Expand All @@ -71,7 +71,6 @@ class Product extends ProductBaseModel
}
```

Once registered, you can use dependency injection or other Laravel mechanisms to reference the interface(`\Webkul\Product\Contracts\Product::class`) throughout your application. Laravel's service container will automatically resolve your custom model implementation (`\App\Http\Product::class`) where the interface is referenced.
Once registered, you can use dependency injection or other Laravel mechanisms to reference the interface(`Webkul\Product\Contracts\Product as ProductContract`) throughout your application. Laravel's service container will automatically resolve your custom model implementation (`Webkul\Category\Models\Product`) where the interface is referenced.

By following this approach, you can effectively extend and override core models within Krayin using Concord, maintaining modularity and flexibility in your application's architecture.

0 comments on commit ef441b9

Please sign in to comment.