Commit ded198d3 by Francisco Salazar

Initial commit

parents
# Package products OneStartup
**onestartup/product** is a module product for websites
# Installation
- Run this in the terminal
```php
composer require onestartup/product
```
- after add the ServiceProvider to the providers array in config/app.php
```php
Onestartup\Product\ProductServiceProvider::class,
```
- Run migration
```php
php artisan migrate
```
- add next lines to app/User.php
```php
public function products()
{
return $this->hasMany('Onestartup\Product\Model\Product', 'user_id');
}
```
- run command for publish views
```php
php artisan vendor:publish --provider="Onestartup\Product\ProductServiceProvider"
```
- run command for publish config file
```php
php artisan vendor:publish --tag=config
```
- run serv
```php
php artisan serve
```
- test in this route how admin user
```php
http://localhost:8000/admin/product/product
```
- add .env vars
```php
SLUG_PRODUCTS=productos
SLUG_PRODUCTS_CATEGORY=categorias
```
- test in this route
```php
http://localhost:8000/portafolio
```
\ No newline at end of file
{
"name": "onestartup/product-primerplano",
"description": "catalog of products for websites onestartup",
"type": "library",
"license": "Apache-2.0",
"authors": [
{
"name": "Francisco Salazar",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"psr-4": {"Onestartup\\ProductPrimerPlano\\": "src"}
}
}
<?php
namespace Onestartup\ProductPrimerPlano;
use Illuminate\Support\ServiceProvider;
class ProductPrimerPlanoServiceProvider 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/product')) {
$this->loadViewsFrom(base_path() . '/resources/views/vendor/onestartup/product', 'product-public');
$this->loadViewsFrom(__DIR__.'/views', 'product');
} else {
$this->loadViewsFrom(__DIR__.'/views', 'product');
$this->loadViewsFrom(__DIR__.'/views/public', 'product-public');
}
$this->publishes([
__DIR__.'/views/public' => resource_path('views/vendor/onestartup/product'),
]);
// Allow your user to publish the config
$this->publishes([
__DIR__.'/config/product.php' => config_path('product.php'),
], 'config');
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->make('Onestartup\ProductPrimerPlano\Controller\AdminProductController');
$this->app->make('Onestartup\ProductPrimerPlano\Controller\CategoryController');
$this->app->make('Onestartup\ProductPrimerPlano\Controller\ProductController');
$this->mergeConfigFrom( __DIR__.'/config/product.php', 'product');
}
}
<?php
return [
"slug_products" => "productos",
"slug_category" => "categoria",
"slug_subcategory" => "subcategoria",
"product-index" => [
"pagination" => 25,
"otros" => 6,
],
"product-show" => [
"otros" => 6,
],
"product-bycategory" => [
"pagination" => 15,
"otros" => 6
],
"product-bysubcategory" => [
"pagination" => 15,
"otros" => 6
],
];
\ No newline at end of file
<?php
namespace Onestartup\ProductPrimerPlano\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Yajra\Datatables\Datatables;
use Onestartup\ProductPrimerPlano\Model\ProductCategory as Category;
use Onestartup\ProductPrimerPlano\Model\ProductSubCategory as SubCategory;
use Onestartup\ProductPrimerPlano\Model\ProductImage as Gallery;
use Onestartup\ProductPrimerPlano\Model\Product;
use Onestartup\ProductPrimerPlano\Model\Variable as Variable;
use Onestartup\ProductPrimerPlano\Model\Asesor;
use Onestartup\ProductPrimerPlano\Requests\RequestProduct;
use Onestartup\ProductPrimerPlano\Requests\RequestVariables;
use Onestartup\ProductPrimerPlano\Requests\RequestGallery;
class AdminProductController extends Controller
{
public function index()
{
return view('product::product.index');
}
/**
* Show the form for creating a new resource.
* @return Response
*/
public function create()
{
$categories = Category::pluck('name', 'id');
$variable = Variable::first();
$asesores = Asesor::pluck('nombre', 'id');
$subcategories = [];
return view('product::product.create')
->with('asesores', $asesores)
->with('categories', $categories)
->with('subcategories', $subcategories)
->with('variable', $variable);
}
/**
* Store a newly created resource in storage.
* @param Request $request
* @return Response
*/
public function store(RequestProduct $request)
{
$product = new Product($request->all());
\Auth::user()->products()->save($product);
if (isset($request->cover)) {
$file = $request->file('cover');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='products/cover/'.$product->id."/".$nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$product->cover = $ubicacion_donde_guarda;
$product->save();
}
return redirect()
->route('admin.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');
$subcategories = SubCategory::where("category_id", $product->category_id)->pluck('name', 'id');
$variable = Variable::first();
return view('product::product.edit')
->with('categories', $categories)
->with('subcategories', $subcategories)
->with('product', $product)
->with('variable', $variable);
}
/**
* Update the specified resource in storage.
* @param Request $request
* @return Response
*/
public function update(RequestProduct $request, $id)
{
$product = Product::find($id);
$product->fill($request->all());
$product->save();
if (isset($request->cover)) {
$file = $request->file('cover');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='products/cover/'.$product->id."/".$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'>Categoría: <b>".$product->category->name."</b></p>".
"<p class='mb0'>Fecha de creación: <b>".$product->created_at->format('d/m/Y')."</b></p>";
})
->addColumn('form', function ($product) {
return "<center><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></center>";
})
->rawColumns(['main', 'description', 'features', 'specifications', 'form'])
->make();
}
public function storeGallery(RequestGallery $request, $product_id)
{
$product = Product::find($product_id);
$asset = '/storage/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);
if (file_exists(public_path().$gallery->path)) {
unlink(public_path().$gallery->path);
}
$gallery->delete();
return redirect()
->back()
->with('message_danger', 'Imagen eliminada correctamente');
}
public function deleteCover($id)
{
$product = Product::find($id);
if (file_exists(public_path().'/storage/'.$product->cover)) {
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('product::variable.edit')
->with('variable', $variable);
}
public function postVars(RequestVariables $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\ProductPrimerPlano\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Yajra\Datatables\Datatables;
use Onestartup\ProductPrimerPlano\Model\ProductCategory as Category;
use Onestartup\ProductPrimerPlano\Requests\RequestCategory;
class CategoryController extends Controller
{
/**
* Display a listing of the resource.
* @return Response
*/
public function index()
{
$categories = Category::paginate(25);
return view('product::category.index')
->with('categories', $categories);
}
/**
* Store a newly created resource in storage.
* @param Request $request
* @return Response
*/
public function store(RequestCategory $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 ='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('product::category.edit')
->with('category', $category);
}
/**
* Update the specified resource in storage.
* @param Request $request
* @return Response
*/
public function update(RequestCategory $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 ='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\ProductPrimerPlano\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Yajra\Datatables\Datatables;
use Onestartup\ProductPrimerPlano\Model\Product;
use Onestartup\ProductPrimerPlano\Model\ProductCategory as Category;
use Onestartup\ProductPrimerPlano\Model\ProductSubCategory as SubCategory;
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(config("product.product-index."));
} else {
$products = Product::where('active', true)->paginate(config("product.product-index.pagination"));
}
$otros = Product::where('active', true)->inRandomOrder()->take(config("product.product-index.otros"))->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)->where("id", "<>", $product->id)->inRandomOrder()->take(config("product.product-show.otros"))->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);
}
public function byCategory($category_slug)
{
$category = Category::where('slug', $category_slug)->first();
$products = $category->products()->where('active', true)->paginate(config("product.product-bycategory.pagination"));
$otros = Product::where('active', true)->inRandomOrder()->take(config("product.product-bycategory.otros"))->get();
$categories = Category::where('active', true)->get();
return view('product-public::category')
->with('categories', $categories)
->with('otros', $otros)
->with('category', $category)
->with('products', $products);
}
public function bySubCategory($category_slug, $subcategory_slug)
{
//return $category_slug . " " .$subcategory_slug;
$category = Category::where('slug', $category_slug)->first();
$subcategory = $category->subcategories->where('slug', $subcategory_slug)->first();
$products = $subcategory->products()->where('active', true)->paginate(config("product.product-bysubcategory.pagination"));
$otros = Product::where('active', true)->inRandomOrder()->take(config("product.product-bycategory.otros"))->get();
$categories = Category::where('active', true)->get();
$subcategories = $category->subcategories()->where('active' ,true)->get();
return view('product-public::subcategory')
->with('categories', $categories)
->with('subcategories', $subcategories)
->with('otros', $otros)
->with('category', $category)
->with('subcategory', $subcategory)
->with('products', $products);
}
}
<?php
namespace Onestartup\ProductPrimerPlano\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Onestartup\ProductPrimerPlano\Model\ProductCategory as Category;
use Onestartup\ProductPrimerPlano\Model\ProductSubCategory as SubCategory;
use Onestartup\ProductPrimerPlano\Requests\RequestSubCategory;
class SubCategoryController extends Controller{
public function index(Request $request, $category_id){
$category = Category::find($category_id);
if($request->ajax()){
return $subcategories = $category->subcategories()->get();
}
$subcategories = $category->subcategories()->paginate(30);
return view("product::subcategory.index")
->with("subcategories", $subcategories)
->with("category", $category);
}
public function edit($category_id, $id){
$category = Category::find($category_id);
$subcategory = SubCategory::where("category_id", $category_id)->find($id);
return view("product::subcategory.edit")
->with("subcategory", $subcategory)
->with("category", $category);
}
public function store(RequestSubCategory $request, $category_id){
$subcategory = new SubCategory($request->all());
$subcategory->category_id = $category_id;
$subcategory->save();
if (isset($request->portada)) {
$file = $request->file('portada');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='product/subcategories/' . $subcategory->id . '/' .$nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$subcategory->cover = $ubicacion_donde_guarda;
$subcategory->save();
}
return redirect()
->back()
->with('message_success', 'Subcategoría añadida correctamente.');
}
public function update(RequestSubCategory $request, $category_id, $id){
$subcategory = SubCategory::where("category_id", $category_id)->find($id);
$subcategory->fill($request->all());
$subcategory->save();
if (isset($request->portada) && $request->portada != null ) {
$file = $request->file('portada');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='product/subcategories/'. $subcategory->id . '/'. $nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$subcategory->cover = $ubicacion_donde_guarda;
$subcategory->save();
}
return redirect()
->back()
->with('message_success', 'Subcategoría actualizada correctamente.');
}
public function destroy($category_id, $id){
$subcategory = SubCategory::where("category_id", $category_id)->find($id);
$subcategory->delete();
return redirect()
->back()
->with('message_danger', 'Subcategoría eliminada correctamente.');
}
public function deleteCover($id)
{
$category = SubCategory::find($id);
$category->cover = null;
$category->save();
return redirect()
->back()
->with('message_success', 'Imagen eliminada correctamente.');
}
}
\ No newline at end of file
<?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', 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');
}
}
<?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', 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->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');
}
}
<?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', 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');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddExtrasFieldsToProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function (Blueprint $table) {
$table->string('extra7', 455)->nullable();
$table->string('extra8', 455)->nullable();
$table->string('extra9', 455)->nullable();
$table->string('extra10', 455)->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn(['extra7', 'extra8', 'extra9', 'extra10']);
});
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateVariablesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('variables', function (Blueprint $table) {
$table->increments('id');
$table->string('alias1', 455)->nullable();
$table->string('alias2', 455)->nullable();
$table->string('alias3', 455)->nullable();
$table->string('alias4', 455)->nullable();
$table->string('alias5', 455)->nullable();
$table->string('alias6', 455)->nullable();
$table->string('alias7', 455)->nullable();
$table->string('alias8', 455)->nullable();
$table->string('alias9', 455)->nullable();
$table->string('alias10', 455)->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('variables');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddExtra11ToProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function (Blueprint $table) {
$table->text('extra11')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn(['extra11']);
});
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddAlias11ToVariablesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('variables', function (Blueprint $table) {
$table->string('alias11', 455)->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('variables', function (Blueprint $table) {
$table->dropColumn(['alias11']);
});
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProductSubcategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('product_subcategories', 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->integer('category_id')->unsigned();
$table->foreign('category_id')
->references('id')
->on('product_categories')
->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('product_subcategories');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddSubcategoryToProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function($table) {
$table->integer('subcategory_id')->unsigned()->nullable();
$table->foreign('subcategory_id')->references('id')->on('product_subcategories')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function($table) {
$table->dropColumn('subcategory_id');
});
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAsesorTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('asesores', function (Blueprint $table) {
$table->increments('id');
$table->string("nombre");
$table->string("telefono1");
$table->string("telefono2");
$table->string("celular");
$table->string("email");
$table->string("foto", 455);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('asesores');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddExtrasToProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function (Blueprint $table) {
$table->double('precio_renta', 8, 2)->nullable();
$table->string('tipo_moneda_renta', 455)->nullable();
$table->string('precio_renta_tiene_oferta')->nullable();
$table->double('precio_renta_oferta', 8, 2)->nullable();
$table->double('precio_venta', 8, 2)->nullable();
$table->string('tipo_moneda_venta', 455)->nullable();
$table->string('precio_venta_tiene_oferta')->nullable();
$table->double('precio_venta_oferta', 8, 2)->nullable();
$table->double('metros_construccion', 8, 2)->nullable();
$table->double('metros_terreno', 8, 2)->nullable();
$table->double('metros_frente', 8, 2)->nullable();
$table->double('metros_fondo', 8, 2)->nullable();
$table->integer('banos')->nullable();
$table->integer('medios_banos')->nullable();
$table->integer('dormitorios')->nullable();
$table->string('edad')->nullable();
$table->integer('asesor_id')->unsigned()->nullable();
//$table->foreign('asesor_id')
// ->references('id')
// ->on('asesores')
// ->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn([
'precio_renta', 'tipo_moneda_renta',
'precio_renta_tiene_oferta', 'precio_renta_oferta',
'precio_venta', 'tipo_moneda_venta',
'precio_venta_tiene_oferta', 'precio_venta_oferta',
'metros_construccion', 'metros_terreno',
'metros_frente', 'metros_fondo',
'banos', 'medios_banos', 'dormitorios', 'edad',
'asesor_id'
]);
});
}
}
<?php
namespace Onestartup\ProductPrimerPlano\Model;
use Illuminate\Database\Eloquent\Model;
class Asesor extends Model
{
protected $table = 'asesores';
protected $fillable = [
'nombre',
'telefono1',
'telefono2',
'telefono_celular',
'email',
'foto'
];
}
\ No newline at end of file
<?php
namespace Onestartup\ProductPrimerPlano\Model;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
protected $table = 'products';
protected $fillable = [
'name',
'slug',
'description',
'specifications',
'features',
'active',
'publication_date',
'category_id',
'subcategory_id',
'cover',
'extra1',
'extra2',
'extra3',
'extra4',
'extra5',
'extra6',
'extra7',
'extra8',
'extra9',
'extra10',
'extra11',
'precio_renta',
'tipo_moneda_renta',
'precio_renta_tiene_oferta',
'precio_renta_oferta',
'precio_venta',
'tipo_moneda_venta',
'precio_renta_tiene_oferta',
'precio_venta_oferta',
'metros_construccion',
'metros_terreno',
'metros_frente',
'metros_fondo',
'banos',
'medios_banos',
'dormitorios',
'edad',
'asesor_id'
];
public function category()
{
return $this->belongsTo('Onestartup\ProductPrimerPlano\Model\ProductCategory', 'category_id');
}
public function subcategory()
{
return $this->belongsTo('Onestartup\ProductPrimerPlano\Model\ProductSubCategory', 'subcategory_id');
}
public function user()
{
return $this->belongsTo('App\User', 'user_id');
}
public function images()
{
return $this->hasMany('Onestartup\ProductPrimerPlano\Model\ProductImage', 'product_id');
}
}
<?php
namespace Onestartup\ProductPrimerPlano\Model;
use Illuminate\Database\Eloquent\Model;
class ProductCategory extends Model
{
protected $table = 'product_categories';
protected $fillable = [
'name',
'description',
'cover',
'active',
'slug'
];
public function products()
{
return $this->hasMany('Onestartup\ProductPrimerPlano\Model\Product', 'category_id');
}
public function subcategories(){
return $this->hasMany('Onestartup\ProductPrimerPlano\Model\ProductSubCategory', 'category_id');
}
}
<?php
namespace Onestartup\ProductPrimerPlano\Model;
use Illuminate\Database\Eloquent\Model;
class ProductImage extends Model
{
protected $table = 'product_images';
protected $fillable = [
'path',
'description',
'product_id'
];
public function product()
{
return $this->belongsTo('Onestartup\ProductPrimerPlano\Model\Product', 'product_id');
}
}
<?php
namespace Onestartup\ProductPrimerPlano\Model;
use Illuminate\Database\Eloquent\Model;
class ProductSubCategory extends Model
{
protected $table = 'product_subcategories';
protected $fillable = [
'name',
'description',
'cover',
'active',
'slug',
'category_id'
];
public function category()
{
return $this->belongsTo('Onestartup\ProductPrimerPlano\Model\ProductCategory', 'category_id');
}
public function products(){
return $this->hasMany('Onestartup\ProductPrimerPlano\Model\Product', 'subcategory_id');
}
}
<?php
namespace Onestartup\ProductPrimerPlano\Model;
use Illuminate\Database\Eloquent\Model;
class Variable extends Model
{
protected $table = 'variables';
protected $fillable = [
'alias1',
'alias2',
'alias3',
'alias4',
'alias5',
'alias6',
'alias7',
'alias8',
'alias9',
'alias10',
'alias11'
];
}
<?php
namespace Onestartup\ProductPrimerPlano\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RequestCategory extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->get("_method") == "PUT" || $this->get("_method") == "PATCH"){
$slug = 'required|max:455|unique:product_categories,slug,'.$this->route("category");
}else{
$slug = 'required|max:455|unique:product_categories,slug';
}
return [
'name' => 'required|max:355',
'slug' => $slug,
'description'=> 'max:455',
'active' => 'required|boolean',
'portada' => 'image'
];
}
}
\ No newline at end of file
<?php
namespace Onestartup\ProductPrimerPlano\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RequestGallery extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'file.*' => 'image'
];
}
}
\ No newline at end of file
<?php
namespace Onestartup\ProductPrimerPlano\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RequestProduct extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->get("_method") == "PUT" || $this->get("_method") == "PATCH"){
$slug = 'required|max:455|unique:products,slug,'.$this->route("product");
}else{
$slug = 'required|max:455|unique:products,slug';
}
return [
'name' => 'required|max:355',
'slug' => $slug,
'description'=> 'required',
'active' => 'required|boolean',
'publication_date' => 'required',
'extra1' => 'max:455',
'extra2' => 'max:455',
'extra3' => 'max:455',
'extra4' => 'max:455',
'extra5' => 'max:455',
'extra6' => 'max:455',
'extra7' => 'max:455',
'extra8' => 'max:455',
'extra9' => 'max:455',
'extra10' => 'max:455',
'category_id' => 'required|numeric',
'cover' => 'image'
];
}
}
\ No newline at end of file
<?php
namespace Onestartup\ProductPrimerPlano\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RequestSubCategory extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if ($this->get("_method") == "PUT" || $this->get("_method") == "PATCH"){
$slug = 'required|max:255|unique:product_subcategories,slug,'.$this->route("subcategory");
}else{
$slug = 'required|max:255|unique:product_subcategories,slug';
}
return [
'name' => 'required|max:355',
'slug' => $slug,
'description'=> 'max:455',
'active' => 'required|boolean',
'portada' => 'image'
];
}
}
\ No newline at end of file
<?php
namespace Onestartup\ProductPrimerPlano\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RequestVariables extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'alias1' => 'max:455',
'alias2' => 'max:455',
'alias3' => 'max:455',
'alias4' => 'max:455',
'alias5' => 'max:455',
'alias6' => 'max:455',
'alias7' => 'max:455',
'alias8' => 'max:455',
'alias9' => 'max:455',
'alias10' => 'max:455',
'alias11' => 'max:455',
];
}
}
\ No newline at end of file
<?php
Route::group(['middleware' => ['web', 'auth', 'is_admin']], function(){
Route::resource('admin/product/product', 'Onestartup\ProductPrimerPlano\Controller\AdminProductController', ['as'=>'admin', 'except'=>['show']]);
Route::resource('admin/product/category', 'Onestartup\ProductPrimerPlano\Controller\CategoryController', ['as'=>'admin.product', 'except' => ['show', 'create']]);
Route::delete('delete/cover/category/product/{id}', 'Onestartup\ProductPrimerPlano\Controller\CategoryController@deleteCover')
->name('delete.cover.category.product');
Route::resource('admin/product/category/{category_id}/subcategory', 'Onestartup\ProductPrimerPlano\Controller\SubCategoryController', ['as'=>'admin.product', 'except' => ['show', 'create']]);
//Route::post("api/admin/product/category/{category_id}/subcategory", )
Route::delete('delete/cover/subcategory/product/{id}', 'Onestartup\ProductPrimerPlano\Controller\SubCategoryController@deleteCover')
->name('delete.cover.subcategory.product');
Route::get('admin/products/datatable', 'Onestartup\ProductPrimerPlano\Controller\AdminProductController@getProducts')
->name('datatable.products');
Route::post('admin/product/{id}/gallery', 'Onestartup\ProductPrimerPlano\Controller\AdminProductController@storeGallery')
->name('admin.product.files.store');
Route::delete('admin/product/delete/gallery/{id}', 'Onestartup\ProductPrimerPlano\Controller\AdminProductController@deleteImage')
->name('admin.product.gallery.delete');
Route::delete('delete/cover/product/{id}', 'Onestartup\ProductPrimerPlano\Controller\AdminProductController@deleteCover')
->name('delete.cover.product');
Route::get('admin/product/variable', 'Onestartup\ProductPrimerPlano\Controller\AdminProductController@showVars')
->name('admin.product.variable');
Route::post('admin/product/variable', 'Onestartup\ProductPrimerPlano\Controller\AdminProductController@postVars')
->name('admin.product.variable.store');
});
Route::group(['middleware' => ['web']], function(){
Route::get(config("product.slug_products").'/{slug}', 'Onestartup\Product\Controller\ProductController@show')->name('show.product');
Route::get(config("product.slug_products"), 'Onestartup\Product\Controller\ProductController@index')->name('main.product');
Route::get(config("product.slug_category").'/{slug_category}',
'Onestartup\Product\Controller\ProductController@byCategory')
->name('category.product');
Route::get(config("product.slug_category").'/{slug_category}/{slug_subcategory}',
'Onestartup\Product\Controller\ProductController@bySubCategory')
->name('subcategory.product');
});
@extends('crm-admin::main-layout')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{route('home')}}">Home</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.index')}}">Productos</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.category.index')}}">Lista de categorías</a>
</li>
<li class="breadcrumb-item active">
{{$category->name}}
</li>
@endsection
@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.product.category.update',$category->id],"method"=>"PUT", 'enctype'=>'multipart/form-data']) !!}
@include('product::category.fields')
</div>
</div>
<div class='dker p-a text-right'>
<div class='col-md-12'>
<a class='btn danger' href="{{route('admin.product.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.product',$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('breadcrumb')
<li class="breadcrumb-item">
<a href="{{route('home')}}">Home</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.index')}}">Productos</a>
</li>
<li class="breadcrumb-item active">
Lista de categorías
</li>
@endsection
@section('content')
<div class='row'>
<div class='col-md-12 collapse' id='agregarCategoria'>
<div class='box'>
<div class='box-header dark'>
<h2>
Agregar nueva categoría
<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.product.category.store','method'=>'POST', 'enctype'=>'multipart/form-data']) !!}
@include('product::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 Categorías de productos
<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>Subcategorias</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 class="text-center"> {{$category->products->count()}}</td>
<td class="text-center"> {{$category->subcategories->count()}}</td>
<td class="text-center">
<a class='btn btn-xs btn-success button-mb' href="{{route('admin.product.subcategory.index', $category->id)}}">
<i class='fas fa-plus icon-special-size'></i>
Subcategorías
</a>
{!! Form::open(['route'=> ['admin.product.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.product.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('breadcrumb')
<li class="breadcrumb-item">
<a href="{{route('home')}}">Home</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.index')}}">Productos</a>
</li>
<li class="breadcrumb-item active">
Crear producto
</li>
@endsection
@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.product.store','method'=>'POST', "id"=>"target", 'enctype'=>'multipart/form-data']) !!}
@include('product::product.fields')
</div>
<div class='dker p-a text-right'>
<div class='col-md-12'>
<a class='btn danger' href="{{route('admin.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>
<script>
$(document).ready(function() {
var category = $("#category_id").val();
$.ajax({
type: "GET",
url: "/admin/product/category/" + category + "/subcategory",
success: function(data)
{
$("#subcategory_id").html("");
$("#subcategory_id").append('<option value="" selected disabled>Selecciona una subcategoría</option>');
$.each( data, function( key, value ) {
$("#subcategory_id").append('<option value=' + value.id + '>' + value.name + '</option>');
});
},
error: function(data){
console.log("error");
}
});
});
$("#category_id").change(function() {
var category = $("#category_id").val();
$.ajax({
type: "GET",
url: "/admin/product/category/" + category + "/subcategory",
success: function(data)
{
$("#subcategory_id").html("");
$("#subcategory_id").append('<option value="" selected disabled>Selecciona una subcategoría</option>');
$.each( data, function( key, value ) {
$("#subcategory_id").append('<option value=' + value.id + '>' + value.name + '</option>');
});
},
error: function(data){
console.log("error");
}
});
});
</script>
@if($variable != null)
@if($variable->alias11 != null)
<script type="text/javascript">
CKEDITOR.replace('extra11', options);
</script>
@endif
@endif
@endsection
@extends('crm-admin::main-layout')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{route('home')}}">Home</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.index')}}">Productos</a>
</li>
<li class="breadcrumb-item active">
{{$product->name}}
</li>
@endsection
@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.product.update', $product->id],"method"=>"PUT", 'enctype'=>'multipart/form-data']) !!}
@include('product::product.fields')
</div>
<div class='dker p-a text-right'>
<div class='col-md-12'>
<a class='btn danger' href="{{route('admin.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>Galería de imágenes</h2>
</div>
<div class='box-body'>
<div class="row">
<div class="col-md-6">
{!! Form::open(['route'=> ['admin.product.files.store', $product->id], 'method' => 'POST', 'files'=>'true', 'id' => 'my-dropzone' , 'class' => 'dropzone']) !!}
<div class="dz-message" style="height:200px;">
Arrastra las imágenes 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',$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',$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>
@if($variable != null)
@if($variable->alias11 != null)
<script type="text/javascript">
CKEDITOR.replace('extra11', options);
</script>
@endif
@endif
<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: true,
uploadMultiple: true,
maxFilezise: 30,
maxFiles: 10,
parallelUploads: 10,
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>
<script>
$("#category_id").change(function() {
var category = $("#category_id").val();
$.ajax({
type: "GET",
url: "/admin/product/category/" + category + "/subcategory",
success: function(data)
{
$("#subcategory_id").html("");
$.each( data, function( key, value ) {
$("#subcategory_id").append('<option value=' + value.id + '>' + value.name + '</option>');
});
},
error: function(data){
console.log("error");
}
});
});
</script>
@endsection
@extends('crm-admin::main-layout')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{route('home')}}">Home</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.index')}}">Productos</a>
</li>
<li class="breadcrumb-item active">
Lista de productos
</li>
@endsection
@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.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>Descripción</th>
<th>Características</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") }}',
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
@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
<!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('product-public::layout')
@section('content')
Listado de entradas
<p>
Categoria local:
{{$category}}
</p>
<p>
Subcategoria local
{{$subcategory}}
</p>
<p>
Categorias:
{{$categories}}
</p>
<p>
Subcategorias:
{{$categories}}
</p>
<p>
Productos todas
@foreach($products as $product)
{{product}}
@endforeach
</p>
<p>
Productos al azar
{{$otros}}
</p>
<p>
Paginacion:
{!! $products->links() !!}
</p>
@endsection
\ No newline at end of file
@extends('crm-admin::main-layout')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{route('home')}}">Home</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.index')}}">Productos</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.category.index')}}">Categorías</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.category.index')}}"> {{$category->name}}</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.subcategory.index', $category->id)}}"> Subcategorías de {{$category->name}}</a>
</li>
<li class="breadcrumb-item active">
Subcategoria: {{$subcategory->name}}
</li>
@endsection
@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($subcategory,['route'=> ['admin.product.subcategory.update',$category->id, $subcategory->id],"method"=>"PUT", 'enctype'=>'multipart/form-data']) !!}
@include('product::subcategory.fields')
</div>
</div>
<div class='dker p-a text-right'>
<div class='col-md-12'>
<a class='btn danger' href="{{route('admin.product.subcategory.index', $category->id)}}">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 ($subcategory->cover == null)
<h4> No hay imagen asignada</h4>
@else
<img class='image-modal-preview' src="{{asset('storage/'.$subcategory->cover)}}">
@endif
</div>
<div class='modal-footer'>
<button class='btn dark p-x-md' data-dismiss='modal' type='button'>Cerrar</button>
@if($subcategory->cover != null)
{!! Form::open(['route'=> ['delete.cover.subcategory.product', $subcategory->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($subcategory))
<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('breadcrumb')
<li class="breadcrumb-item">
<a href="{{route('home')}}">Home</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.index')}}">Productos</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.category.index')}}"> Categorías</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.category.index')}}"> Categoría: {{$category->name}}</a>
</li>
<li class="breadcrumb-item active">
Listado de subcategorias
</li>
@endsection
@section('content')
<div class='row'>
<div class='col-md-12 collapse' id='agregarCategoria'>
<div class='box'>
<div class='box-header dark'>
<h2>
Agregar nueva subcategoría
<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.product.subcategory.store', $category->id],'method'=>'POST', 'enctype'=>'multipart/form-data']) !!}
@include('product::subcategory.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>
<b>{{$category->name}}:</b> Listado de subcategorías
<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 Nueva Subcategoría
</a>
</span>
</h2>
</div>
<div class='box-body'>
<div class='col-md-12'>
<table class='table'>
<tr>
<th>#</th>
<th>Subcategoría</th>
<th>Descripción</th>
<th></th>
</tr>
@foreach ($subcategories as $subcategory)
<tr>
<td> {{$subcategory->id}}</td>
<td>
<p> {{$subcategory->name}}</p>
<p>
URL Slug:
<b> {{$subcategory->slug}}</b>
</p>
</td>
<td> {{$subcategory->description}}</td>
<td class="text-center">
{!! Form::open(['route'=> ['admin.product.subcategory.destroy',$category->id,$subcategory->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.product.subcategory.edit', [$category->id, $subcategory->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'>
{{ $subcategories->links() }}
</div>
</div>
</div>
</div>
@endsection
\ No newline at end of file
@extends('crm-admin::main-layout')
@section('breadcrumb')
<li class="breadcrumb-item">
<a href="{{route('home')}}">Home</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('admin.product.index')}}">Productos</a>
</li>
<li class="breadcrumb-item active">
Variables
</li>
@endsection
@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 class="form-group">
{!! Form::label('alias11', 'Alias para el campo extra 11') !!}
{!! Form::text('alias11', null, ["class"=>"form-control"]) !!}
</div>
</div>
</div>
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit7173633b0cb420d97a2e8a09a0590ba0::getLoader();
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Onestartup\\Product\\' => array($baseDir . '/src'),
);
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit7173633b0cb420d97a2e8a09a0590ba0
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit7173633b0cb420d97a2e8a09a0590ba0', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit7173633b0cb420d97a2e8a09a0590ba0', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit7173633b0cb420d97a2e8a09a0590ba0::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit7173633b0cb420d97a2e8a09a0590ba0
{
public static $prefixLengthsPsr4 = array (
'O' =>
array (
'Onestartup\\Product\\' => 19,
),
);
public static $prefixDirsPsr4 = array (
'Onestartup\\Product\\' =>
array (
0 => __DIR__ . '/../..' . '/src',
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7173633b0cb420d97a2e8a09a0590ba0::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7173633b0cb420d97a2e8a09a0590ba0::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
}
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