brand start

This commit is contained in:
merdan 2022-01-25 11:54:15 +05:00
parent 7ae7a0a591
commit ec627b1264
17 changed files with 258 additions and 8 deletions

View File

@ -108,7 +108,8 @@
"Webkul\\Marketplace\\": "packages/Webkul/Marketplace/src",
"Sarga\\Shop\\": "packages/Sarga/Shop/src",
"Sarga\\API\\": "packages/Sarga/API",
"Sarga\\Admin\\": "packages/Sarga/Admin/src"
"Sarga\\Admin\\": "packages/Sarga/Admin/src",
"Sarga\\Brand\\": "packages/Sarga/Brand/src"
}
},
"autoload-dev": {

View File

@ -286,7 +286,8 @@ return [
Sarga\Shop\Providers\ShopServiceProvider::class,
Sarga\API\Providers\APIServiceProvider::class,
Sarga\Admin\Providers\AdminServiceProvider::class
Sarga\Admin\Providers\AdminServiceProvider::class,
Sarga\Brand\Providers\BrandServiceProvider::class,
],
/*

View File

@ -46,15 +46,15 @@ class Vendors extends Controller
}])
->orderBy('position','asc')
->get();
if($vendor->main_categories->count()){
foreach($vendor->main_categories as $category){
$category->filters = app(ProductFlatRepository::class)->getProductsRelatedFilterableAttributes($category);
}
}
// if($vendor->main_categories->count()){
// foreach($vendor->main_categories as $category){
// $category->filters = app(ProductFlatRepository::class)->getProductsRelatedFilterableAttributes($category);
// }
// }
}
}
return $vendors;
// return $vendors;
return Vendor::collection($vendors);
}

View File

@ -0,0 +1,27 @@
{
"name": "sarga/bagisto-brand",
"license": "MIT",
"authors": [
{
"name": "Merdan Singh",
"email": "merdan.m@gmail.com"
}
],
"require": {
"bagisto/laravel-core": "dev-master"
},
"autoload": {
"psr-4": {
"Sarga\\Admin\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Sarga\\Brand\\Providers\\BrandServiceProvider"
],
"aliases": {}
}
},
"minimum-stability": "dev"
}

View File

@ -0,0 +1,6 @@
<?php namespace Sarga\Brand\Contracts;
interface Brand
{
}

View File

@ -0,0 +1,36 @@
<?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('brands', function (Blueprint $table) {
$table->increments('id');
$table->string('code')->unique();
$table->string('name');
$table->integer('position')->default(0);
$table->string('image')->nullable();
$table->boolean('status')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('brands');
}
}

View File

@ -0,0 +1,34 @@
<?php namespace Sarga\Brand\Http\Controllers;
class BrandController extends Controller
{
public function index() {
}
public function create(){
}
public function edit(){
}
public function update(){
}
public function destroy(){
}
public function massDestroy(){
}
public function productCount(){
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Sarga\Brand\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Support\Facades\Route;
use Sarga\Brand\Http\Controllers\BrandController;
/**
* Catalog routes.
*/
Route::group(['middleware' => ['web', 'admin', 'admin_locale'], 'prefix' => config('app.admin_url')], function () {
Route::prefix('catalog')->group(function () {
/**
* Categories routes.
*/
Route::get('/brands', [BrandController::class, 'index'])->defaults('_config', [
'view' => 'admin::catalog.categories.index',
])->name('admin.catalog.categories.index');
Route::get('/brands/create', [BrandController::class, 'create'])->defaults('_config', [
'view' => 'admin::catalog.categories.create',
])->name('admin.catalog.categories.create');
Route::post('/brands/create', [BrandController::class, 'store'])->defaults('_config', [
'redirect' => 'admin.catalog.categories.index',
])->name('admin.catalog.categories.store');
Route::get('/brands/edit/{id}', [BrandController::class, 'edit'])->defaults('_config', [
'view' => 'admin::catalog.categories.edit',
])->name('admin.catalog.categories.edit');
Route::put('/brands/edit/{id}', [BrandController::class, 'update'])->defaults('_config', [
'redirect' => 'admin.catalog.categories.index',
])->name('admin.catalog.categories.update');
Route::post('/brands/delete/{id}', [BrandController::class, 'destroy'])->name('admin.catalog.categories.delete');
Route::post('brands/massdelete', [BrandController::class, 'massDestroy'])->defaults('_config', [
'redirect' => 'admin.catalog.categories.index',
])->name('admin.catalog.categories.massdelete');
Route::post('/brands/product/count', [BrandController::class, 'productCount'])->name('admin.catalog.categories.product.count');
});
});

View File

@ -0,0 +1 @@
<?php

View File

@ -0,0 +1,34 @@
<?php namespace Sarga\Brand\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
use Sarga\Brand\Contracts\Brand as BrandContract;
class Brand extends Model implements BrandContract
{
protected $fillable = [
'position',
'status',
'code',
'name'
];
/**
* Get image url for the category image.
*/
public function image_url()
{
if (! $this->image) {
return;
}
return Storage::url($this->image);
}
/**
* Get image url for the category image.
*/
public function getImageUrlAttribute()
{
return $this->image_url();
}
}

View File

@ -0,0 +1,17 @@
<?php namespace Sarga\Brand\Providers;
use Illuminate\Support\ServiceProvider;
class BrandServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot(): void
{
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
// CategoryProxy::observe(CategoryObserver::class);
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace Sarga\Brand\Providers;
use Webkul\Core\Providers\CoreModuleServiceProvider;
class ModuleServiceProvider extends CoreModuleServiceProvider
{
protected $models = [
\Sarga\Brand\Models\Brand::class,
];
}

View File

@ -0,0 +1,12 @@
<?php namespace Sarga\Brand\Repositories;
use Webkul\Core\Eloquent\Repository;
class BrandRepository extends Repository
{
public function model()
{
return 'Sarga\Brand\Contracts\Brand';
}
}

View File

@ -0,0 +1,12 @@
@extends('admin::layouts.content')
@section('page_title')
Add Brand
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.catalog.brands.store') }}" @submit.prevent="onSubmit" enctype="multipart/form-data">
</form>
</div>
@stop

View File

@ -0,0 +1 @@
<?php

View File

@ -0,0 +1 @@
<?php