vendredi 24 mars 2017

Laravel 5.3 Update data base record with button

Hello i am learning Laravel at collage got my project simple open ticket system which has users roles and tickets for broken inventory. When subbmited ticket it must be seen by worker and acssepted by pressing button (Priimti) i done .blade form

<div class="row">

  <h3>Viso gedimų:  </h3>
  <!-- Table -->
  <table class="table table-condensed">
    <thead>
      <th>Numeris</th>
      <th>Aprašymas</th>
      <th>Korpusas</th>
      <th>Meistras</th>
      <th>Priimta</th>
      <th>Atlikta</th>
      <th>Data</th>
      <th></th>
    </thead>
    <tbody>

      @foreach($gedimai as $gedimas)
      <tr>
        <form action="" method="post">
          <td></td>
          <td></td>
          <td> </td>
          <td></td>


          <td>
            <td> <input type="hidden" name="priimta" value=""> </td>
            @if ($gedimas->priimta == '0')
            <span class="label label-warning">Naujas</span> 
            <td><button type="submit">Priimti</button></td>
        </form>
        @else
        <span class="label label-success"> Priimtas</span> @endif

        </td>


        <td> @if ($gedimas->priimta == '0' AND $gedimas->priimta == '0')

          <span class="label label-info"> - </span> @elseif ($gedimas->atlikta == '0')
          <span class="label label-warning">Taisoma</span>
          <input type="hidden" name="id" type="POST" value="gedimas.atlikta"> 
          <td><button type="submit">Atlikta</button></td>

          @else
          <span class="label label-success"> Gedimas pašalintas</span> @endif
        </td>

        <td></td>
      </tr>
      @endforeach 
    </tbody>
  </table>

</div>
@endsection

added to GedimasController function to accsept (priimti)

       public function priimti(Request $request)
    {

$id = Gedimas::where('id', $request['id'])->first();
         $id = $request->get('id');
          DB::table('gedimas')
            ->where('id', '=', $id)
            ->update(['priimta' => $request->status, 'priimta' => 1]);
        

return redirect()->back();
        
        }

and added route

Route::post('/pranesti', ['uses' => 'GedimasController@store']);

but unfotianatly it will not updating database row priimta which is boolean with default value "0" i just need to make it "1".

Thank you.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2o0dCMQ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire