Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. <?php
  2.  
  3. use IlluminateSupportFacadesSchema;
  4. use IlluminateDatabaseSchemaBlueprint;
  5. use IlluminateDatabaseMigrationsMigration;
  6.  
  7. class CreatePlatosTable extends Migration
  8. {
  9. /**
  10. * Run the migrations.
  11. *
  12. * @return void
  13. */
  14. public function up()
  15. {
  16. Schema::create('platos', function (Blueprint $table) {
  17. $table->increments('id');
  18. $table->char('nombre',50);
  19. $table->double('valor', 8, 2);
  20. $table->timestamps();
  21. });
  22. }
  23.  
  24. /**
  25. * Reverse the migrations.
  26. *
  27. * @return void
  28. */
  29. public function down()
  30. {
  31. Schema::dropIfExists('platos');
  32. }
  33. }
  34.  
  35. <?php
  36.  
  37. use IlluminateSupportFacadesSchema;
  38. use IlluminateDatabaseSchemaBlueprint;
  39. use IlluminateDatabaseMigrationsMigration;
  40.  
  41. class CreatePlatoIngredienteTable extends Migration
  42. {
  43. /**
  44. * Run the migrations.
  45. *
  46. * @return void
  47. */
  48. public function up()
  49. {
  50. Schema::create('platoIngrediente', function (Blueprint $table) {
  51. $table->increments('id');
  52. $table->unsignedInteger('plato_id');
  53. $table->foreign('plato_id')->references('id')->on('plato');
  54. $table->unsignedInteger('plato_id');
  55. $table->foreign('ingrediente_id')->references('id')->on('ingrediente');
  56. $table->double('cantidad', 8, 2);
  57. $table->timestamps();
  58. });
  59. }
  60.  
  61. /**
  62. * Reverse the migrations.
  63. *
  64. * @return void
  65. */
  66. public function down()
  67. {
  68. Schema::dropIfExists('platoIngrediente');
  69.  
  70. }
  71. }
  72.  
  73. <?php
  74.  
  75. namespace App;
  76.  
  77. use IlluminateDatabaseEloquentModel;
  78.  
  79. class PlatoIngrediente extends Model
  80. {
  81. public $table = "platoIngrediente";
  82.  
  83. protected $fillable = ['cantidad'];
  84.  
  85.  
  86. public function platos(){
  87. return $this->belongsTo('AppPlato','id_plato');
  88. }
  89.  
  90. public function ingredientes(){
  91. return $this->belongsTo('AppIngrediente','id_ingrediente');
  92. }
  93.  
  94. }
  95.  
  96. <?php
  97.  
  98. namespace AppHttpControllers;
  99.  
  100. use AppPlatoIngrediente;
  101. use IlluminateHttpRequest;
  102.  
  103. class PlatoIngredienteController extends Controller
  104. {
  105. /**
  106. * Display a listing of the resource.
  107. *
  108. * @return IlluminateHttpResponse
  109. */
  110. public function index()
  111. {
  112. $platoingrediente = PlatoIngrediente::all();
  113. return view('platoingrediente/index', compact('platoIngrediente'));
  114. }
  115.  
  116. /**
  117. * Show the form for creating a new resource.
  118. *
  119. * @return IlluminateHttpResponse
  120. */
  121. public function create()
  122. {
  123. return view('platoingrediente/create');
  124. }
  125.  
  126. /**
  127. * Store a newly created resource in storage.
  128. *
  129. * @param IlluminateHttpRequest $request
  130. * @return IlluminateHttpResponse
  131. */
  132. public function store(Request $request)
  133. {
  134. //
  135. }
  136.  
  137. /**
  138. * Display the specified resource.
  139. *
  140. * @param AppPlatoIngrediente $platoIngrediente
  141. * @return IlluminateHttpResponse
  142. */
  143. public function show($id)
  144. {
  145. //
  146. }
  147.  
  148. /**
  149. * Show the form for editing the specified resource.
  150. *
  151. * @param AppPlatoIngrediente $platoIngrediente
  152. * @return IlluminateHttpResponse
  153. */
  154. public function edit($id)
  155. {
  156. //
  157. }
  158.  
  159. /**
  160. * Update the specified resource in storage.
  161. *
  162. * @param IlluminateHttpRequest $request
  163. * @param AppPlatoIngrediente $platoIngrediente
  164. * @return IlluminateHttpResponse
  165. */
  166. public function update(Request $request, $id)
  167. {
  168. //
  169. }
  170.  
  171. public function formulario(){
  172. $platos = Platos::with('platos','ingredientes')->get();
  173. return view('/platoingrediente/index', compact('$platos'));
  174.  
  175. }
  176.  
  177. /**
  178. * Remove the specified resource from storage.
  179. *
  180. * @param AppPlatoIngrediente $platoIngrediente
  181. * @return IlluminateHttpResponse
  182. */
  183. public function destroy($id)
  184. {
  185. //
  186. }
  187. }
  188.  
  189. <div class="up sombra card">
  190. <div class="card-header">
  191. Creacion del plato
  192. </div>
  193. <div class="card-body">
  194. <div class="up">
  195. @if(session()->get('success'))
  196. <div class="alert alert-success">
  197. {{ session()->get('success') }}
  198. </div><br />
  199. @endif
  200.  
  201.  
  202. <dd>Primero selecciona un plato: </dd>
  203. <select class="custom-select">
  204.  
  205. <option selected>[ SELECCIONA UN PLATO ]</option>
  206. <option value="$plato->id">{{ $plato->nombre }}</option>
  207. <option value="2">Two</option>
  208. <option value="3">Three</option>
  209.  
  210. </select>
  211. </div>
  212. </div>
  213. </div>
  214.  
  215. @foreach($platos as $plato)
  216. <option value=">{{ $plato->nombre }}">{{ $plato->nombre }}</option>
  217. @endofeach
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement