menus & translations ready
This commit is contained in:
parent
6d4bee4e14
commit
3c9bbbb392
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateBrandsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('menus', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('position')->default(0);
|
||||
$table->boolean('status')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('menu_brands',function (Blueprint $table) {
|
||||
$table->integer('menu_id')->unsigned();
|
||||
$table->integer('brand_id')->unsigned();
|
||||
$table->foreign('menu_id')->references('id')->on('menus');
|
||||
$table->foreign('brand_id')->references('id')->on('brands');
|
||||
});
|
||||
|
||||
Schema::create('menu_categories',function (Blueprint $table) {
|
||||
$table->integer('menu_id')->unsigned();
|
||||
$table->integer('category_id')->unsigned();
|
||||
$table->foreign('menu_id')->references('id')->on('menus');
|
||||
$table->foreign('category_id')->references('id')->on('categories');
|
||||
});
|
||||
|
||||
Schema::create('menu_translations',function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->text('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->integer('menu_id')->unsigned();
|
||||
$table->string('locale');
|
||||
$table->unique(['menu_id', 'locale']);
|
||||
$table->foreign('menu_id')->references('id')->on('menus')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('menu_brands');
|
||||
Schema::dropIfExists('menu_categories');
|
||||
Schema::dropIfExists('menus_translations');
|
||||
Schema::dropIfExists('menus');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Shop\Contracts;
|
||||
|
||||
interface Menu
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Shop\Contracts;
|
||||
|
||||
interface MenuTranslation
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Shop\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Sarga\Brand\Models\BrandProxy;
|
||||
use Webkul\Category\Models\CategoryProxy;
|
||||
use Webkul\Core\Eloquent\TranslatableModel;
|
||||
use Sarga\Shop\Contracts\Menu as MenuContract;
|
||||
|
||||
class Menu extends TranslatableModel implements MenuContract
|
||||
{
|
||||
protected $fillable = [
|
||||
'position',
|
||||
'status',
|
||||
'filter',
|
||||
];
|
||||
|
||||
/**
|
||||
* Eager loading.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $with = ['translations'];
|
||||
|
||||
public function brands() :BelongsToMany{
|
||||
return $this->belongsToMany(BrandProxy::modelClass(),'menu_brands');
|
||||
}
|
||||
|
||||
public function categories():BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(CategoryProxy::modelClass(), 'menu_categories');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Shop\Models;
|
||||
|
||||
class MenuProxy extends \Konekt\Concord\Proxies\ModelProxy
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Shop\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Sarga\Shop\Contracts\MenuTranslation as MenuTranslationContract;
|
||||
class MenuTranslation extends Model implements MenuTranslationContract
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'locale_id',
|
||||
];
|
||||
}
|
||||
|
|
@ -8,5 +8,8 @@ class ModuleServiceProvider extends CoreModuleServiceProvider
|
|||
{
|
||||
protected $models = [
|
||||
\Sarga\Shop\Models\Recipient::class,
|
||||
\Sarga\Shop\Models\Menu::class,
|
||||
\Sarga\Shop\Models\MenuTranslation::class,
|
||||
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Shop\Repositories;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
class MenuRepository extends Repository
|
||||
{
|
||||
public function model(): string
|
||||
{
|
||||
return 'Sarga\Shop\Contracts\Menu';
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue