Other products
This commit is contained in:
parent
ba7c42f90e
commit
c5929160c8
6 changed files with 148 additions and 0 deletions
|
|
@ -493,6 +493,8 @@ class ProductsController extends Controller
|
|||
'product_id' => $product_id,
|
||||
]);
|
||||
|
||||
$anifoodProduct->composition = $request->composition;
|
||||
$anifoodProduct->servings = $request->servings;
|
||||
$anifoodProduct->save();
|
||||
}
|
||||
|
||||
|
|
@ -506,6 +508,9 @@ class ProductsController extends Controller
|
|||
'product_id' => $product_id,
|
||||
]);
|
||||
|
||||
$garmentProduct->size = $request->size;
|
||||
$garmentProduct->color = $request->color;
|
||||
$garmentProduct->material = $request->material;
|
||||
$garmentProduct->save();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -245,6 +245,21 @@ class Product extends Model implements Buyable
|
|||
return $this->hasOne(FoodProduct::class, 'product_id');
|
||||
}
|
||||
|
||||
public function anifoodProduct()
|
||||
{
|
||||
return $this->hasOne(AnifoodProduct::class, 'product_id');
|
||||
}
|
||||
|
||||
public function toolProduct()
|
||||
{
|
||||
return $this->hasOne(ToolProduct::class, 'product_id');
|
||||
}
|
||||
|
||||
public function garmentProduct()
|
||||
{
|
||||
return $this->hasOne(GarmentProduct::class, 'product_id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
//relationship to associated products
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddFieldsToAnifoodProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('anifood_products', function (Blueprint $table) {
|
||||
$table->text('composition')->after('product_id');
|
||||
$table->unsignedInteger('servings')->after('composition')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('anifood_products', function (Blueprint $table) {
|
||||
$table->dropColumn('composition');
|
||||
$table->dropColumn('servings');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddFieldsToGarmentProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('garment_products', function (Blueprint $table) {
|
||||
$table->string('size')->after('product_id');
|
||||
$table->string('color')->after('size');
|
||||
$table->string('material')->after('color');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('garment_products', function (Blueprint $table) {
|
||||
$table->dropColumn('material');
|
||||
$table->dropColumn('color');
|
||||
$table->dropColumn('sersizevings');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -3,3 +3,45 @@
|
|||
<input type="hidden" id="product_type" name="product_type" value="anifoodProduct">
|
||||
</div>
|
||||
<!--adding fields (anifood_products)-->
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label for="servings">Portions</label>
|
||||
<input type="text" id="servings" name="servings" class="form-control" value="{{ old('servings', $product->anifoodProduct->servings) }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label>Composition</label>
|
||||
<textarea class="form-control" id="composition" name="composition" placeholder="Composition">{{ old('composition', $product->anifoodProduct->composition) }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var editorConfig = {
|
||||
removePlugins: ["Image", "ImageCaption", "ImageStyle", "ImageToolbar", "ImageUpload"],
|
||||
toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', '|', 'blockQuote', 'insertTable', '|', 'undo', 'redo' ],
|
||||
heading: {
|
||||
options: [
|
||||
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
|
||||
{ model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
|
||||
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
|
||||
{ model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
|
||||
{ model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' }
|
||||
]
|
||||
},
|
||||
table: {
|
||||
contentToolbar: [ 'tableColumn', 'tableRow', 'mergeTableCells' ]
|
||||
}
|
||||
};
|
||||
var compositionEditor;
|
||||
ClassicEditor
|
||||
.create( document.querySelector( '#composition' ), editorConfig)
|
||||
.then( editor => {
|
||||
compositionEditor = editor;
|
||||
})
|
||||
.catch( error => {
|
||||
console.error( error );
|
||||
} );
|
||||
</script>
|
||||
@parent
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -3,3 +3,19 @@
|
|||
<input type="hidden" id="product_type" name="product_type" value="garmentProduct">
|
||||
</div>
|
||||
<!--adding fields (garment_products)-->
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label for="size">Taille</label>
|
||||
<input type="text" id="size" name="size" class="form-control" value="{{ old('size', $product->garmentProduct->size) }}">
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label for="color">Couleur</label>
|
||||
<input type="text" id="color" name="color" class="form-control" value="{{ old('color', $product->garmentProduct->color) }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label for="material">Matière</label>
|
||||
<input type="text" id="material" name="material" class="form-control" value="{{ old('material', $product->garmentProduct->material) }}">
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue