My approved not working in laravel with update









up vote
0
down vote

favorite












When a user click on approved button, open a modal bootstrap. in modal has a select option, that select a user inspector . but it is not saving in database.
I guess it has something to do with that fact that im trying to update an entry on the same page? Here is my Code:



After click on approved button



Approved



it be must approved = 1 and inspector user = 4



My blade



@extends('Admin.master')

@section('style')
<link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
@endsection

@section('content')

<div class="col-md-10">
<div class="panel panel-default">
<div class="panel-heading main-color-bg">
<h3 class="panel-title">List of Requisitions</h3>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>School Name</th>
<th>Requisition Code</th>
<th>Activity</th>
<th>Telephone</th>
<th>Requisition Type</th>
<th>Requisition Status</th>
<th>Display Details</th>
</tr>
</thead>
<tbody>
@forelse ($requisitions as $requisition)
@forelse($requisition->activities as $activity)
<tr>
<td> $requisition->schools->school_name </td>
<td class="translate"> $requisition->id </td>
<td> $activity->group->group_name </td>
<td> $requisition->schools->type </td>
<td class="translate"> $requisition->schools->phone </td>
<td> $requisition->schools->type </td>
<td>
<div class="btn-group btn-group-xs">
<a class="btn btn-success btn-xs" data-toggle="modal" data-target="#requisition">Approved</a>
<form class="btn-group" action=" route('requisitions.unapproved', ['id' => $requisition->id]) " method="post">
method_field('PATCH')
csrf_field()
<button type="submit" class="btn btn-danger btn-xs">Disapproval</button>
</form>
</div>
</td>
@empty
Please go to back
@endforelse
@empty
Please go to back
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>

<div class="modal fade" id="requisition" tabindex="-1" role="dialog">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<form action=" route('requisitions.update', ['id' => $requisition->id]) " method="post">
method_field('PATCH')
csrf_field()
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">List of inspection</h4>
</div>
<div class="modal-body">
<select class="form-control" name="inspector_user_id">
@foreach($users as $user)
<option value=" $user->id "> $user->first_name $user->last_name </option>
@endforeach
</select>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>

@endsection

@section('script')
<script src="https://unpkg.com/sweetalert2@7.18.0/dist/sweetalert2.all.js"></script>
@endsection


Controller



public function update(Request $request, $requisition)

$approved = Requisition::findOrFail($requisition);
$approved->approved = 1;
$approved->inspector_user_id = $request->input('inspector_user_id');
$approved->save();
alert()->success('It done', 'OK')->persistent('OK');
return redirect()->back();


public function unapproved(Request $request, $id)

$unApproved = Requisition::findOrFail($id);
$unApproved->approved = 0;
$unApproved->save();
alert()->success('It done', 'Cancel')->persistent('OK');
return redirect()->back();



web.php



Route::resource('requisitions', 'RequisitionController');









share|improve this question

























    up vote
    0
    down vote

    favorite












    When a user click on approved button, open a modal bootstrap. in modal has a select option, that select a user inspector . but it is not saving in database.
    I guess it has something to do with that fact that im trying to update an entry on the same page? Here is my Code:



    After click on approved button



    Approved



    it be must approved = 1 and inspector user = 4



    My blade



    @extends('Admin.master')

    @section('style')
    <link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
    @endsection

    @section('content')

    <div class="col-md-10">
    <div class="panel panel-default">
    <div class="panel-heading main-color-bg">
    <h3 class="panel-title">List of Requisitions</h3>
    </div>
    </div>
    <div class="panel panel-default">
    <div class="panel-body">
    <div class="table-responsive">
    <table class="table">
    <thead>
    <tr>
    <th>School Name</th>
    <th>Requisition Code</th>
    <th>Activity</th>
    <th>Telephone</th>
    <th>Requisition Type</th>
    <th>Requisition Status</th>
    <th>Display Details</th>
    </tr>
    </thead>
    <tbody>
    @forelse ($requisitions as $requisition)
    @forelse($requisition->activities as $activity)
    <tr>
    <td> $requisition->schools->school_name </td>
    <td class="translate"> $requisition->id </td>
    <td> $activity->group->group_name </td>
    <td> $requisition->schools->type </td>
    <td class="translate"> $requisition->schools->phone </td>
    <td> $requisition->schools->type </td>
    <td>
    <div class="btn-group btn-group-xs">
    <a class="btn btn-success btn-xs" data-toggle="modal" data-target="#requisition">Approved</a>
    <form class="btn-group" action=" route('requisitions.unapproved', ['id' => $requisition->id]) " method="post">
    method_field('PATCH')
    csrf_field()
    <button type="submit" class="btn btn-danger btn-xs">Disapproval</button>
    </form>
    </div>
    </td>
    @empty
    Please go to back
    @endforelse
    @empty
    Please go to back
    @endforelse
    </tbody>
    </table>
    </div>
    </div>
    </div>
    </div>

    <div class="modal fade" id="requisition" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-sm" role="document">
    <div class="modal-content">
    <form action=" route('requisitions.update', ['id' => $requisition->id]) " method="post">
    method_field('PATCH')
    csrf_field()
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title">List of inspection</h4>
    </div>
    <div class="modal-body">
    <select class="form-control" name="inspector_user_id">
    @foreach($users as $user)
    <option value=" $user->id "> $user->first_name $user->last_name </option>
    @endforeach
    </select>
    </div>
    <div class="modal-footer">
    <button type="submit" class="btn btn-primary">Save</button>
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    </div>
    </form>
    </div>
    </div>
    </div>

    @endsection

    @section('script')
    <script src="https://unpkg.com/sweetalert2@7.18.0/dist/sweetalert2.all.js"></script>
    @endsection


    Controller



    public function update(Request $request, $requisition)

    $approved = Requisition::findOrFail($requisition);
    $approved->approved = 1;
    $approved->inspector_user_id = $request->input('inspector_user_id');
    $approved->save();
    alert()->success('It done', 'OK')->persistent('OK');
    return redirect()->back();


    public function unapproved(Request $request, $id)

    $unApproved = Requisition::findOrFail($id);
    $unApproved->approved = 0;
    $unApproved->save();
    alert()->success('It done', 'Cancel')->persistent('OK');
    return redirect()->back();



    web.php



    Route::resource('requisitions', 'RequisitionController');









    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      When a user click on approved button, open a modal bootstrap. in modal has a select option, that select a user inspector . but it is not saving in database.
      I guess it has something to do with that fact that im trying to update an entry on the same page? Here is my Code:



      After click on approved button



      Approved



      it be must approved = 1 and inspector user = 4



      My blade



      @extends('Admin.master')

      @section('style')
      <link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
      @endsection

      @section('content')

      <div class="col-md-10">
      <div class="panel panel-default">
      <div class="panel-heading main-color-bg">
      <h3 class="panel-title">List of Requisitions</h3>
      </div>
      </div>
      <div class="panel panel-default">
      <div class="panel-body">
      <div class="table-responsive">
      <table class="table">
      <thead>
      <tr>
      <th>School Name</th>
      <th>Requisition Code</th>
      <th>Activity</th>
      <th>Telephone</th>
      <th>Requisition Type</th>
      <th>Requisition Status</th>
      <th>Display Details</th>
      </tr>
      </thead>
      <tbody>
      @forelse ($requisitions as $requisition)
      @forelse($requisition->activities as $activity)
      <tr>
      <td> $requisition->schools->school_name </td>
      <td class="translate"> $requisition->id </td>
      <td> $activity->group->group_name </td>
      <td> $requisition->schools->type </td>
      <td class="translate"> $requisition->schools->phone </td>
      <td> $requisition->schools->type </td>
      <td>
      <div class="btn-group btn-group-xs">
      <a class="btn btn-success btn-xs" data-toggle="modal" data-target="#requisition">Approved</a>
      <form class="btn-group" action=" route('requisitions.unapproved', ['id' => $requisition->id]) " method="post">
      method_field('PATCH')
      csrf_field()
      <button type="submit" class="btn btn-danger btn-xs">Disapproval</button>
      </form>
      </div>
      </td>
      @empty
      Please go to back
      @endforelse
      @empty
      Please go to back
      @endforelse
      </tbody>
      </table>
      </div>
      </div>
      </div>
      </div>

      <div class="modal fade" id="requisition" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-sm" role="document">
      <div class="modal-content">
      <form action=" route('requisitions.update', ['id' => $requisition->id]) " method="post">
      method_field('PATCH')
      csrf_field()
      <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <h4 class="modal-title">List of inspection</h4>
      </div>
      <div class="modal-body">
      <select class="form-control" name="inspector_user_id">
      @foreach($users as $user)
      <option value=" $user->id "> $user->first_name $user->last_name </option>
      @endforeach
      </select>
      </div>
      <div class="modal-footer">
      <button type="submit" class="btn btn-primary">Save</button>
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
      </form>
      </div>
      </div>
      </div>

      @endsection

      @section('script')
      <script src="https://unpkg.com/sweetalert2@7.18.0/dist/sweetalert2.all.js"></script>
      @endsection


      Controller



      public function update(Request $request, $requisition)

      $approved = Requisition::findOrFail($requisition);
      $approved->approved = 1;
      $approved->inspector_user_id = $request->input('inspector_user_id');
      $approved->save();
      alert()->success('It done', 'OK')->persistent('OK');
      return redirect()->back();


      public function unapproved(Request $request, $id)

      $unApproved = Requisition::findOrFail($id);
      $unApproved->approved = 0;
      $unApproved->save();
      alert()->success('It done', 'Cancel')->persistent('OK');
      return redirect()->back();



      web.php



      Route::resource('requisitions', 'RequisitionController');









      share|improve this question













      When a user click on approved button, open a modal bootstrap. in modal has a select option, that select a user inspector . but it is not saving in database.
      I guess it has something to do with that fact that im trying to update an entry on the same page? Here is my Code:



      After click on approved button



      Approved



      it be must approved = 1 and inspector user = 4



      My blade



      @extends('Admin.master')

      @section('style')
      <link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
      @endsection

      @section('content')

      <div class="col-md-10">
      <div class="panel panel-default">
      <div class="panel-heading main-color-bg">
      <h3 class="panel-title">List of Requisitions</h3>
      </div>
      </div>
      <div class="panel panel-default">
      <div class="panel-body">
      <div class="table-responsive">
      <table class="table">
      <thead>
      <tr>
      <th>School Name</th>
      <th>Requisition Code</th>
      <th>Activity</th>
      <th>Telephone</th>
      <th>Requisition Type</th>
      <th>Requisition Status</th>
      <th>Display Details</th>
      </tr>
      </thead>
      <tbody>
      @forelse ($requisitions as $requisition)
      @forelse($requisition->activities as $activity)
      <tr>
      <td> $requisition->schools->school_name </td>
      <td class="translate"> $requisition->id </td>
      <td> $activity->group->group_name </td>
      <td> $requisition->schools->type </td>
      <td class="translate"> $requisition->schools->phone </td>
      <td> $requisition->schools->type </td>
      <td>
      <div class="btn-group btn-group-xs">
      <a class="btn btn-success btn-xs" data-toggle="modal" data-target="#requisition">Approved</a>
      <form class="btn-group" action=" route('requisitions.unapproved', ['id' => $requisition->id]) " method="post">
      method_field('PATCH')
      csrf_field()
      <button type="submit" class="btn btn-danger btn-xs">Disapproval</button>
      </form>
      </div>
      </td>
      @empty
      Please go to back
      @endforelse
      @empty
      Please go to back
      @endforelse
      </tbody>
      </table>
      </div>
      </div>
      </div>
      </div>

      <div class="modal fade" id="requisition" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-sm" role="document">
      <div class="modal-content">
      <form action=" route('requisitions.update', ['id' => $requisition->id]) " method="post">
      method_field('PATCH')
      csrf_field()
      <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <h4 class="modal-title">List of inspection</h4>
      </div>
      <div class="modal-body">
      <select class="form-control" name="inspector_user_id">
      @foreach($users as $user)
      <option value=" $user->id "> $user->first_name $user->last_name </option>
      @endforeach
      </select>
      </div>
      <div class="modal-footer">
      <button type="submit" class="btn btn-primary">Save</button>
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
      </form>
      </div>
      </div>
      </div>

      @endsection

      @section('script')
      <script src="https://unpkg.com/sweetalert2@7.18.0/dist/sweetalert2.all.js"></script>
      @endsection


      Controller



      public function update(Request $request, $requisition)

      $approved = Requisition::findOrFail($requisition);
      $approved->approved = 1;
      $approved->inspector_user_id = $request->input('inspector_user_id');
      $approved->save();
      alert()->success('It done', 'OK')->persistent('OK');
      return redirect()->back();


      public function unapproved(Request $request, $id)

      $unApproved = Requisition::findOrFail($id);
      $unApproved->approved = 0;
      $unApproved->save();
      alert()->success('It done', 'Cancel')->persistent('OK');
      return redirect()->back();



      web.php



      Route::resource('requisitions', 'RequisitionController');






      laravel-5.4






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 21:08









      Mahmoud Khosravi

      5618




      5618



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233288%2fmy-approved-not-working-in-laravel-with-update%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233288%2fmy-approved-not-working-in-laravel-with-update%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo