My Images getting smaller in next page - DOMPDF - php

Here's the first page
Here's the second page, the image is getting smaller
Created with DOMPDF and Laravel, the first page, my image is fine, but when the second page is getting smaller, i don't know why.. i've been trying to use div, but its still not working
i'm using table and here's my code
<table>
<tbody>
<tr>
<td>
<img src="{{$content['image2']}}" class="img kecil" />
</td>
<td>
{!! $content['paragraph2'] !!}
</td>
</tr>
<tr>
<td>
<img src="{{$content['image2']}}" class="img kecil" />
</td>
<td>
{!! $content['paragraph2'] !!}
</td>
</tr>
<tr>
<td>
<img src="{{$content['image2']}}" class="img kecil" />
</td>
<td>
{!! $content['paragraph2'] !!}
</td>
</tr>
<tr>
<td>
<img src="{{$content['image2']}}" class="img kecil" />
</td>
<td>
{!! $content['paragraph2'] !!}
</td>
</tr>
<tr>
<td>
<img src="{{$content['image2']}}" class="img kecil" />
</td>
<td>
{!! $content['paragraph2'] !!}
</td>
</tr>
<tr>
<td>
<img src="{{$content['image2']}}" class="img kecil" />
</td>
<td>
{!! $content['paragraph2'] !!}
</td>
</tr>
</tbody>
</table>
I also using bootstrap, what should i do to fix this? Thanks

Related

Using inline css with DomPDF and Laravel

I am having a problem with my inline css. So, I am trying to add a border under the data rendered from the database. The problem is the rendered data is under the name, the How can I move the border-bottom and the rendered data at the right of the word "Name"?
here's the html code
<table style="border:none;border-collapse: collapse;font-size:12px;text-align: left;">
<tr>
<td colspan="3"><b>I. PERSONAL AND FAMILY DATA</b></td><td colspan="2"><b>Date today</b> <u>{{ \Carbon\Carbon::parse($infomodel->date_last_updated)->format('m-d-Y') }}</u></td>
</tr>
<tr >
<td colspan="3"><b>Name </b><div style="border-bottom:.7px solid black;height:15px;padding:0px;width:290px;overflow:hidden;">{!! $usermodel->last_name !!}, {!! $usermodel->first_name!!} {!! $usermodel->middle_name !!}.
</div>
</td>
<td colspan="2"><b>Sex </b><u>{!! $infomodel->gender !!}</u></td>
</tr>
<tr>
<td colspan="5"><b>Home Address </b><div style="border-bottom:.7px solid black;height:15px;padding:0px;width:450px;overflow:hidden;">{!! $infomodel->mailing_address !!}
</div>
</td>
</tr>
</table><br />
Here is the pdf view
Print the output in the styled element. And make the element to an inline element.
Example:
Change this :
<td colspan="3"><b>Name </b><div style="border-bottom:.7px solid black;height:15px;padding:0px;width:290px;overflow:hidden;">{!! $usermodel->last_name !!}, {!! $usermodel->first_name!!} {!! $usermodel->middle_name !!}.
</div>
</td>
to this:
<td colspan="3"><b>Name </b>
<div style="display: inline; border-bottom:.7px solid black;height:15px;padding:0px;width:290px;overflow:hidden;">{!! $usermodel->last_name !!}, {!! $usermodel->first_name!!} {!! $usermodel->middle_name !!}.
</div>
</td>
<table style="border:none;border-collapse: collapse;font-size:12px;text-align: left;">
<tr>
<td colspan="3"><b>I. PERSONAL AND FAMILY DATA</b></td><td colspan="2"><b>Date today</b> <u>{{ \Carbon\Carbon::parse($infomodel->date_last_updated)->format('m-d-Y') }}</u></td>
</tr>
<tr >
<td colspan="3"><b>Name </b><div style="display: inline; border-bottom:.7px solid black;height:10px;padding:0px;width:290px;overflow:hidden;">
{!! $usermodel->last_name !!}, {!! $usermodel->first_name!!} {!! $usermodel->middle_name !!}.
</div>
</td>
<td colspan="2"><b>Sex </b><u>{!! $infomodel->gender !!}</u></td>
</tr>
<tr>
<td colspan="5"><b>Home Address </b>{!! $infomodel->mailing_address !!}
<div style="border-bottom:.7px solid black;height:15px;padding:0px;width:450px;overflow:hidden;">
</div>
</td>
</tr>
</table><br />

Laravel: How to show form after submission?

I am new to Laravel and currently working on a project where the guests enter form data for booking a room in a hotel and after submitting it, they will be redirected to a page showing their booking they have just done. I know this can be done by allowing guests to create login account but my project requires login only for the backend(admin). (Q2.)Also the guests can view booking by entering the booking ID and their last name.
My controller:
public function store(Request $request)
{
$book = new book();
$book->title = $request->input('title');
$book->fname = $request->input('firstname');
$book->lname = $request->input('lastname');
$book->country = $request->input('country');
$book->phone = $request->input('phone');
$book->email = $request->input('email');
$book->no_rooms = $request->input('no_rooms');
$book->room_type_id = $request->input('type_room');
$book->no_adults = $request->input('adults');
$book->no_children = $request->input('children');
$book->meal_id = $request->input('meal');
$book->check_in = $request->input('check_in');
$book->check_out = $request->input('check_out');
$book->save();
}
public function show(book $book)
{
return view('book.show', compact('book'));
}
The way I want it to display after it has been submitted:
<div class="row">
<div class="col-6">
<table class="table table-striped text-dark">
<tbody>
<tr>
<td> Name: </td>
<td> {{$book->title}} {{$book->firstname}} {{$book->lastname}} </td>
</tr>
<tr>
<td> Phone </td>
<td> {{$book->phone}} </td>
</tr>
<tr>
<td> Email </td>
<td> {{$book->email}} </td>
</tr>
<tr>
<td> Phone </td>
<td> {{$book->phone}} </td>
</tr>
<tr>
<td> Passport Issued: </td>
<td> {{$book->country}} </td>
</tr>
<tr>
<td> Number of rooms: </td>
<td> {{$book->no_rooms}} </td>
</tr>
<tr>
<td> Room Type </td>
<td> {{$book->type_room}} </td>
</tr>
<tr>
<td> No of adults: </td>
<td> {{$book->adults}} </td>
</tr><tr>
<td> No of children: </td>
<td> {{$book->children}} </td>
</tr>
<tr>
<td> Meal plan: </td>
<td> {{$book->meals_id}} </td>
</tr>
<tr>
<td> Check-in: </td>
<td> {{$book->check_in}} </td>
</tr>
<tr>
<td> Check-out: </td>
<td> {{$book->check_out}} </td>
</tr>
</tbody>
</table>
</div>
</div>
You can redirect to the show method from the bottom of your store method:
// Replace MyController with the name of your controller
return redirect()->action(
'MyController#show', ['book' => $book]
);
For more information check out the documentation: https://laravel.com/docs/master/redirects#redirecting-controller-actions
If I understand correctly your situation, you wish to show the same data introduced by the user after form submission.
I can think that redirecting to a page that show your div without anything else, is not enough. You'll still need to access to data entered in the form.
Laravel store form data in a session variable called old, according to documentation, that variable should be available during next request after submission, so you could try to get data using
<table class="table table-striped text-dark">
<tbody>
<tr>
<td> Name: </td>
<td> {{ old('title') }} {{ old('firstname') }} {{ old('lastname') }} </td>
</tr>
<tr>
<td> Phone </td>
<td> {{ old('phone') }} </td>
</tr>
<tr>
<td> Email </td>
<td> {{ old('email') }} </td>
</tr>
<tr>
<td> Phone </td>
<td> {{ old('phone') }} </td>
</tr>
<tr>
<td> Passport Issued: </td>
<td> {{ old('country') }} </td>
</tr>
<tr>
<td> Number of rooms: </td>
<td> {{ old('no_rooms') }} </td>
</tr>
<tr>
<td> Room Type </td>
<td> {{ old('type_room') }} </td>
</tr>
<tr>
<td> No of adults: </td>
<td> {{ old('adults') }} </td>
</tr><tr>
<td> No of children: </td>
<td> {{ old('children') }} </td>
</tr>
<tr>
<td> Meal plan: </td>
<td> {{ old('meals_id') }} </td>
</tr>
<tr>
<td> Check-in: </td>
<td> {{ old('check_in') }} </td>
</tr>
<tr>
<td> Check-out: </td>
<td> {{ old('check_out') }} </td>
</tr>
</tbody>
</table>
Just in case that you don't have old data available in your session because a successive redirect, you should inject that data in your session using flash.
You can find more detailed information here, in laravel documentation
You can just use the laravel helper redirect()
return redirect()->route('route name here');
or
return redirect('your-form-path');
read more here: laravel http redirects

