jeudi 8 juillet 2021

not pass some values

i can't find the error by myself, when inserting records, pass two values as null

Database:

Controller:

  public function cobrar(Request $request,$id){

    $data = [
        'category_name' => 'datatable',
        'page_name' => 'custom',
    'has_scrollspy' => 0,
    'scrollspy_offset' => '',

    ];
    $cliente = \App\Models\Eventos::first();
    $cobros = \App\Models\Cobros::where('turno_id',  $request->id)->first();
    $evento = \App\Models\Eventos::where('id' , $id)->with('servicio')->first();
    $servicio = \App\Models\Servicios::where('id', $evento->servicio_id)->first();
    $event = \App\Models\Eventos::find($id);

   
 
    if ($request->isMethod('post')) {
        Cobros::insert([
            'fpago'       => $request->input("fpago"),
            'deuda'       => $request->input("deuda"),
            'turno_id'       => $request->input("turno_id"),
            'importe'       => $request->input("importe"),
            'servicio_id'       => $request->input("servicio_id"),
          ]);

       
     
    }
   



    return view('cobrar',compact('cobros', 'evento', 'servicio', 'event'))->with($data);

  }

Blade.php:

 <form method="POST" action="">
              
@csrf

 
  <div class="row">
    <div class="col">
    <h5 class="text-white mt-2"> </h5>
    </div>
    <div class="col">
    <div class="input-group mb-4">


  <div class="input-group-prepend">

    <span class="input-group-text">$</span>
  </div>
  <input type="hidden" value="" name="servicio_id">
  <input type="hidden" value="" name="turno_id">
  <input type="text"  name="importe" value="" class="form-control col-md-3" aria-label="Amount (to the nearest dollar)">
  <div class="input-group-append">
    <span class="input-group-text"></span>
  </div>
    </div>
  </div>
  </div>
<hr>


<div class="row">
    <div class="col">
     <h5>Formas de Pago</h5> 
    </div>
    <div class="col">
    <label  class="switch s-outline s-outline-success  mb-4 mr-2">
    <input type="checkbox" id="alternar">
    <span class="slider round"></span>
</label>
    </div>
  </div>


  <div id="prueba">

  <div class="container">
     <div class="widget-content widget-content-area">
                                    <p>Seleccione la forma de pago adecuada.</p>
                                    <select name="fpago" value="efectivo" class="placeholder js-states form-control">
                                        <option>Selecionar...</option>
                                        <option value="efectivo">Efectivo</option>
                                        <option value="mercadopago">MercadoPago</option>
                                        <option value="tarjeta">Pago con Tarjeta</option>
                                    </select>

                                  

                                </div>
  </div>






  </div>



  <hr>

  <div class="row">
    <div class="col">
     <h5>¿Cliente Adeuda?</h5> 
    </div>
    <div class="col">
    <label class="switch s-outline s-outline-info  mb-4 mr-2">
    <input name="deuda" value="adeuda" type="checkbox">
    <span class="slider round"></span>
</label>
    </div>
  </div>

<hr>

<div class="row">
    <div class="col">
     <h5>--------------</h5> 
    </div>
    <div class="col">
    <input type="submit" class="btn btn-outline-success mb-2" value="Cobrar">
    </div>
  </div>
  </form>

Model:

   <?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Cobros extends Model
{
    protected $table= 'cobros';

    //
    protected $fillable = [
        'importe', 'turno_id', 'servicio_id', 'deuda', 'fpago', 
    ];

    public function eventos()
    {
        return $this->belongsTo(Eventos::class);
    }
}

column deuda and fpago are the ones that always pass null

the other columns if you pass them correctly

i need help to find the error maybe it's something simple, I don't have more details to add



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3hR9Lyj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire