#extends('main')
#foreach ($hotel as $hotel)
#foreach ($city as $city)
#section('title'," $hotel->hotel - $city->city")
#endsection
#section('content')
{{-- Header --}}
<div style="background-image:url('../img/{{ $hotel->id }}.jpg'); height:400px; background-size:cover;">
<div class="container">
#include('partials._nav')
<div class="row">
<center>
<h2>
<div class="col-md-12 hotel-name">
{{ $hotel->hotel }}
<p class="city">
</h2>
{{ $city->city }}
#endforeach
</p>
</div>
</center>
</div>
</div>
{{-- End Search bar --}}
</div>
</div>
{{-- Header End here --}}
</div>
</div>
</div>
{{-- Modal Closed --}}
<div class="container">
{{-- Tab Start here --}}
<div class="tabs">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">Overview</li>
<li role="presentation">Menu</li>
<li role="presentation">Comments <span class="disqus-comment-count" data-disqus-identifier="article_1_identifier"></span></li>
<li role="presentation">Photo</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<div class="row">
<div class="col-md-3">
<h3>Contact No.</h3>
<p class="contactno">{{ $hotel->contactno }}</p>
<p class="remark">{{ $hotel->remark }}</p>
<h3>Cuisines</h3>
<p class="cuisines">{{ $hotel->cuisines }}</p>
<h3>Cost</h3>
<p class="cost">{{ $hotel->cost }}</p>
</div>
<div class="col-md-3">
<h3>Opening Hours</h3>
<p class="hours">{{ date('h:ia', strtotime($hotel->openfrom)) }} - {{ date('h:ia', strtotime($hotel->opento)) }}</p>
<h3>Address</h3>
<p class="address">{{ $hotel->address }}</p>
<div id="map" style="width:150px;height:100px;"></div>
</div>
<div class="col-md-3">
<h3>Highlights</h3>
<p class="highlight">{{ $hotel->highlight }}</p>
<h3>Featured in Collection</h3>
<p class="featured">{{ $hotel->featured }}</p>
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="profile">
<table class="table">
<tr>
<th>#</th>
<th>Dish</th>
<th>Price</th>
</tr>
#foreach ($menu as $menu)
<tr>
<td>{{ $menu->id }}</td>
<td>{{ $menu->dish_name }}</td>
<td>{{ $menu->price }}</td>
</tr>
#endforeach
</table>
</div>
<div role="tabpanel" class="tab-pane" id="messages">
{{-- Disqus Start from here --}}
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//gobumpr.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
</div>
{{-- Disqus End Here --}}
<div role="tabpanel" class="tab-pane" id="settings"></div>
</div>
</div>
{{-- Tab End Here --}}
</div>
#endsection
#section('javascript')
<script>
function myMap() {
var mapCanvas = document.getElementById("map");
var mapOptions = {
center: new google.maps.LatLng({{ $hotel->directions }}),
zoom: 10
}
var map = new google.maps.Map(mapCanvas, mapOptions);
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?callback=myMap"></script>
<script id="dsq-count-scr" src="//gobumpr.disqus.com/count.js" async></script>
#endforeach
{{-- <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDu9JV__AvYU6auWV-QsJuV82TnLtrytm0&callback=initMap" async defer></script> --}}
#endsection
I am getting this:
Error::
ErrorException in Factory.php line 587:
Cannot end a section without first starting one. (View: E:\Other\gobumpr\resources\views\pages\select.blade.php)
In here
#section('title'," $hotel->hotel - $city->city")
#endsection
you don't gonna need an #endsection since you supply the content for the title.
The 2nd argument of #section() consider as the content for the #section()
Simply use #section('title'," $hotel->hotel - $city->city")
If you use #section('section_name', 'section_content') syntax, your section's content is "section_content". There is no need to close such section with #endsection.
Check https://laravel.com/docs/5.3/blade#extending-a-layout
#section('javascript')
function myMap() {
var mapCanvas = document.getElementById("map");
var mapOptions = {
center: new google.maps.LatLng({{ $hotel->directions }}),
zoom: 10
}
var map = new google.maps.Map(mapCanvas, mapOptions);
}
#endforeach
{{-- --}}
#endsection
The #endsection needs to be before the #endforeach.
removing #endsection will solve the problem. I'm trying to add title page with #yield('title') in <title></title> and provide with #section('title', 'pageTitle') without #endsection.
you defenetly forget the'#' before the word section
try to delete the #endsection after the section('title') it will fix it.
use #stop or #endsection (only one) in a blade template not both.
You should use #stop or #endsection after #section
For example
It'll work
#section('testing')
<h1>kjfdgjkfdgfd kjgkdfhgdljkfs hgdfhgjk</h1>
#endsection
It'll not work
#section('testing')
<h1>kjfdgjkfdgfd kjgkdfhgdljkfs hgdfhgjk</h1>
#endsection
#stop
Related
when ever I delete a user from my records the wrong user gets deleted
the deletion is happening in an incremented way no matter what the user id I'm choosing to delete
let's say I'm deleting the user with the id 4
the one that actually gets deleted is the one with the id 1
if I try again to delete id 4 the user with the id of 2 gets deleted and so on.
my view is :
#extends('layouts.app')
#section('content')
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0">{{ __('Admin panel') }}</h1>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<!-- Main content -->
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h5 class="card-title"></h5>
<p class="card-text">
#if (Session::has('successMsg'))
<div class="alert alert-success">
<h6 style=" text-align:center !important;"><b>Successfully Deleted! </b></h6>
</div>
#endif
<a class="btn btn-primary m-2" href="/addAppointment">Add new Appointment</a>
Appointments List
<div class="container">
#if ($users->count())
<table class="table" id="table">
<thead>
<tr>
<th>Id</th>
<th>Email</th>
<th>View</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
#foreach ($users as $user)
#if ($user->id > 1)
<tr>
<td>{{ $user->id }}</td>
<td>{{ $user->email }}</td>
<td><a href="/cpanel/{{ $user->id }}"
class="btn">👁</a></td>
<td>
<form action="/cpanel/{{ $user->id }}" method="POST"
id="EditForm">
#method('DELETE')
#csrf
<button type="submit" class="btn" data-toggle="tooltip"
title='Delete' onclick="submitResult(event)"
aria-hidden="true">🗑</button>
</form>
</td>
</tr>
#endif
#endforeach
</tbody>
</table>
#endif
</div>
</p>
</div>
</div>
</div>
</div>
<!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content -->
#endsection
#section('scripts')
<script src="//cdn.jsdelivr.net/npm/sweetalert2#11"></script>
<script src="sweetalert2.all.min.js"></script>
<script type="text/javascript">
function submitResult(e) {
e.preventDefault();
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
Swal.fire(
'Deleted!',
'Your file has been deleted.',
'success'
)
document.getElementById("EditForm").submit();
}
})
}
</script>
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script type="text/javascript" language="javascript"
src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
#endsection
#section('styles')
<link href='https://cdn.jsdelivr.net/npm/sweetalert2#10.10.1/dist/sweetalert2.min.css'>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.2/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css">
#endsection
my destroy function in the user controller is:
public function destroy($id)
{
if (!Auth::check()) {
return redirect('login');
} elseif (Gate::denies('cpanel')) {
abort(403, 'action not allowed!');
} else {
User::destroy($id);
return redirect('cpanel')->with('successMsg', 'User Deleted !');
}
}
my route is:
Route::resource('/cpanel', UserController::class)->middleware(['auth', 'verified']);
what Am I missing?
EDIT:
it seems that the onclick="submitResult(event)"
is causing some problem, when I remove the onclick event
the id gets sent correctly to the destroy function.
can you please Help fix this.
i think this was probably an error caused by me.
the problem is fixed after I changed the
onclick="submitResult(event)"
to
onclick="submitResult(e)"
the id is now being sent correctly to the destroy function.
problem fixed.
I'm getting this error when clicking a button on my dashboard
And this error only happens in the customization part, in other sections everything works fine
It gives me the solution below but I don't know how to apply
$name is undefined
Make the variable optional in the blade template. Replace {{ $name }} with {{ $name ?? '' }}
Undefined variable $name (View: /home/dir/mysite.com/resources/views/admin/settings/personalization.blade.php)
#push('styles_top')
#endpush
#section('content')
<section class="section">
<div class="section-header">
<h1>{{ trans('admin/main.personalization') }} {{ trans('admin/main.settings') }}</h1>
<div class="section-header-breadcrumb">
<div class="breadcrumb-item active">{{ trans('admin/main.dashboard') }}</div>
<div class="breadcrumb-item active">{{ trans('admin/main.settings') }}</div>
<div class="breadcrumb-item ">{{ trans('admin/main.personalization') }}</div>
</div>
</div>
<div class="section-body">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
#php
$items = ['page_background','home_sections','home_hero','home_hero2','home_video_or_image_box',
'panel_sidebar','find_instructors','reward_program','become_instructor_section',
'theme_colors', 'theme_fonts', 'forums_section', 'navbar_button','cookie_settings','mobile_app',
'others_personalization'
]
#endphp
<ul class="nav nav-pills" id="myTab3" role="tablist">
#foreach($items as $item)
<li class="nav-item">
<a class="nav-link {{ ($item == $name) ? 'active' : '' }}" href="/admin/settings/personalization/{{ $item }}">{{ trans('admin/main.'.$item) }}</a>
</li>
#endforeach
</ul>
<div class="tab-content">
#include('admin.settings.personalization.'.$name,['itemValue' => (!empty($values)) ? $values : ''])
</div>
</div>
</div>
</div>
</div>
</div>
</section>
#endsection
#push('scripts_bottom')
#endpush
I've tried several solutions suggested in other posts, but none worked.
What's wrong?
IN:
/home/dir/mysite.com/resources/views/admin/settings/personalization.blade.php)
error: You have not any variable $name.
Solution:
check that into controller, you are sending variable with view file?
return view('file_path')->with("name", $valueVariable);
return view("file_path".["name" => $valueVariable]);
I want to paginate in a blade file different tabs , each tabs show different collections of object but each time i go to next page in one page it redirects to the first tab and also paginate each tab not just the one i wanted to paginate.
Blade Part Where i have tabs
<div class="container">
<div class="section-bg-color">
<div class="row">
<div class="col-lg-12">
<!-- My Account Page Start -->
<div class="myaccount-page-wrapper">
<!-- My Account Tab Menu Start -->
<div class="row">
<div class="col-lg-3 col-md-4">
<div class="myaccount-tab-menu nav" role="tablist" id="myTab">
<i class="fa fa-dashboard"></i>Dashboard
<i class="fa fa-user"></i>Gestione Utenti
<i class="fa fa-book"></i>Gestione Fumetti
<i class="fa fa-map-marker"></i>Gestione Recensione
</div>
</div>
<!-- My Account Tab Menu End -->
<!-- My Account Tab Content Start -->
<div class="col-lg-9 col-md-8">
<div class="tab-content" id="myaccountContent">
<!-- Single Tab Content Start -->
<div class="tab-pane fade show active" id="dashboad" role="tabpanel">
<div class="myaccount-content">
<h5>Dashboard</h5>
<div class="welcome">
<p>Ciao, <strong>{{ $user->username }}</strong>! (Non sei <strong>{{ $user->username }}</strong>? Logout)</p>
</div>
<p class="mb-0">I tuoi dati:</p>
<p class="mb-0">E-mail: <strong>{{ $user->email }} </strong></p>
</div>
<div class="myaccount-content">
#php
$notifications = \App\Http\Controllers\NotificationController::getNotification($user->id);
#endphp
<h5>Notifiche</h5>
#if($notifications->count() < 1)
<div class="myaccount-content">
<h5>Non ci sono ancora notifiche</h5>
</div>
#else
<div class="myaccount-table table-responsive text-center">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th>Data</th>
<th>testo</th>
<th>stato</th>
<th>Action</th>
</tr>
</thead>
<tbody>
#foreach($notifications as $notification)
<tr>
<td>{{ $notification->date }}</td>
<td>
#if(strlen($notification->notification_text) > 50 )
#php
$subnotification = substr($notification->notification_text, 0, 50)
#endphp
{{ $subnotification }}...
#else
{{ $notification->notification_text }}
#endif
</td>
#if($notification->state == 1)
<td>
Letto
</td>
<td>
View
</td>
#else
<td>
Non letto
</td>
<td>
View
</td>
#endif
</tr>
#endforeach
</tbody>
</table>
</div>
#endif
</div>
</div>
<!-- Single Tab Content End -->
#if(session('message'))
{{session('message')}}
#endif
<!-- Single Tab Content Start -->
<div class="tab-pane fade" id="users" role="tabpanel">
<div class="myaccount-content">
<h5>Utenti</h5>
<div class="myaccount-table table-responsive text-center">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th>Nickname</th>
<th>Phone</th>
<th>Email</th>
<th>Tipologia</th>
<th>Elimina</th>
</tr>
</thead>
<tbody>
#foreach($users as $user)
<tr>
<td>{{$user->username}}</td>
<td>{{$user->phone_number}}</td>
<td>{{$user->email}}</td>
#if($user->hasGroup('il gruppo degli utenti'))
<td>Utente</td>
#else
<td>Venditore</td>
#endif
<td><a class="btn btn-danger" onclick="return myFunction();" href="{{route('user-delete', $user->id)}}"><i class="fa fa-trash"></i></a></td>
<script>
function myFunction() {
if(!confirm("Sei sicuro di voler eliminare questo utente"))
event.preventDefault();
}
</script>
</tr>
#endforeach
{{ $users->links() }}
</tbody>
</table>
</div>
</div>
</div>
<!-- Single Tab Content End -->
<!-- Single Tab Content Start -->
<div class="tab-pane fade" id="comics" role="tabpanel">
<div class="myaccount-content">
<h5>Fumetti</h5>
<div class="myaccount-table table-responsive text-center">
<table class="table table-bordered">
<thead class="thead-dark">
<tr>
<th>Titolo</th>
<th>ISBN</th>
<th>Quantità</th>
<th>Utente</th>
<th>Elimina</th>
</tr>
</thead>
<tbody>
#foreach($comics as $comic)
#php
$userNeed = App\User::where('id','=',$comic->user_id)->first();
#endphp
<tr>
<td>{{$comic->comic_name}}</td>
<td>{{$comic->ISBN}}</td>
<td>{{$comic->quantity}}</td>
<td>{{$userNeed->username}}</td>
<td><a class="btn btn-danger" onclick="return myFunction();" href="{{route('comic-delete', $comic->id)}}"><i class="fa fa-trash"></i></a></td>
<script>
function myFunction() {
if(!confirm("Sei sicuro di voler eliminare questo fumetto"))
event.preventDefault();
}
</script>
</tr>
#endforeach
{{ $comics->links() }}
</tbody>
</table>
</div>
</div>
</div>
<!-- Single Tab Content End -->
<!-- Single Tab Content Start -->
<div class="tab-pane fade" id="reviews" role="tabpanel">
<div class="myaccount-content">
<h5>Recensione</h5>
<div class="myaccount-table table-responsive text-center">
<table class="table table-bordered">
<thead class="thead-dark">
<tr>
<th>Titolo</th>
<th>Fumetto</th>
<th>Recensore</th>
<th>Elimina</th>
</tr>
</thead>
<tbody>
#foreach($reviews as $review)
#php
$userReview = App\User::where('id','=',$review->user_id)->first();
$comicReview = App\Comic::where('id','=',$review->comic_id)->first();
#endphp
<tr>
<td>{{$review->review_title}}</td>
<td>{{$comicReview->comic_name}}</td>
<td>{{$userReview->username}}</td>
<td><a class="btn btn-danger" onclick="return myFunction();" href="{{route('review-delete-local', $review->id)}}"><i class="fa fa-trash"></i></a></td>
<script>
function myFunction() {
if(!confirm("Sei sicuro di voler eliminare questa recensione"))
event.preventDefault();
}
</script>
</tr>
#endforeach
{{ $reviews->links() }}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div> <!-- My Account Tab Content End -->
</div>
</div> <!-- My Account Page End -->
</div>
</div>
</div>
</div>
</div>
And this is my route
Route
Route::get('/adminArea', function () {
$user = \Illuminate\Support\Facades\Auth::user();
$users = \App\User::where('username','!=','admin')->orderBy('username', 'asc')->paginate(12);
$comics =Comic::orderBy('comic_name', 'asc')->paginate(12);
$reviews = \App\Review::orderBy('review_title', 'asc')->paginate(12);
return view('adminPanel')
->with(compact('user'))
->with(compact('users'))
->with(compact('comics'))
->with(compact('reviews'));
})->name('AdminAccount');
In the end what i want to do is to paginate each tab differently meaning if a put the next on the comics i don't want to show also in the user tab the second page of user. The problem is that it use the same pagination url for each tabs so i was wondering if the solution is to give each tab an indipendent url
It redirects to the first tab because you use javascript tabs with active class added to first tab. To resolve problem with tabs you need to change for each tabs nav to:
<a href="#dashboad" class="{{ (Route::currentRouteName() == 'YOUR-ROUTE-NAME) ? 'active' : '' }}" ...
Also here:
<!-- Single Tab Content Start -->
<div class="tab-pane fade show {{ (Route::currentRouteName() == 'YOUR-ROUTE-NAME) ? 'active' : '' }}"...
But your problems with paginations will remain.
Here are 2 solutions:
Use JS tabs and get data via Ajax request.
Use 4 separated routes for each collection and add routes to tabs corresponding above example.
I hope it was clear.
Solution look like this.
Navigation code:
<div class="myaccount-tab-menu nav" role="tablist" id="myTab">
<i class="fa fa-dashboard"></i>Dashboard
<i class="fa fa-user"></i>Gestione Utenti
<i class="fa fa-book"></i>Gestione Fumetti
<i class="fa fa-map-marker"></i>Gestione Recensione
</div>
Also for each tab add, don't forget to change route name for each:
<!-- Single Tab Content Start -->
<div class="tab-pane fade show {{ (Route::currentRouteName() == 'dashboard') ? 'active' : '' }}" id="dashboad" role="tabpanel">
Route code:
Route::get('/dashboard', function () {
$user = \Illuminate\Support\Facades\Auth::user();
return view('adminPanel')->with(compact('user'));
})->name('dashboard');
Route::get('/users', function () {
$users = \App\User::where('username','!=','admin')->orderBy('username', 'asc')->paginate(12);
return view('adminPanel')->with(compact('users'));
})->name('users');
Route::get('/comics', function () {
$comics =Comic::orderBy('comic_name', 'asc')->paginate(12);
return view('adminPanel')->with(compact('comics'));
})->name('comics');
Route::get('/reviews', function () {
$reviews = \App\Review::orderBy('review_title', 'asc')->paginate(12);
return view('adminPanel')->with(compact('reviews'));
})->name('reviews');
I have this:
#foreach($portfolios as $portfolio)
<div id="item-portfolio-expand{{$portfolio->id}}" class="item-portfolio-expand expand">
<div class="container">
<div class="row">
<div class="col-md-8">
col-md-8
</div>
<div class="col-md-4">
{{ __('Name')}}: {{ $portfolio->name }}
</div>
</div>
</div>
</div>
#endforeach
And this:
#foreach ($portfolios as $portfolio)
<div class="portfolio-item {{ $portfolio->tag }} " data-category="transition">
<img src="{{ $portfolio->image_show }}">
<a href="#item-portfolio-expand{{$portfolio->id}}" data-toggle="collapse" data-target="#item-portfolio-expand{{$portfolio->id}}" data-parent="#item-portfolio-expand{{$portfolio->id}}">
<div class="portfolio-item-overlay">
<p class="name-item-overlay">{{ $portfolio->name }}</p>
</div>
</a>
</div>
#endforeach
And when I press the in the first foreach, I want to toggle the second foreach at <div id = "item-portfolio-expand {{$ portfolio-> id}}" class = "item- portfolio-expand expand "> I just don't succeed at anything, I use bootstrap and jquery in the project. .item-portfolio-expand has display: none;
And at the same time when one is open and another is selected, to close the one already open and to appear the one selected with toggle.
I want to add pagination to my searching product item view using my show controller
This is my controller
public function show($id)
{
$categories = Item::all();
$products = Item::find($id)->products->paginate(3);
return view('category.index', compact('categories', 'products'));
}
This is my view
#extends('layout.front')
#section('page')
<div class="row" id="portfolio">
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-lg-3" style="margin-top:20px;">
<nav class="main-nav">
<ul class="main-nav-ul">
<li style="background-color: #343A40; color: #ffffff; font-weight: 600;" id="sidebar-header"><a>Product List</a></li>
<li>Computer<span></span>
<ul>
#if(!empty($categories))
#forelse($categories as $category)
<li>{{ $category->name }}</li>
#empty
<li>No data found</li>
#endforelse
#endif
</ul>
</li>
<li>CCTV</li>
<li>Gaming</li>
</ul>
</nav>
</div>
<!-- /.col-lg-3 -->
<div class="col-lg-9">
<div class="row" style="margin-top:20px;">
#if(!empty($products))
#foreach($products as $key=>$product)
<div class="col-md-4 col-sm-6 portfolio-item" id="items">
<div class="card h-100">
<img class="card-img-top" src="/storage/{{ $product->image }}" alt="Product Image">
<div class="card-body">
<h4 class="card-title">
{{ $product->category_name }}<br />{{ $product->item_name}}
</h4>
<p class="card-text" style="color: #A9A9A9;text-decoration: line-through;">LKR {{ $product->old_price}}</p>
<h4 style="text-align: center; color: #fff;"><a class="waves-effect waves-light btn btn-dark btn-block">LKR {{ $product->new_price}}</a></h4>
{{--#endforelse--}}
</div>
</div>
</div>
#endforeach
#endif
</div>
<!-- /.row -->
</div>
<!-- /.col-lg-9 -->
</div>
<!-- /.row -->
</div>
<!-- /.container -->
</div>
<div class="col-lg-12">{!! $products->links() !!}</div>
#endsection
i used laravel default pagination and customize my bootstrap pagination to laravel.
But in my show function in controller pagination not working. how to fix searching products pagination.
i used links method. but it's not working for this view.
<div class="col-lg-12">{!! $comproducts->links() !!}</div>
You are not using pagination anywhere in the code. Please check the documentation on how to add pagination. You need to use paginate function when making the db call, and then use paginator links.
https://laravel.com/docs/5.5/pagination
{{$products->render()}}
put it below the end of the foreach loop.
Hi Please find pagination code here
Table:stocks PK:id,Varchar:name
StockController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
use App\Http\Controllers\Controller as Controller;
class StockController extends Controller {
public function usaPage() {
$stocks = DB::table('stocks')->orderBy('name', 'ASC')->paginate(50);
return view('stock.usa', ['stocks' => $stocks]);
}
?>
usa.blade.php
#section('content')
<div class="row">
<div class="col-md-12">
<table class="table">
<tr>
<th scope="col">Company Name</th>
<th scope="col">ID</th>
</tr>
#foreach ($stocks as $stock)
<tr><td> {{ $stock->name }}</a></td><td> {{ $stock->id }}</td></tr>
#endforeach
</table>
</div>
</div>
#endsection