Route not working(showing blank page) in Laravel

I'm new to Laravel. I'm getting this issue from a long while. I've added a route to a page in web.php but it is showing a blank page instead of going to that page.
Here are the routes in web.php:
Route::group(['middleware' => ['auth','admin']], function() {
//For Admin Dashboard
Route::get('/dashboard', function () {
return view('admin.dashboard');
});
//For listing users
Route::get('/users-list', function () {
return view('admin.users');
});
});
The users-list route is not working. The users.blade.php file is placed in admin folder.
I'm trying to add the path directory to url but still not working. Here is another thing I'm trying.
Navbar
<li>
<!-- <a href="{{ url('/admin/users') }}"> -->
<a href="{{ url('/users-list') }}">
<i class="now-ui-icons users_single-02"></i>
<p>Users Profiles</p>
</a>
</li>
Here is my views directory
I'm trying to access it from here but still no results, same blank page. There's something wrong which I'm not able to find out. Any suggestion will be highly appreciated.
I'll be happy to provide any sorts of other details if required.
Replace your route with below route code:
Route::get('users-list', function () {
return view('admin/users');
});
Blade file code:
<li>
<!-- <a href="{{ url('/admin/users') }}"> -->
<a href="{{ url('users-list') }}">
<i class="now-ui-icons users_single-02"></i>
<p>Users Profiles</p>
</a>
</li>
just change your url in this way
Navbar
<li>
<a href="{{ url('/admin/users-list') }}">
<i class="now-ui-icons users_single-02"></i>
<p>Users Profiles</p>
</a>
Alright everyone, thanks alot for your answers and suggestions. I think I have found my issue.
I was using a layout file for dashboard.blade.php and users-list.blade.php named master.blade.php. And issue was in that file as it was not displaying output. I've corrected it and it worked.
Here is my users.blade.php
#extends('layouts.master')
#section('title')
Users Profiles | TestWeb
#endsection
#section('content')
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4 class="card-title"> Simple Table</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="card card-plain">
<div class="card-header">
<h4 class="card-title"> Table on Plain Background</h4>
<p class="category"> Here is a subtitle for this table</p>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
#endsection
And #extends('layouts.master')
#section('title')
Users Profiles | TestWeb
#endsection
#section('content')
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4 class="card-title"> Simple Table</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="card card-plain">
<div class="card-header">
<h4 class="card-title"> Table on Plain Background</h4>
<p class="category"> Here is a subtitle for this table</p>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
#endsection
And master.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="apple-touch-icon" sizes="76x76" href="/assets/img/apple-icon.png">
<link rel="icon" type="image/png" href="/assets/img/favicon.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>
#yield('title')
</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' />
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<!-- CSS Files -->
<link href="{{ asset('assets/css/bootstrap.min.css') }}" rel="stylesheet" />
<link href="{{ asset('assets/css/now-ui-dashboard.css?v=1.3.0') }}" rel="stylesheet" />
<!-- CSS Just for demo purpose, don't include it in your project -->
<link href="{{ asset('assets/demo/demo.css') }}" rel="stylesheet" />
</head>
<body class="">
<div class="wrapper ">
<div class="sidebar" data-color="orange">
<!--
Tip 1: You can change the color of the sidebar using: data-color="blue | green | orange | red | yellow"
-->
<div class="logo">
<a href="http://www.creative-tim.com" class="simple-text logo-normal">
| TestWeb |
</a>
</div>
<div class="sidebar-wrapper" id="sidebar-wrapper">
#include('inc.admin_navbar')
</div>
</div>
<div class="main-panel" id="main-panel">
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-transparent bg-primary navbar-absolute">
<div class="container-fluid">
<div class="navbar-wrapper">
<div class="navbar-toggle">
<button type="button" class="navbar-toggler">
<span class="navbar-toggler-bar bar1"></span>
<span class="navbar-toggler-bar bar2"></span>
<span class="navbar-toggler-bar bar3"></span>
</button>
</div>
<a class="navbar-brand" href="#pablo">Table List</a>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigation" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-bar navbar-kebab"></span>
<span class="navbar-toggler-bar navbar-kebab"></span>
<span class="navbar-toggler-bar navbar-kebab"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navigation">
<form>
<div class="input-group no-border">
<input type="text" value="" class="form-control" placeholder="Search...">
<div class="input-group-append">
<div class="input-group-text">
<i class="now-ui-icons ui-1_zoom-bold"></i>
</div>
</div>
</div>
</form>
<ul class="navbar-nav">
<!-- Logout Button Starts -->
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
#csrf
</form>
</div>
</li>
<!-- Logout Button Ends -->
</ul>
</div>
</div>
</nav>
<!-- End Navbar -->
<div class="panel-header panel-header-sm">
</div>
<div class="content">
#yield('content')
</div>
<footer class="footer">
<div class="container-fluid">
<nav>
<ul>
<li>
<a href="#">
TestWeb
</a>
</li>
<li>
<a href="#">
About Us
</a>
</li>
<li>
<a href="#">
Blog
</a>
</li>
</ul>
</nav>
<div class="copyright" id="copyright">
<script>
document.getElementById('copyright').appendChild(document.createTextNode(new Date().getFullYear()))
</script>
</div>
</div>
</footer>
</div>
</div>
<!-- Core JS Files -->
<script src="{{ asset('assets/js/core/jquery.min.js') }}"></script>
<script src="{{ asset('assets/js/core/popper.min.js') }}"></script>
<script src="{{ asset('assets/js/core/bootstrap.min.js') }}"></script>
<script src="{{ asset('assets/js/plugins/perfect-scrollbar.jquery.min.js') }}"></script>
<!-- Google Maps Plugin -->
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE"></script>
<!-- Chart JS -->
<script src="{{ asset('assets/js/plugins/chartjs.min.js') }}"></script>
<!-- Notifications Plugin -->
<script src="{{ asset('assets/js/plugins/bootstrap-notify.js') }}"></script>
<!-- Control Center for Now Ui Dashboard: parallax effects, scripts for the example pages etc -->
<script src="{{ asset('assets/js/now-ui-dashboard.min.js?v=1.3.0') }}" type="text/javascript"></script>
<!-- Now Ui Dashboard DEMO methods, don't include it in your project! -->
<script src="{{ asset('assets/demo/demo.js') }}"></script>
</body>
</html>

laravel Parse error on view

I'm getting Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ')' on my view file. This is my controller:
public function gclogs()
{
$gclogs = DB::table('duplicategcs')->orderBy('created_at', 'desc')->paginate(20);
return view('admin.gclogs')->with('gclogs',$gclogs);
}
and this is just a snippet from view:
#foreach($gclogs as $gclog)
<tr>
<td>
{{gclog->id}}
</td>
<td>
{{gclog->user_id}}
</td>
<td>
{{gclog->google_id}}
</td>
<td>
{{gclog->google_email}}
</td>
<td>
{{gclog->created_at}}
</td>
<td>
User Edit
</td>
</tr>
#endforeach
</tbody>
</table>
<div align="center">
{{ $gclogs->render() }}
</div>
You forget use $ inside foreach.
Try this:
#foreach($gclogs as $gclog)
<tr>
<td>
{{$gclog->id}}
</td>
<td>
{{$gclog->user_id}}
</td>
<td>
{{$gclog->google_id}}
</td>
<td>
{{$gclog->google_email}}
</td>
<td>
{{$gclog->created_at}}
</td>
<td>
User Edit
</td>
</tr>
#endforeach
</tbody>
</table>
<div align="center">
{{ $gclogs->render() }}
</div>

Update multiple data from <select> <option> in database using laravel 5.1

i have some coding, i wanna to update multiple data from select option value in database using laravel 5.1. i'm using ajax onchange="form.submit()", so i can update data without submit.
this is my view
{!! Form::model($UserAccess,['method' => 'POST','url'=>['setting/updaterole']]) !!}
<table class="dataTable" id="table-user">
<thead class="grey lighten-3">
<tr>
<td class="center-align no-sort">Photo</td>
<td class="center-align">Fullname</td>
<td class="center-align">Rule</td>
<td class="center-align">Action</td>
</tr>
</thead>
<tbody>
<?php $hitung = $UserAccess->count(); ?>
#foreach($UserAccess as $list)
<tr>
<td class="center-align" width="50">
#if($list->avatar == NULL)
<img class="circle responsive-img" width="50" src="{{asset(config('param.url_uploads').'blank.jpg')}}"/>
#else
<img class="circle responsive-img" width="50" src="{{$list->avatar}}"/>
#endif
</td>
<td class="red1-text lato-bold center-align">{{$list->name}}</td>
<td class="center-align" width="150">
<select id="selectrole" name="selectrole" onchange="form.submit()">
#foreach($UserAccessRole as $listRole)
<option value="{{$listRole->id}}" #if($list->user_access_role_id_fk == $listRole->id) selected="selected"#endif>{{$listRole->name}}</option>
#endforeach
</select>
</td>
<input type = "hidden" value = "{{$list->id}}" name = "idmain">
#if($hitung > 2)
<td class="center-align">
<a href = "remove_access/{{$list->id}}/delete" >Remove Access<a/>
</td>
#else
<td class="center-align">Remove Access</td>
#endif
</tr>
#endforeach
</tbody>
</table>
{!! Form::close() !!}
this is my controller
public function doUpdateAccessRole(Request $request)
{
$UserAccess = UserAccess::orderBy('name', 'asc')->get();
$id_main = $request->input('idmain');
$id_role = $request->input('selectrole');
$Role = UserAccess::findOrFail($id_main);
$Role->user_access_role_id_fk = $id_role;
$Role->update($request->all());
return redirect('setting/useraccess');
}
this is my route
Route::post('setting/updaterole',['uses'=>'SettingController#doUpdateAccessRole','as'=>'updateaccessrole']);
using my coding update function already work, but just last id has been update. please help me, thank you
my code already work. just add foreach in my controller. like this, my controller :
public function doUpdateAccessRole(Request $request)
{
$UserAccess = UserAccess::all();
foreach($UserAccess as $list)
{
$id_main = $request->input('idmain'.$list->id);
$id_role = $request->input('selectrole'.$list->id);
$Role = UserAccess::find($id_main);
$Role->user_access_role_id_fk = $id_role;
$Role->update($request->all());
}
return redirect('setting/useraccess');
}
and this my view :
{!! Form::model($UserAccess,['method' => 'POST','url'=>['setting/updaterole']]) !!}
<table class="dataTable" id="table-user">
<thead class="grey lighten-3">
<tr>
<td class="center-align no-sort">Photo</td>
<td class="center-align">Fullname</td>
<td class="center-align">Rule</td>
<td class="center-align">Action</td>
</tr>
</thead>
<tbody>
<?php $hitung = $UserAccess->count(); ?>
#foreach($UserAccess as $list)
<tr>
<td class="center-align" width="50">
#if($list->avatar == NULL)
<img class="circle responsive-img" width="50" src="{{asset(config('param.url_uploads').'blank.jpg')}}"/>
#else
<img class="circle responsive-img" width="50" src="{{$list->avatar}}"/>
#endif
</td>
<td class="red1-text lato-bold center-align">{{$list->name}}</td>
<td class="center-align" width="150">
<select id="selectrole" name="selectrole{{$list->id}}" onchange="form.submit()">
#foreach($UserAccessRole as $listRole)
<option value="{{$listRole->id}}" #if($list->user_access_role_id_fk == $listRole->id) selected="selected"#endif>{{$listRole->name}}</option>
#endforeach
</select>
</td>
<input type = "hidden" value = "{{$list->id}}" name = "idmain{{$list->id}}">
#if($hitung > 2)
<td class="center-align">
<a href = "remove_access/{{$list->id}}/delete" >Remove Access<a/>
</td>
#else
<td class="center-align">Remove Access</td>
#endif
</tr>
#endforeach
</tbody>
</table>
{!! Form::close() !!}
and now my coding already work.

Categories