Commit adadb368 by Angel MAS

Initial Commit

parents
# Package shop OneStartup
**onestartup/shop** is a module store for websites
# Installation
- Run this in the terminal
```php
composer require onestartup/shop
```
- after add the ServiceProvider to the providers array in config/app.php
```php
Onestartup\Shop\ShopServiceProvider::class,
```
- Run migration
```php
php artisan migrate
```
- add next lines to app/User.php
```php
public function productsShop()
{
return $this->hasMany('Onestartup\Shop\Model\ProductShop', 'user_id');
}
```
- run command for publish views
```php
php artisan vendor:publish --provider="Onestartup\Shop\ShopServiceProvider"
```
- run serv
```php
php artisan serve
```
- test in this route how admin user
```php
http://localhost:8000/admin/shop/product
```
- test in this route
```php
http://localhost:8000/productos
```
\ No newline at end of file
{
"name": "onestartup/shop",
"description": "store for websites onestartup",
"type": "library",
"license": "Apache-2.0",
"authors": [
{
"name": "Angel MAS",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"psr-4": {"Onestartup\\Shop\\": "src"}
}
}
<?php
namespace Onestartup\Shop;
use Illuminate\Support\ServiceProvider;
class ShopServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
include __DIR__.'/routes.php';
$this->loadMigrationsFrom(__DIR__.'/migrations');
if (is_dir(base_path() . '/resources/views/vendor/onestartup/shop')) {
$this->loadViewsFrom(base_path() . '/resources/views/vendor/onestartup/shop', 'shop-public');
$this->loadViewsFrom(__DIR__.'/views', 'shop');
} else {
$this->loadViewsFrom(__DIR__.'/views', 'shop');
$this->loadViewsFrom(__DIR__.'/views/public', 'shop-public');
}
$this->publishes([
__DIR__.'/views/public' => resource_path('views/vendor/onestartup/shop'),
]);
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->make('Onestartup\Shop\Controller\AdminProductController');
$this->app->make('Onestartup\Shop\Controller\CategoryController');
$this->app->make('Onestartup\Shop\Controller\ProductController');
}
}
<?php
namespace Onestartup\Shop\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Yajra\Datatables\Datatables;
use Onestartup\Shop\Model\ProductCategoryShop as Category;
use Onestartup\Shop\Model\ProductImageShop as Gallery;
use Onestartup\Shop\Model\ProductShop as Product;
//use Onestartup\Shop\Model\VariableShop;
class AdminProductController extends Controller
{
public function index()
{
return view('shop::product.index');
}
/**
* Show the form for creating a new resource.
* @return Response
*/
public function create()
{
$categories = Category::pluck('name', 'id');
//$variable = Variable::first();
return view('shop::product.create')
->with('categories', $categories);
//->with('variable', $variable);
}
/**
* Store a newly created resource in storage.
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$product = new Product($request->all());
if (isset($request->cover)) {
$file = $request->file('cover');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='shop/products/cover/'.$nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$product->cover = $ubicacion_donde_guarda;
}
\Auth::user()->products()->save($product);
return redirect()
->route('admin.shop.product.edit', $product->id)
->with('message_success', "Producto guardado correctamente, continua agregando las imagenes correspondientes");
}
/**
* Show the form for editing the specified resource.
* @return Response
*/
public function edit($id)
{
$product = Product::find($id);
$categories = Category::pluck('name', 'id');
return view('shop::product.edit')
->with('categories', $categories)
->with('product', $product);
}
/**
* Update the specified resource in storage.
* @param Request $request
* @return Response
*/
public function update(Request $request, $id)
{
$product = Product::find($id);
$product->fill($request->all());
if (isset($request->cover)) {
$file = $request->file('cover');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='shop/products/cover/'.$nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$product->cover = $ubicacion_donde_guarda;
}
$product->save();
return redirect()
->back()
->with('message_info', 'Información actualizada correctamente');
}
/**
* Remove the specified resource from storage.
* @return Response
*/
public function destroy($id)
{
$product = Product::find($id);
$product->delete();
return redirect()
->back()
->with('message_danger', 'Producto eliminada correctamente');
}
public function getProducts()
{
$products = Product::select([
'id',
'name',
'slug',
'category_id',
'created_at',
'description',
'features',
'specifications'
]);
return Datatables::of($products)
->addColumn('main', function ($product) {
return
"<p class='mb0'>Nombre: <b>$product->name</b></p>".
"<p class='mb0'>Slug: <b>$product->slug</b></p>".
"<p class='mb0'>Categoria: <b>".$product->category->name."</b></p>".
"<p class='mb0'>Fecha creación: <b>".$product->created_at->format('d/m/Y')."</b></p>";
})
->addColumn('form', function ($product) {
return "<form method='POST' action='".route('admin.product.destroy',$product->id)."'>".
"<input name='_method' type='hidden' value='DELETE' class='has-value'>".
csrf_field() .
"<button class='btn btn-danger btn-xs button-mb' onclick='return confirm();' type='submit'>".
"<i class='fas fa-trash-alt icon-special-size'></i>Eliminar</button>".
"</form>".
"<a href='".route('show.product', $product->slug)."' class='btn btn-xs info button-mb' target='new'>".
"<i class='fas fa-eye icon-special-size'></i>Ver</a>".
"<br><a href='".route('admin.product.edit', $product->id)."' class='btn btn-xs accent mb0'>".
"<i class='fas fa-edit icon-special-size'></i>Editar</a>";
})
->rawColumns(['main', 'description', 'features', 'specifications', 'form'])
->make();
}
public function storeGallery(Request $request, $product_id)
{
$product = Product::find($product_id);
$asset = '/storage/shop/product/'.$product->id.'/gallery/';
$path = public_path().$asset;
$files = $request->file('file');
foreach($files as $file){
$fileName = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $fileName);
$file->move($path, $nombre_file);
$gallery = new Gallery([
'path'=>$asset.$nombre_file
]);
$product->images()->save($gallery);
}
return $product;
}
public function deleteImage($id)
{
$gallery = Gallery::find($id);
unlink(public_path().$gallery->path);
$gallery->delete();
return redirect()
->back()
->with('message_danger', 'Imagen eliminada correctamente');
}
public function deleteCover($id)
{
$product = Product::find($id);
unlink(public_path().'/storage/'.$product->cover);
$product->cover = null;
$product->save();
//$gallery->delete();
return redirect()
->back()
->with('message_danger', 'Imagen eliminada correctamente');
}
public function showVars()
{
$variable = Variable::first();
if ($variable == null) {
$variable = new Variable();
}
return view('shop::variable.edit')
->with('variable', $variable);
}
public function postVars(Request $request)
{
$variable = Variable::first();
if ($variable == null) {
$variable = new Variable();
}
$variable->fill($request->all());
$variable->save();
return redirect()
->back()
->with('message_success', 'Información actualizada');
}
}
<?php
namespace Onestartup\Shop\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Yajra\Datatables\Datatables;
use Onestartup\Shop\Model\ProductCategoryShop as Category;
class CategoryController extends Controller
{
/**
* Display a listing of the resource.
* @return Response
*/
public function index()
{
$categories = Category::paginate(25);
return view('shop::category.index')
->with('categories', $categories);
}
/**
* Store a newly created resource in storage.
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$category = new Category($request->all());
if (isset($request->portada)) {
$file = $request->file('portada');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='shop/product/categories/'.$nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$category->cover = $ubicacion_donde_guarda;
}
$category->save();
return redirect()
->back()
->with('message_success', 'Categoria añadida correctamente');
}
/**
* Show the form for editing the specified resource.
* @return Response
*/
public function edit($id)
{
$category = Category::find($id);
return view('shop::category.edit')
->with('category', $category);
}
/**
* Update the specified resource in storage.
* @param Request $request
* @return Response
*/
public function update(Request $request, $id)
{
$category = Category::find($id);
$category->fill($request->all());
if (isset($request->portada) && $request->portada != null ) {
$file = $request->file('portada');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='shop/product/categories/'.$nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$category->cover = $ubicacion_donde_guarda;
}
$category->save();
return redirect()
->back()
->with('message_success', 'Categoria actualizado correctamente');
}
/**
* Remove the specified resource from storage.
* @return Response
*/
public function destroy($id)
{
$category = Category::find($id);
$category->delete();
return redirect()
->back()
->with('message_danger', 'Categoria eliminada correctamente');
}
public function deleteCover($id)
{
$category = Category::find($id);
$category->cover = null;
$category->save();
return redirect()
->back()
->with('message_success', 'Imagen eliminada correctamente');
}
}
<?php
namespace Onestartup\Shop\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Yajra\Datatables\Datatables;
use Onestartup\Product\Model\Product;
use Onestartup\Product\Model\ProductCategory as Category;
class ProductController extends Controller
{
public function index(Request $request)
{
if(isset($request->category)){
$category = Category::where('slug', $request->category)->first();
$products = $category->products()->where('active', true)->paginate(15);
} else {
$products = Product::where('active', true)->paginate(3);
}
$otros = Product::where('active', true)->inRandomOrder()->take(3)->get();
$categories = Category::where('active', true)->get();
return view('product-public::list')
->with('categories', $categories)
->with('otros', $otros)
->with('products', $products);
}
public function show($slug)
{
$product = Product::where('slug',$slug)->first();
$otros = $product->category->products()->where('active', true)->take(3)->get();
$categories = Category::all();
if ($product != null) {
if (!$product->active) {
return redirect('inactivo');
}
} else {
return redirect('no_existe');
}
return view('product-public::single')
->with('product', $product)
->with('categories', $categories)
->with('otros', $otros);
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProductCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('product_categories_shop', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 355);
$table->string('description', 455)->nullable();
$table->string('cover', 455)->nullable();
$table->boolean('active')->default(true);
$table->string('slug')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('product_categories_shop');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products_shop', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 355);
$table->string('slug', 455);
$table->string('cover', 455)->nullable();
$table->text('description')->nullable();
$table->text('specifications')->nullable();
$table->text('features')->nullable();
$table->boolean('active')->default(true);
$table->date('publication_date')->nullable();
$table->string('extra1', 455)->nullable();
$table->string('extra2', 455)->nullable();
$table->string('extra3', 455)->nullable();
$table->string('extra4', 455)->nullable();
$table->string('extra5', 455)->nullable();
$table->string('extra6', 455)->nullable();
$table->string('extra7', 455)->nullable();
$table->string('extra8', 455)->nullable();
$table->string('extra9', 455)->nullable();
$table->string('extra10', 455)->nullable();
$table->integer('category_id')->unsigned();
$table->foreign('category_id')
->references('id')
->on('product_categories')
->onDelete('cascade');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('products_shop');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProductImagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('product_images_shop', function (Blueprint $table) {
$table->increments('id');
$table->string('path', 455);
$table->string('description', 455)->nullable();
$table->integer('product_id')->unsigned();
$table->foreign('product_id')
->references('id')
->on('products')
->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('product_images_shop');
}
}
<?php
namespace Onestartup\Shop\Model;
use Illuminate\Database\Eloquent\Model;
class ProductCategoryShop extends Model
{
protected $table = 'product_categories_shop';
protected $fillable = [
'name',
'description',
'cover',
'active',
'slug'
];
public function products()
{
return $this->hasMany('Onestartup\Shop\Model\ProductShop', 'category_id');
}
}
<?php
namespace Onestartup\Shop\Model;
use Illuminate\Database\Eloquent\Model;
class ProductImageShop extends Model
{
protected $table = 'product_images_shop';
protected $fillable = [
'path',
'description',
'product_id'
];
public function product()
{
return $this->belongsTo('Onestartup\Shop\Model\ProductShop', 'product_id');
}
}
<?php
namespace Onestartup\Shop\Model;
use Illuminate\Database\Eloquent\Model;
class ProductShop extends Model
{
protected $table = 'products_shop';
protected $fillable = [
'name',
'slug',
'description',
'specifications',
'features',
'active',
'publication_date',
'category_id',
'cover',
'extra1',
'extra2',
'extra3',
'extra4',
'extra5',
'extra6',
'extra7',
'extra8',
'extra9',
'extra10',
];
public function category()
{
return $this->belongsTo('Onestartup\Shop\Model\ProductCategoryShop', 'category_id');
}
public function user()
{
return $this->belongsTo('App\User', 'user_id');
}
public function images()
{
return $this->hasMany('Onestartup\Shop\Model\ProductImageShop', 'product_id');
}
}
<?php
Route::group(['middleware' => ['web', 'auth', 'is_admin']], function(){
Route::resource('admin/shop/product', 'Onestartup\Shop\Controller\AdminProductController', ['as'=>'admin.shop']);
Route::resource('admin/shop/category', 'Onestartup\Shop\Controller\CategoryController', ['as'=>'admin.shop']);
Route::delete('delete/cover/category/product/{id}',
'Onestartup\Shop\Controller\CategoryController@deleteCover')
->name('delete.cover.category.shop');
Route::get('admin/products/datatable/shop',
'Onestartup\Shop\Controller\AdminProductController@getProducts')
->name('datatable.products.shop');
Route::post('admin/product/{id}/gallery',
'Onestartup\Shop\Controller\AdminProductController@storeGallery')
->name('admin.product.files.store.shop');
Route::delete('admin/product/delete/gallery/{id}',
'Onestartup\Shop\Controller\AdminProductController@deleteImage')
->name('admin.product.gallery.delete.shop');
Route::delete('delete/cover/product/{id}',
'Onestartup\Shop\Controller\AdminProductController@deleteCover')
->name('delete.cover.product.shop');
Route::get('admin/product/variable',
'Onestartup\Shop\Controller\AdminProductController@showVars')
->name('admin.product.variable.shop');
Route::post('admin/product/variable',
'Onestartup\Shop\Controller\AdminProductController@postVars')
->name('admin.product.variable.store.shop');
});
Route::group(['middleware' => ['web']], function(){
Route::get('producto/{slug}', 'Onestartup\Shop\Controller\ProductController@show')->name('show.product');
Route::get('productos', 'Onestartup\Shop\Controller\ProductController@index')->name('main.product');
});
@extends('crm-admin::main-layout')
@section('content')
<div class='row'>
<div class='col-md-12'>
<div class='box'>
<div class='box-header dark'>
<h2>Actualizar información</h2>
</div>
<div class='box-body'>
<div class='col-md-12'>
{!! Form::model($category,['route'=> ['admin.shop.category.update',$category->id],"method"=>"PUT", 'enctype'=>'multipart/form-data']) !!}
@include('shop::category.fields')
</div>
</div>
<div class='dker p-a text-right'>
<div class='col-md-12'>
<a class='btn danger' href="{{route('admin.shop.category.index')}}">Cancelar</a>
{!! Form::submit('Actualizar información', ['class'=>'btn dark']) !!}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
<!-- .modal nuevo contrato -->
<div class='modal fade' data-backdrop='true' id='ver'>
<div class='modal-dialog modal-lg'>
<div class='modal-content box-shadow-z3'>
<div class='modal-body text-center p-lg'>
@if ($category->cover == null)
<h4> No hay imagen asignada</h4>
@else
<img class='image-modal-preview' src="{{asset('storage/'.$category->cover)}}">
@endif
</div>
<div class='modal-footer'>
<button class='btn dark p-x-md' data-dismiss='modal' type='button'>Cerrar</button>
@if($category->cover != null)
{!! Form::open(['route'=> ['delete.cover.category.shop',$category->id],'method'=>'DELETE'])!!}
<button class='btn btn-danger button-mb' onclick="return confirm('¿Estás seguro de eliminar este elemento?');" type='submit'>
<i class='fas fa-trash-alt icon-special-size'>
Eliminar
</i>
</button>
{!! Form::close()!!}
@endif
</div>
</div>
<!-- /.modal-content -->
</div>
</div>
@endsection
<div class="form-group">
{!! Form::label('name', 'Nombre *') !!}
{!! Form::text('name', null, ["class"=>"form-control", "required"=>"required", "placeholder"=>"Coloque aquí el nombre de la categoría", "id"=>"first"]) !!}
</div>
<div class="form-group">
{!! Form::label('slug', 'URL Slug *') !!}
{!! Form::text('slug', null, ["class"=>"form-control", "required"=>"required", "placeholder"=>"Coloque aquí la liga o URL de la categoría", "id"=>"second"]) !!}
</div>
<div class="form-group">
{!! Form::label('description', 'Resumen') !!}
{!! Form::text('description', null, ["class"=>"form-control", "placeholder"=>"Coloque la información descriptiva de la categoría"]) !!}
</div>
<div class="form-group">
{!! Form::label('active', 'Estado') !!}
{!! Form::select('active', [true=>'Activo', false=>'Inactivo'], null, ["class"=>"form-control", "required"=>"required"]) !!}
</div>
<div class="form-group">
{!! Form::label('portada', 'Imagén de portada') !!}
@if (isset($category))
<span>
<a class="btn btn-xs accent" data-target="#ver" data-toggle="modal" href="#" ui-toggle-class="fade-up-big">
Ver actual
<i class="fa fa-eye"></i>
</a>
</span>
@endif
<br>
{!! Form::file('portada', null, ["class"=>"form-control"]) !!}
</div>
\ No newline at end of file
@extends('crm-admin::main-layout')
@section('content')
<div class='row'>
<div class='col-md-12 collapse' id='agregarCategoria'>
<div class='box'>
<div class='box-header dark'>
<h2>
Agregar nueva categoria
<span></span>
<a aria-expanded='false' class='btn btn-xs btn-danger button-ml' data-toggle='collapse' href='#agregarCategoria'>
Cancelar
</a>
</h2>
</div>
<div class='box-body'>
<div class='col-md-12'>
{!! Form::open(['route'=> 'admin.shop.category.store','method'=>'POST', 'enctype'=>'multipart/form-data']) !!}
@include('shop::category.fields')
<div class='form-group'>
<button class='btn btn-primary' type='submit'>
Registrar
</button>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
</div>
<div class='col-md-12'>
<div class='box'>
<div class='box-header dark'>
<h2>
Listado de Categorias de productos de la tienda
<span>
<a aria-expanded='false' class='btn btn-xs btn-info button-ml' data-toggle='collapse' href='#agregarCategoria'>
<i class='fas fa-plus'></i>
Agregar Categorías
</a>
</span>
</h2>
</div>
<div class='box-body'>
<div class='col-md-12'>
<table class='table'>
<tr>
<th>#</th>
<th>Categoría</th>
<th>Descripción</th>
<th>Productos</th>
<th></th>
</tr>
@foreach ($categories as $category)
<tr>
<td> {{$category->id}}</td>
<td>
<p> {{$category->name}}</p>
<p>
URL Slug:
<b> {{$category->slug}}</b>
</p>
</td>
<td> {{$category->description}}</td>
<td> {{$category->products->count()}}</td>
<td>
{!! Form::open(['route'=> ['admin.shop.category.destroy',$category->id],'method'=>'DELETE'])!!}
<button class='btn btn-danger btn-xs button-mb' onclick="return confirm('¿Estás seguro de eliminar este elemento?');" type='submit'>
<i class='fas fa-trash-alt icon-special-size'></i>
Eliminar
</button>
{!! Form::close()!!}
<a class='btn btn-xs accent' href="{{route('admin.shop.category.edit', $category->id)}}">
<i class='fas fa-edit icon-special-size'></i>
Editar
</a>
</td>
@endforeach
</tr>
</table>
</div>
</div>
<div class='dker p-a text-right'>
{{ $categories->links() }}
</div>
</div>
</div>
</div>
@endsection
@extends('crm-admin::main-layout')
@section('content')
<div class='row'>
<div class='col-md-12'>
<div class='box'>
<div class='box-header dark'>
<h2>Actualizar información</h2>
</div>
<div class='box-body'>
{!! Form::open(['route'=> 'admin.shop.product.store','method'=>'POST', "id"=>"target", 'enctype'=>'multipart/form-data']) !!}
@include('shop::product.fields')
</div>
<div class='dker p-a text-right'>
<div class='col-md-12'>
<a class='btn danger' href="{{route('admin.shop.product.index')}}" style='margin-right:10px'>Cancelar</a>
<button class='btn dark' type='submit'>
Registrar
</button>
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
@endsection
@section('script_extras')
<script src='https://cdn.ckeditor.com/4.8.0/standard/ckeditor.js'></script>
<script>
var options = {
filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images',
filebrowserImageUploadUrl: '/laravel-filemanager/upload?type=Images&_token=',
filebrowserBrowseUrl: '/laravel-filemanager?type=Files',
filebrowserUploadUrl: '/laravel-filemanager/upload?type=Files&_token='
};
</script>
<script>
CKEDITOR.replace('description', options);
CKEDITOR.replace('features', options);
CKEDITOR.replace('specifications', options);
$("#publication_date").datepicker({
dateFormat: "yy-mm-dd"
});
</script>
@endsection
@extends('crm-admin::main-layout')
@section('css_extras')
<link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.4.0/min/dropzone.min.css" rel='stylesheet' type='text/css'>
@endsection
@section('content')
<div class='row'>
<div class='col-md-12'>
<div class='box'>
<div class='box-header dark'>
<h2>Actualizar información del producto</h2>
</div>
<div class='box-body'>
{!! Form::model($product,['route'=> ['admin.shop.product.update', $product->id],"method"=>"PUT", 'enctype'=>'multipart/form-data']) !!}
@include('shop::product.fields')
</div>
<div class='dker p-a text-right'>
<div class='col-md-12'>
<a class='btn danger' href="{{route('admin.shop.product.index')}}" style='margin-right:10px'>Cancelar</a>
{!! Form::submit('Actualizar información', ['class'=>'btn dark']) !!}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<div class='box'>
<div class='box-header dark'>
<h2>Galeria de imagenes</h2>
</div>
<div class='box-body'>
<div class="row">
<div class="col-md-6">
{!! Form::open(['route'=> ['admin.product.files.store.shop', $product->id], 'method' => 'POST', 'files'=>'true', 'id' => 'my-dropzone' , 'class' => 'dropzone']) !!}
<div class="dz-message" style="height:200px;">
Arrastra las imagenes aqui
</div>
<div class="dropzone-previews"></div>
<button type="submit" class="btn btn-success" id="submitFiles">Save</button>
{!! Form::close() !!}
</div>
<div class="col-md-6">
@if($product->images->count() > 0)
<div class="row">
@foreach($product->images as $img)
<div class="col-md-4">
<img src="{{$img->path}}" width="100%">
{!! Form::open(['route'=> ['admin.product.gallery.delete.shop',$img->id],'method'=>'DELETE'])!!}
<button class='btn btn-danger btn-block' onclick="return confirm('¿Estás seguro de eliminar este elemento?');" type='submit'>
<i class='fas fa-trash-alt icon-special-size'></i>
Eliminar
</button>
{!! Form::close()!!}
</div>
@endforeach
</div>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
<!-- .modal nuevo contrato -->
<div class='modal fade' data-backdrop='true' id='ver'>
<div class='modal-dialog modal-lg'>
<div class='modal-content box-shadow-z3'>
<div class='modal-body text-center p-lg'>
@if ($product->cover == null)
<h4>No hay imagen asignada</h4>
@else
<img class='image-modal-preview' src="{{asset('storage/'.$product->cover)}}">
@endif
</div>
<div class='modal-footer'>
<button class='btn dark p-x-md' data-dismiss='modal' type='button'>Cerrar</button>
@if($product->cover != null)
{!! Form::open(['route'=> ['delete.cover.product.shop',$product->id],'method'=>'DELETE'])!!}
<button class='btn btn-danger button-mb' onclick="return confirm('¿Estás seguro de eliminar este elemento?');" type='submit'>
<i class='fas fa-trash-alt icon-special-size'></i>
Eliminar
</button>
{!! Form::close()!!}
@endif
</div>
</div>
<!-- /.modal-content -->
</div>
</div>
@endsection
@section('script_extras')
<script src='https://cdn.ckeditor.com/4.8.0/standard/ckeditor.js'></script>
<script>
var options = {
filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images',
filebrowserImageUploadUrl: '/laravel-filemanager/upload?type=Images&_token=',
filebrowserBrowseUrl: '/laravel-filemanager?type=Files',
filebrowserUploadUrl: '/laravel-filemanager/upload?type=Files&_token='
};
</script>
<script>
CKEDITOR.replace('description', options);
CKEDITOR.replace('features', options);
CKEDITOR.replace('specifications', options);
$("#publication_date").datepicker({
dateFormat: "yy-mm-dd"
});
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.4.0/min/dropzone.min.js"></script>
<script type="text/javascript">
Dropzone.options.myDropzone = {
autoProcessQueue: false,
uploadMultiple: true,
maxFilezise: 10,
maxFiles: 5,
init: function() {
var submitBtn = document.querySelector("#submitFiles");
myDropzone = this;
submitBtn.addEventListener("click", function(e){
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
});
this.on("addedfile", function(file) {
//alert("file uploaded");
});
this.on("complete", function(file) {
myDropzone.removeFile(file);
//alert('que pex');
});
this.on("success", function(myDropzone){
swal({
title: "Finalizado",
text: "Tus imagénes subieron correctamente",
icon: "success",
closeOnEsc: false,
closeOnClickOutside: false,
}).then((value) => {
location.reload();
});
myDropzone.processQueue.bind(myDropzone)
});
}
};
</script>
@endsection
<div class="row">
<div class="col-md-6">
<div class="form-group">
{!! Form::label('name', 'Nombre', ['class'=>'control-label'])!!}
{!! Form::text('name', null, ["class"=>"form-control", "required"=>"required", "id"=>"first"]) !!}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{!! Form::label('slug', 'URL Slug', ['class'=>'control-label'])!!}
{!! Form::text('slug', null, ["class"=>"form-control", "required"=>"required", "id"=>"second"]) !!}
</div>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<div class="form-group" >
{!! Form::label('active', 'Estado', ['class'=>'control-label'])!!}
{!! Form::select('active', [true=>'Activo', false=>'Inactivo'], null, ["class"=>"form-control", "required"=>"required"]) !!}
</div>
</div>
<div class='col-md-6'>
<div class="form-group" >
{!! Form::label('category_id', 'Categoria', ['class'=>'control-label'])!!}
{!! Form::select('category_id', $categories, null, ["class"=>"form-control", "required"=>"required"]) !!}
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{!! Form::label('cover', 'Portada', ['class'=>'control-label'])!!}
@if (isset($product))
<span>
<a class="btn btn-xs accent" data-target="#ver" data-toggle="modal" href="#" ui-toggle-class="fade-up-big">
Ver actual
<i class="fa fa-eye"></i>
</a>
</span>
@endif
<br>
{!! Form::file('cover', null, ["class"=>"form-control", "required"=>"required"]) !!}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{!! Form::label('publication_date', 'Fecha de publicación', ['class'=>'control-label'])!!}
{!! Form::text('publication_date', null, ["class"=>"form-control", "required"=>"required", "id"=>"publication_date"]) !!}
</div>
</div>
</div>
<div class="row">
@if(isset($variable))
@if($variable->alias1 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', $variable->alias1, ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias2 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra2', $variable->alias2, ['class'=>'control-label'])!!}
{!! Form::text('extra2', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias3 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra3', $variable->alias3, ['class'=>'control-label'])!!}
{!! Form::text('extra3', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias4 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra4', $variable->alias4, ['class'=>'control-label'])!!}
{!! Form::text('extra4', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias5 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra5', $variable->alias5, ['class'=>'control-label'])!!}
{!! Form::text('extra5', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias6 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra6', $variable->alias6, ['class'=>'control-label'])!!}
{!! Form::text('extra6', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias7 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra7', $variable->alias7, ['class'=>'control-label'])!!}
{!! Form::text('extra7', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias8 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra8', $variable->alias8, ['class'=>'control-label'])!!}
{!! Form::text('extra8', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias9 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra9', $variable->alias9, ['class'=>'control-label'])!!}
{!! Form::text('extra9', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias10 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra10', $variable->alias10, ['class'=>'control-label'])!!}
{!! Form::text('extra10', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@endif
</div>
<div class="row">
<div class="col-md-6">
{!! Form::label('description', 'Descripción', ['class'=>'control-label'])!!}
{!! Form::textarea('description', null, ["class"=>"form-control", "required"=>"required", 'id'=>'body', 'rows'=>"30", 'cols'=>"80"]) !!}
</div>
<div class="col-md-6">
{!! Form::label('features', 'Características', ['class'=>'control-label'])!!}
{!! Form::textarea('features', null, ["class"=>"form-control", "required"=>"required", 'id'=>'body', 'rows'=>"30", 'cols'=>"80"]) !!}
</div>
</div>
<div class="row">
<div class="col-md-6">
{!! Form::label('specifications', 'Especificaciones', ['class'=>'control-label'])!!}
{!! Form::textarea('specifications', null, ["class"=>"form-control", "required"=>"required", 'id'=>'body', 'rows'=>"30", 'cols'=>"80"]) !!}
</div>
</div>
@extends('crm-admin::main-layout')
@section('content')
<div class='row'>
<div class='col-md-12'>
<div class='box'>
<div class='box-header dark'>
<h2>
Listado de productos
<span>
<a class='btn btn-xs btn-info button-ml' href="{{route('admin.shop.product.create')}}">
<i class='fas fa-plus'></i>
Agregar producto
</a>
</span>
</h2>
</div>
<div class='box-body'>
<table class='table' id='products'>
<thead>
<tr>
<th>#</th>
<th>Producto</th>
<th>Descripcion</th>
<th>Caracteristicas</th>
<th>Especificaciones</th>
<th></th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script>
$(function() {
$('#products').DataTable({
processing: true,
serverSide: true,
pageLength: 25,
ajax: '{{ route("datatable.products.shop") }}',
columns: [
{data: 'id', name: 'id'},
{data: 'main', name: 'main'},
{data: 'description', name: 'description'},
{data: 'features', name: 'features'},
{data: 'specifications', name: 'specifications'},
{data: 'form', name: 'form'},
]
});
});
</script>
@endpush
<!DOCTYPE html>
<html>
<head>
<title>
{{$product->name or "PCatalogo de proeudtos"}}
</title>
@include('product-public::metatags')
</head>
<body>
{{-- Aqui toda la estructura del blog--}}
@yield('content')
{{-- Aqui el footer --}}
<!-- Importante: scripts elementales no remover -->
<script src='https://unpkg.com/sweetalert/dist/sweetalert.min.js'></script>
<script src='https://cdn.jsdelivr.net/jquery.jssocials/1.4.0/jssocials.min.js' type='text/javascript'></script>
<script src='//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5a139cd3addf2e26' type='text/javascript'></script>
<!-- ******************************************* -->
@yield('scripts_extra')
</body>
</html>
\ No newline at end of file
@extends('product-public::layout')
@section('content')
Listado de entradas
<p>
Categorias:
{{$categories}}
</p>
<p>
Productos todas
{{$products}}
</p>
<p>
Productos al azar
{{$otros}}
</p>
<p>
Paginacion:
{!! $products->links() !!}
</p>
@endsection
\ No newline at end of file
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
<meta charset='utf-8'>
<meta content='ie=edge' http-equiv='x-ua-compatible'>
<meta content='' name='description'>
<meta content='width=device-width, initial-scale=1' name='viewport'>
<meta content="{{isset($product) ? strip_tags(substr($product->description, 0, 120), '') :'Descripcion general del product'}}" name='description'>
<link href="{{isset($product) ? route('show.product', $product->slug) : route('main.product')}}" rel='canonical'>
<meta content='es_MX' property='og:locale'>
<meta content='website' property='og:type'>
<meta content="{{$product->name or 'Titulo general del blog'}}" property='og:title'>
<meta content="{{isset($product) ? strip_tags(substr($product->description, 0, 120), '') :'Descripcion general del product'}}" property='og:description'>
<meta content="{{isset($product) ? route('show.product', $product->slug) : route('main.product')}}" property='og:url'>
<meta content='{{env('APP_NAME')}}' property='og:site_name'>
<meta content="{{asset('assets/img/Odessa-Seguros-alta-2.png')}}" property='og:image'>
<meta content="{{asset('assets/img/Odessa-Seguros-alta-2.png')}}" property='og:image:secure_url'>
<meta content='summary' name='twitter:card'>
<meta content="{{isset($product) ? strip_tags(substr($product->description, 0, 120), '') :'Descripcion general del product'}}" name='twitter:description'>
<meta content="{{$product->name or 'titulo general del product'}}" name='twitter:title'>
<meta content='@odessa_seguros' name='twitter:site'>
<meta content="{{asset('assets/img/Odessa-Seguros-alta-2.png')}}" name='twitter:image'>
<meta content='@odessa_seguros' name='twitter:creator'>
@extends('product-public::layout')
@section('content')
<p>
Producto: {{$product}}
</p>
<p>
Categoria: {{$product->category}}
</p>
<p>
Categorias: Listado de categorias:
</p>
<p>{{$categories}}</p>
<p>
Listado de productos relacionados con sus categorias:
</p>
<p>
{{$otros}}
</p>
{{-- Caja de compartir con redes sociales--}}
<div class="addthis_inline_share_toolbox_le2j"></div>
{{-- *********************************** --}}
@endsection
@extends('crm-admin::main-layout')
@section('content')
<div class='row'>
<div class='col-md-12'>
<div class='box'>
<div class='box-header dark'>
<h2>Mapeo de variables extras</h2>
</div>
<div class='box-body'>
<div class='col-md-12'>
{!! Form::model($variable,['route'=> ['admin.product.variable.store'],"method"=>"POST"]) !!}
@include('product::variable.fields')
</div>
</div>
<div class='dker p-a text-right'>
<div class='col-md-12'>
{!! Form::submit('Actualizar información', ['class'=>'btn dark']) !!}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
@endsection
<div class="row">
<div class="col-md-6">
<div class="form-group">
{!! Form::label('alias1', 'Alias para el campo extra 1') !!}
{!! Form::text('alias1', null, ["class"=>"form-control"]) !!}
</div>
<div class="form-group">
{!! Form::label('alias2', 'Alias para el campo extra 2') !!}
{!! Form::text('alias2', null, ["class"=>"form-control"]) !!}
</div>
<div class="form-group">
{!! Form::label('alias3', 'Alias para el campo extra 3') !!}
{!! Form::text('alias3', null, ["class"=>"form-control"]) !!}
</div>
<div class="form-group">
{!! Form::label('alias4', 'Alias para el campo extra 4') !!}
{!! Form::text('alias4', null, ["class"=>"form-control"]) !!}
</div>
<div class="form-group">
{!! Form::label('alias5', 'Alias para el campo extra 5') !!}
{!! Form::text('alias5', null, ["class"=>"form-control"]) !!}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{!! Form::label('alias6', 'Alias para el campo extra 6') !!}
{!! Form::text('alias6', null, ["class"=>"form-control"]) !!}
</div>
<div class="form-group">
{!! Form::label('alias7', 'Alias para el campo extra 7') !!}
{!! Form::text('alias7', null, ["class"=>"form-control"]) !!}
</div>
<div class="form-group">
{!! Form::label('alias8', 'Alias para el campo extra 8') !!}
{!! Form::text('alias8', null, ["class"=>"form-control"]) !!}
</div>
<div class="form-group">
{!! Form::label('alias9', 'Alias para el campo extra 9') !!}
{!! Form::text('alias9', null, ["class"=>"form-control"]) !!}
</div>
<div class="form-group">
{!! Form::label('alias10', 'Alias para el campo extra 10') !!}
{!! Form::text('alias10', null, ["class"=>"form-control"]) !!}
</div>
</div>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment