Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use IlluminateSupportFacadesSchema;
- use IlluminateDatabaseSchemaBlueprint;
- use IlluminateDatabaseMigrationsMigration;
- class CreatePlatosTable extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('platos', function (Blueprint $table) {
- $table->increments('id');
- $table->char('nombre',50);
- $table->double('valor', 8, 2);
- $table->timestamps();
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('platos');
- }
- }
- <?php
- use IlluminateSupportFacadesSchema;
- use IlluminateDatabaseSchemaBlueprint;
- use IlluminateDatabaseMigrationsMigration;
- class CreatePlatoIngredienteTable extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('platoIngrediente', function (Blueprint $table) {
- $table->increments('id');
- $table->unsignedInteger('plato_id');
- $table->foreign('plato_id')->references('id')->on('plato');
- $table->unsignedInteger('plato_id');
- $table->foreign('ingrediente_id')->references('id')->on('ingrediente');
- $table->double('cantidad', 8, 2);
- $table->timestamps();
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('platoIngrediente');
- }
- }
- <?php
- namespace App;
- use IlluminateDatabaseEloquentModel;
- class PlatoIngrediente extends Model
- {
- public $table = "platoIngrediente";
- protected $fillable = ['cantidad'];
- public function platos(){
- return $this->belongsTo('AppPlato','id_plato');
- }
- public function ingredientes(){
- return $this->belongsTo('AppIngrediente','id_ingrediente');
- }
- }
- <?php
- namespace AppHttpControllers;
- use AppPlatoIngrediente;
- use IlluminateHttpRequest;
- class PlatoIngredienteController extends Controller
- {
- /**
- * Display a listing of the resource.
- *
- * @return IlluminateHttpResponse
- */
- public function index()
- {
- $platoingrediente = PlatoIngrediente::all();
- return view('platoingrediente/index', compact('platoIngrediente'));
- }
- /**
- * Show the form for creating a new resource.
- *
- * @return IlluminateHttpResponse
- */
- public function create()
- {
- return view('platoingrediente/create');
- }
- /**
- * Store a newly created resource in storage.
- *
- * @param IlluminateHttpRequest $request
- * @return IlluminateHttpResponse
- */
- public function store(Request $request)
- {
- //
- }
- /**
- * Display the specified resource.
- *
- * @param AppPlatoIngrediente $platoIngrediente
- * @return IlluminateHttpResponse
- */
- public function show($id)
- {
- //
- }
- /**
- * Show the form for editing the specified resource.
- *
- * @param AppPlatoIngrediente $platoIngrediente
- * @return IlluminateHttpResponse
- */
- public function edit($id)
- {
- //
- }
- /**
- * Update the specified resource in storage.
- *
- * @param IlluminateHttpRequest $request
- * @param AppPlatoIngrediente $platoIngrediente
- * @return IlluminateHttpResponse
- */
- public function update(Request $request, $id)
- {
- //
- }
- public function formulario(){
- $platos = Platos::with('platos','ingredientes')->get();
- return view('/platoingrediente/index', compact('$platos'));
- }
- /**
- * Remove the specified resource from storage.
- *
- * @param AppPlatoIngrediente $platoIngrediente
- * @return IlluminateHttpResponse
- */
- public function destroy($id)
- {
- //
- }
- }
- <div class="up sombra card">
- <div class="card-header">
- Creacion del plato
- </div>
- <div class="card-body">
- <div class="up">
- @if(session()->get('success'))
- <div class="alert alert-success">
- {{ session()->get('success') }}
- </div><br />
- @endif
- <dd>Primero selecciona un plato: </dd>
- <select class="custom-select">
- <option selected>[ SELECCIONA UN PLATO ]</option>
- <option value="$plato->id">{{ $plato->nombre }}</option>
- <option value="2">Two</option>
- <option value="3">Three</option>
- </select>
- </div>
- </div>
- </div>
- @foreach($platos as $plato)
- <option value=">{{ $plato->nombre }}">{{ $plato->nombre }}</option>
- @endofeach
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement