Commit 5a224789 by Angel MAS

Mapeo de variables

parent e135c567
......@@ -9,6 +9,7 @@ use Yajra\Datatables\Datatables;
use Onestartup\Product\Model\ProductCategory as Category;
use Onestartup\Product\Model\ProductImage as Gallery;
use Onestartup\Product\Model\Product;
use Onestartup\Product\Model\Variable;
class AdminProductController extends Controller
{
......@@ -24,9 +25,11 @@ class AdminProductController extends Controller
public function create()
{
$categories = Category::pluck('name', 'id');
$variable = Variable::first();
return view('product::product.create')
->with('categories', $categories);
->with('categories', $categories)
->with('variable', $variable);
}
/**
......@@ -66,10 +69,12 @@ class AdminProductController extends Controller
{
$product = Product::find($id);
$categories = Category::pluck('name', 'id');
$variable = Variable::first();
return view('product::product.edit')
->with('categories', $categories)
->with('product', $product);
->with('product', $product)
->with('variable', $variable);
}
/**
......@@ -204,4 +209,35 @@ class AdminProductController extends Controller
}
public function showVars()
{
$variable = Variable::first();
if ($variable == null) {
$variable = new Variable();
}
return view('product::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
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
namespace Onestartup\Product\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'
];
}
......@@ -16,6 +16,12 @@ Route::group(['middleware' => ['web', 'auth', 'is_admin']], function(){
Route::delete('delete/cover/product/{id}', 'Onestartup\Product\Controller\AdminProductController@deleteCover')
->name('delete.cover.product');
Route::get('admin/product/variable', 'Onestartup\Product\Controller\AdminProductController@showVars')
->name('admin.product.variable');
Route::post('admin/product/variable', 'Onestartup\Product\Controller\AdminProductController@postVars')
->name('admin.product.variable.store');
});
Route::group(['middleware' => ['web']], function(){
......
......@@ -57,49 +57,100 @@
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', 'Ciudad', ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
@if($variable != null)
@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>
</div>
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra2', 'Latitud', ['class'=>'control-label'])!!}
{!! Form::text('extra2', null, ["class"=>"form-control"]) !!}
@endif
@if($variable->alias2 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', $variable->alias2, ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra3', 'Longitud', ['class'=>'control-label'])!!}
{!! Form::text('extra3', null, ["class"=>"form-control"]) !!}
@endif
@if($variable->alias3 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', $variable->alias3, ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra4', 'Extra 4', ['class'=>'control-label'])!!}
{!! Form::text('extra4', null, ["class"=>"form-control"]) !!}
@endif
@if($variable->alias4 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', $variable->alias4, ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra5', 'Extra 5', ['class'=>'control-label'])!!}
{!! Form::text('extra5', null, ["class"=>"form-control"]) !!}
@endif
@if($variable->alias5 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', $variable->alias5, ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra6', 'Extra 6', ['class'=>'control-label'])!!}
{!! Form::text('extra6', null, ["class"=>"form-control"]) !!}
@endif
@if($variable->alias6 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', $variable->alias6, ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
</div>
</div>
</div>
@endif
@if($variable->alias7 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', $variable->alias7, ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias8 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', $variable->alias8, ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias9 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', $variable->alias9, ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@if($variable->alias10 != null)
<div class="col-md-4">
<div class="form-group">
{!! Form::label('extra1', $variable->alias10, ['class'=>'control-label'])!!}
{!! Form::text('extra1', null, ["class"=>"form-control"]) !!}
</div>
</div>
@endif
@endif
</div>
<div class="row">
......
@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