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
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">×</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
add a comment |
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
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">×</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
add a comment |
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
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">×</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
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
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">×</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
laravel-5.4
asked Nov 9 at 21:08
Mahmoud Khosravi
5618
5618
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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