category creation fix
This commit is contained in:
parent
cd6d6c89a8
commit
af5f039cb9
|
|
@ -764,6 +764,7 @@ return [
|
|||
'attribute-product-error' => ':name is used in products.',
|
||||
'customer-associate' => ':name can not be deleted because customer is associated with this group.',
|
||||
'currency-delete-error' => 'This currency is set as channel base currency so it can not be deleted.',
|
||||
'delete-category-root' => 'Cannot delete the root category'
|
||||
'delete-category-root' => 'Cannot delete the root category',
|
||||
'create-root-failure' => 'Category with name root already exists'
|
||||
],
|
||||
];
|
||||
|
|
@ -5,6 +5,7 @@ namespace Webkul\Category\Http\Controllers;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Category\Repositories\CategoryRepository as Category;
|
||||
use Webkul\Category\Models\CategoryTranslation;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
/**
|
||||
|
|
@ -74,9 +75,21 @@ class CategoryController extends Controller
|
|||
$this->validate(request(), [
|
||||
'slug' => ['required', 'unique:category_translations,slug', new \Webkul\Core\Contracts\Validations\Slug],
|
||||
'name' => 'required',
|
||||
'image.*' => 'mimes:jpeg,jpg,bmp,png'
|
||||
'image.*' => 'mimes:jpeg, jpg, bmp, png'
|
||||
]);
|
||||
|
||||
if (strtolower(request()->input('name')) == 'root') {
|
||||
$categoryTransalation = new CategoryTranslation();
|
||||
|
||||
$result = $categoryTransalation->where('name', request()->input('name'))->get();
|
||||
|
||||
if(count($result) > 0) {
|
||||
session()->flash('error', trans('admin::app.response.create-root-failure'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
$category = $this->category->create(request()->all());
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Category']));
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCurrencyCodeSymbolTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('currency_code_symbol', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('symbol')->nullable();
|
||||
$table->string('name')->nullable();
|
||||
$table->string('symbol_native')->nullable();
|
||||
$table->string('decimal_digits')->nullable();
|
||||
$table->string('rounding')->nullable();
|
||||
$table->string('code')->nullable();
|
||||
$table->string('name_plural')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('currency_code_symbol');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Core\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use DB;
|
||||
|
||||
class CurrenySymbolTableSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
DB::table('currency_code_symbol')->delete();
|
||||
|
||||
$currencies = json_decode(file_get_contents(__DIR__ . '/../../Data/currency_symbols.json'), true);
|
||||
|
||||
DB::table('currency_code_symbol')->insert($currencies);
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ class DatabaseSeeder extends Seeder
|
|||
{
|
||||
$this->call(LocalesTableSeeder::class);
|
||||
$this->call(CurrencyTableSeeder::class);
|
||||
$this->call(CurrenySymbolTableSeeder::class);
|
||||
$this->call(CountriesTableSeeder::class);
|
||||
$this->call(StatesTableSeeder::class);
|
||||
$this->call(ChannelTableSeeder::class);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Core\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Core\Models\CurrencyExchangeRate;
|
||||
|
||||
class CurrencyCodeSymbol extends Model
|
||||
{
|
||||
protected $table = 'currency_code_symbol';
|
||||
}
|
||||
Loading…
Reference in New Issue