pass variable through blade pagination - php

I need to use pagination on a laravel blade, but from the controller comes another variable that does not pass pagination, how can I solve it?
<div class="main-content">
<div class="breadcrumb">
<h1>Página de Cliente</h1>
</div>
<div class="separator-breadcrumb border-top"></div>
<div class="card user-profile o-hidden mb-4">
<div class="user-info"><img class="profile-picture avatar-lg mb-2" alt="" />
<p class="m-0 text-24">{{ $customer->name }}</p>
<p class="text-muted m-0">{{ $customer->email }}</p>
</div>
<div class="card-body">
<ul class="nav nav-tabs profile-nav mb-4" id="profileTab" role="tablist">
<li class="nav-item"><a class="nav-link active" id="timeline-tab" data-toggle="tab" href="#timeline" role="tab" aria-controls="timeline" aria-selected="false">Propostas</a></li>
<li class="nav-item"><a class="nav-link" id="about-tab" data-toggle="tab" href="#about" role="tab" aria-controls="about" aria-selected="true">#</a></li>
<li class="nav-item"><a class="nav-link" id="friends-tab" data-toggle="tab" href="#friends" role="tab" aria-controls="friends" aria-selected="false">#</a></li>
<li class="nav-item"><a class="nav-link" id="photos-tab" data-toggle="tab" href="#photos" role="tab" aria-controls="photos" aria-selected="false">#</a></li>
</ul>
<div class="tab-content" id="profileTabContent">
<div class="tab-pane fade active show" id="timeline" role="tabpanel" aria-labelledby="timeline-tab">
<div class="row mb-4">
<div class="col-md-12 mb-3">
<div class="card text-left">
<div class="card-body">
<h4 class="card-title mb-3">Lista de Propostas</h4>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Data</th>
<th scope="col">Vendedor</th>
<th scope="col">Produto</th>
<th scope="col">Preço</th>
<th scope="col">Produção</th>
</tr>
</thead>
#foreach($proposals as $proposal)
<tbody>
<tr>
<th scope="row"> {{ $proposal->id_proposal }} </th>
<td> {{ $proposal->date }} </td>
<td> {{$proposal->users()->first()->name }} </td>
<td>
#foreach($proposal->proposed_phases()->get() as $proposedphase)
<p>{{ $proposedphase->features()->first()->name }}</p>
#endforeach
</td>
<td>
#foreach($proposal->proposed_phases()->get() as $proposedphase)
<p>{{ $proposedphase->amount }}€</p>
#endforeach
</td>
#if($proposal->id_production == null)
<td><span class="badge badge-danger">Produção</span></td>
#else
<td><span class="badge badge-success">Produção</span></td>
#endif
#if($proposal->id_production == null)
<td>
<a href="{{ URL::route('new.production', array('id_proposal'=>$proposal->id_proposal)) }}" class="text-success mr-2">
<button class="nav-icon i-Add font-weight-bold btn btn-success m-0" type="button" data-toggle="tooltip" data-placement="top" title="Criar Produção"></button>
</a>
</td>
#else
<td>
<a href="{{ URL::route('new.label', array('id_proposal'=>$proposal->id_proposal)) }}" class="text-success mr-2">
<button class="nav-icon i-Add font-weight-bold btn btn-warning m-0" type="button" data-toggle="tooltip" data-placement="top" title="Criar Etiquetas"></button>
</a>
</td>
#endif
</tr>
</tbody>
#endforeach
</table>
{{-- Pagination --}}
<div class="d-flex justify-content-center">
{!! $proposals->links() !!}
</div>
</div>
</div>
</div>
</div>
CONTROLLER
public function PageCustomer(Request $request)
{
$data = $request->all();
$customer = customer::where('id_customer', $data['id_customer'])->first();
$proposals = proposal::where('id_customer', $customer['id_customer'])->paginate(5);
return view('admin.customer.page_customer', compact('customer', 'proposals'));
}
the variable that does not pass to the second page is $customer
I tried to pass an array with the values ​​of name and email, but it didn't work. how can i resolve this situation?

Use appends on Paginator :
{!! $proposals->appends(['customer' => $customer])->links() !!}
As of Laravel 7, you can call the withQueryString() method on your Paginator instance :
{!! $proposals->withQueryString()->links() !!}
withQueryString() method appends all current query string values to the pagination links.

Related

Why is appering a pagination error after click in the search button?

I have a page "https://proj.test/user/profile?user=2#myRegistrations" where I have two tabs, one tab show the past registrations of a user in conferences and other tab the next registrations of the user in a conference. The user can click "Past Registrations" to check the past registrations and click in "Next Registrations" to check his next registrations in conferences. And its working.
In this same page, above the tabs, I have a form for the user to search for a conference name where he his registered. But when the user enters some text in the form search input like "test" and click in "Search" it appears "Undefined property: Illuminate\Pagination\LengthAwarePaginator::$participants (View: /Users/john/projects/proj/resources/views/users/index.blade.php)". Do you know what can be the issue?
Code in he view:
<div class="tab-pane clearfix fade" id="myTickets" role="tabpanel" aria-labelledby="contact-tab">
<div class="d-flex justify-content-between">
<form method="get" class="clearfix w-75" method="POST" action="{{ route('user.searchRegistration') }}">
{{ csrf_field() }}
<div class="form-group col col-md-6 px-0">
<div class="input-group" data-provide="datepicker">
<input type='text' class="form-control" placeholder="Search Registrations"
name="search_registration"
value="{{old('search_registration')}}"/>
<button class="input-group-addon">Search</button>
</div>
</div>
</form>
<a href="{{route('user.cleanSearchRegistration')}}" class="btn btn-outline-primary"
id="cleanSearchRegistration">Clean Search</a>
</div>
#if(session('searchedRegistrations'))
#if(session('searchedRegistrations')->count() != null)
#foreach(session('searchedRegistrations') as $registration)
#foreach(session('searchedRegistrations')->participants as $participant)
#if(!empty($registration))
<li class="list-group-item">
<h5>{{optional($registration->conference)->name}}</h5>
#if ($registration->status == 'C')
<a href="{{route('conference.registrationInfo',
['id' => $registration->conference->id,
'slug' => $registration->conference->slug,
'regID'=> $registration->id])}}"
class="btn btn-primary ml-2"><i class="fa fa-file-pdf-o"></i> Registration document
</a>
#endif
#if ($participant->registration_type->certificate_available == 'Y')
<a href="{{route('conferences.certificateInfo',
[
'regID'=> $registration->id])}}"
class="btn btn-primary ml-2"><i class="fa fa-file-pdf-o"></i> Download certificate
</a>
#break
#endif
</li>
#endif
#endforeach
#endforeach
<div class="text-center d-flex justify-content-center mt-3">
{{session('searchedRegistrations')->fragment('searchRegistrations')->links("pagination::bootstrap-4")}}
</div>
#else
<div class="alert alert-info" role="alert">
<i class="material-icons">info</i>
<span>Your search didnt return any result.</span>
</div>
#endif
#else
<div class="d-flex mb-3">
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active border" href="#nextConferences" data-toggle="tab" role="tab">Next
Conferences</a>
</li>
<li class="nav-item">
<a class="nav-link border" href="#PastRegistrations" data-toggle="tab" role="tab">Past
Conferences</a>
</li>
</ul>
</div>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active clearfix" id="nextConferences" role="tabpanel"
aria-labelledby="home-tab">
<ul class="list-group">
#foreach($nextRegistrations as $nextRegistration)
#foreach($nextRegistration->participants as $participant)
#if(!empty($nextRegistration->conference) || !empty($nextRegistration->conference->start_date))
<li class="list-group-item">
<h5>{{optional($nextRegistration->conference)->name}}</h5>
#if ($participant->registration_type->certificate_available == 'Y')
<a href="{{route('conferences.certificateInfo',
[
'regID'=> $nextRegistration->id])}}"
class="btn btn-primary ml-2"><i
class="fa fa-file-pdf-o"></i> Download Certificate</a>
#break
#endif
#if ($nextRegistration->status == 'C')
<a href="{{route('conferences.registrationInfo',
[
'regID'=> $nextRegistration->id])}}"
class="btn btn-primary ml-2"><i
class="fa fa-file-pdf-o"></i> Registration document
</a>
#endif
</li>
#endif
#endforeach
#endforeach
</ul>
<div class="text-center d-flex justify-content-center mt-3">
{{$nextRegistrations->fragment('nextConferences')->links("pagination::bootstrap-4")}}
</div>
</div>
<div class="tab-pane fade show clearfix" id="pastConferences" role="tabpanel" aria-labelledby="home-tab">
<ul class="list-group">
#foreach($pastRegistrations as $pastRegistration)
#foreach($pastRegistration->participants as $participant)
#if(!empty($pastRegistration->conference) || !empty($pastRegistration->conference->start_date))
<li class="list-group-item">
<h5>{{optional($pastRegistration->conference)->name}}</h5>
#if ($participant->registration_type->certificate_available == 'Y')
<a href="{{route('conferences.certificateInfo',['regID'=> $pastRegistration->id])}}"
class="btn btn-primary ml-2"><i
class="fa fa-file-pdf-o"></i> Download Certificate
</a>
#break
#endif
#if ($pastRegistration->status == 'C')
<a href="{{route('conferences.registrationInfo',
[
'regID'=> $pastRegistration->id])}}"
class="btn btn-primary ml-2"><i
class="fa fa-file-pdf-o"></i> Registration info
</a>
#endif
</li>
#endif
#endforeach
#endforeach
</ul>
<div class="text-center d-flex justify-content-center mt-3">
{{$pastRegistrations->fragment('pastConferences')->links("pagination::bootstrap-4")}}
</div>
</div>
</div>
</div>
I assume session('searchedRegistrations') is the Pagination instance. There is no property named participants nor would there be any random properties (it is a container, not what it contains). I would imagine a model instance contained in the collection might have a participants property though.
#foreach(session('searchedRegistrations') as $registration)
#foreach(session('searchedRegistrations')->participants as $participant)
I am guessing that should be
#foreach($registration->participants as $participant)

How to Show 1 plan in laravel?

i have a page "deposits" here are plans are availble with the use of "foreach"
now i wnt to show only plan number 3 here. mean plan of id 3.
<div class="row">
#foreach($plan as $p)
<div class="col-sm-4 text-center">
<div class="panel panel-info panel-pricing">
<div class="panel-heading">
<h3 style="font-size: 28px;"><b>{{ $p->name }}</b></h3>
</div>
<div style="font-size: 18px;padding: 18px;" class="panel-body text-center">
<p><strong>{{ $p->minimum }} {{ $basic->currency }} - {{ $p->maximum }} {{ $basic->currency }}</strong></p>
</div>
<ul style='font-size: 15px;' class="list-group text-center bold">
<li class="list-group-item"><i class="fa fa-check"></i> Commission - {{ $p->percent }} <i class="fa fa-percent"></i> </li>
<li class="list-group-item"><i class="fa fa-check"></i> Time - {{ $p->time }} times </li>
<li class="list-group-item"><i class="fa fa-check"></i> Compound - <span class="aaaa">{{ $p->compound->name }}</span></li>
</ul>
<div class="panel-footer" style="overflow: hidden">
<div class="col-sm-12">
<button type="button" class="btn btn-info btn-block btn-icon icon-left delete_button"
data-toggle="modal" data-target="#DelModal"
data-id="{{ $p->id }}">
<i class="fa fa-send"></i> Invest Under This Package
</button>
</div>
</div>
</div>
</div>
#endforeach
</div>
You can simply extract the plan from your $plan collection , does not need loop in below case
$p = $plan ->find(3);
if you want to use foreach and show plan id 3 , then try this :
<div class="row">
#foreach($plan as $p)
#if($p == 3)
<div class="col-sm-4 text-center">
<div class="panel panel-info panel-pricing">
<div class="panel-heading">
<h3 style="font-size: 28px;"><b>{{ $p->name }}</b></h3>
</div>
<div style="font-size: 18px;padding: 18px;" class="panel-body text-center">
<p><strong>{{ $p->minimum }} {{ $basic->currency }} - {{ $p->maximum }} {{ $basic->currency }}</strong></p>
</div>
<ul style='font-size: 15px;' class="list-group text-center bold">
<li class="list-group-item"><i class="fa fa-check"></i> Commission - {{ $p->percent }} <i class="fa fa-percent"></i> </li>
<li class="list-group-item"><i class="fa fa-check"></i> Time - {{ $p->time }} times </li>
<li class="list-group-item"><i class="fa fa-check"></i> Compound - <span class="aaaa">{{ $p->compound->name }}</span></li>
</ul>
<div class="panel-footer" style="overflow: hidden">
<div class="col-sm-12">
<button type="button" class="btn btn-info btn-block btn-icon icon-left delete_button"
data-toggle="modal" data-target="#DelModal"
data-id="{{ $p->id }}">
<i class="fa fa-send"></i> Invest Under This Package
</button>
</div>
</div>
</div>
</div>
#endif
#endforeach
</div>
But i suggest not to use foreach as you already know you need to show only plan id 3 . Try this :
<div class="row">
<?php $p = $plan["your_desired_id"]; ?> // means 2 or 3 .. whatever your desired id
<div class="col-sm-4 text-center">
<div class="panel panel-info panel-pricing">
<div class="panel-heading">
<h3 style="font-size: 28px;"><b>{{ $p->name }}</b></h3>
</div>
<div style="font-size: 18px;padding: 18px;" class="panel-body text-center">
<p><strong>{{ $p->minimum }} {{ $basic->currency }} - {{ $p->maximum }} {{ $basic->currency }}</strong></p>
</div>
<ul style='font-size: 15px;' class="list-group text-center bold">
<li class="list-group-item"><i class="fa fa-check"></i> Commission - {{ $p->percent }} <i class="fa fa-percent"></i> </li>
<li class="list-group-item"><i class="fa fa-check"></i> Time - {{ $p->time }} times </li>
<li class="list-group-item"><i class="fa fa-check"></i> Compound - <span class="aaaa">{{ $p->compound->name }}</span></li>
</ul>
<div class="panel-footer" style="overflow: hidden">
<div class="col-sm-12">
<button type="button" class="btn btn-info btn-block btn-icon icon-left delete_button"
data-toggle="modal" data-target="#DelModal"
data-id="{{ $p->id }}">
<i class="fa fa-send"></i> Invest Under This Package
</button>
</div>
</div>
</div>
</div>
</div>
If you need to find out a single value of plan from the collection .
You can just find it by it's plan id
$plan = Plan::find(3);
Write this in your controller and then pass it down to your view blade file by using with.
Example :
return view("blade file name")->with(['plan'=>$plan])
Later in your blade file just access it's fields.
{{$plan->field_name}}

Cannot end a section without first starting one in Laravel 5.5

so I keep getting this error Cannot end a section without first starting one in Laravel on my website online but localhost it is working no problem I don't see anything wrong with the code and I tried changing #stop with #endsection still the same, and I repeat I got this error on my online website, not my localhost my localhost is working fine, btw when I removed the heading section the error is gone but I need it.
here's my code
#extends('AdminPanel.master.main')
#section('heading')
Banner Details
<a style="float: right" href="/admin/banners-list" class="btn btn-primary">
<i class="fa fa-arrow-left"></i> Back To List
</a>
#stop
#section('body')
<div class="panel">
<div class="table-responsive">
<ul class="nav nav-tabs" style="margin-bottom: 2%">
<li class="nav-item">
<a class="nav-link active" href="#tab_a" data-toggle="tab">English</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="#tab_b" data-toggle="tab">العربية </a>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="#tab_c" data-toggle="tab">Urdu </a>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="#tab_d" data-toggle="tab">Chinese </a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active login-tabs" id="tab_a">
<table class="table table-hover profile">
<tbody>
<tr>
<td><i class="fa fa-user fa-fw"></i>Title</td>
<td> {{$data->TitleEn}}</td>
</tr>
<tr>
<td><i class="fa fa-user fa-fw"></i>Caption</td>
<td> {{$data->CaptionEn}}</td>
</tr>
<tr>
<td><i class="fa fa-user fa-fw"></i>Image</td>
<td><img #if($data->Image)src="/admin-assests/banner/{{$data->Image}}" #endif width="200px"
height="200px"></td>
</tr>
</tbody>
</table>
</div>
<div class="tab-pane login-tabs" id="tab_b">
<table class="table table-hover profile">
<tbody>
<tr>
<td><i class="fa fa-user fa-fw"></i>العنوان</td>
<td> {{$data->TitleAr}}</td>
</tr>
<tr>
<td><i class="fa fa-user fa-fw"></i>الوصف</td>
<td> {{$data->CaptionAr}}</td>
</tr>
<tr>
<td><i class="fa fa-user fa-fw"></i>Image</td>
<td><img #if($data->Image)src="/admin-assests/banner/{{$data->Image}}" #endif width="200px"
height="200px"></td>
</tr>
</tbody>
</table>
</div>
<div class="tab-pane login-tabs" id="tab_c">
<table class="table table-hover profile">
<tbody>
<tr>
<td><i class="fa fa-user fa-fw"></i>العنوان</td>
<td> {{$data->TitleUr}}</td>
</tr>
<tr>
<td><i class="fa fa-user fa-fw"></i>الوصف</td>
<td> {{$data->CaptionUr}}</td>
</tr>
<tr>
<td><i class="fa fa-user fa-fw"></i>Image</td>
<td><img #if($data->Image)src="/admin-assests/banner/{{$data->Image}}" #endif width="200px"
height="200px"></td>
</tr>
</tbody>
</table>
</div>
<div class="tab-pane login-tabs" id="tab_d">
<table class="table table-hover profile">
<tbody>
<tr>
<td><i class="fa fa-user fa-fw"></i>العنوان</td>
<td> {{$data->TitleCh}}</td>
</tr>
<tr>
<td><i class="fa fa-user fa-fw"></i>الوصف</td>
<td> {{$data->CaptionCh}}</td>
</tr>
<tr>
<td><i class="fa fa-user fa-fw"></i>Image</td>
<td><img #if($data->Image)src="/admin-assests/banner/{{$data->Image}}" #endif width="200px"
height="200px"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 pull-right">
Edit Info
</div>
</div>
#stop
main
<html lang="en">
<head>
#include('AdminPanel.master.head')
#include('AdminPanel.master.navbar')
</head>
<body>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">#yield('heading')</h1>
</div>
</div>
#yield('body')
</div>
#include('AdminPanel.master.footer')
</body>

How to show/hide fields on link click?

I am using laravel 5.3
I have a responding navigation menu, when I click on domains, it shows all the domains I already have in DB, and then when I click on one of these domains I get the corresponding projects.
Now, I am want that when I click on project it displays all the corresponding data in a table for example. But, this is what I am getting :
this is ProjectController :
public function index(Request $request)
{
$projects1=DB::table('projects')->where('domain_id', '=', 1)->get();
$projects2=DB::table('projects')->where('domain_id', '=', 2)->get();
$projects3=DB::table('projects')->where('domain_id', '=', 3)->get();
return view('projects.index',compact('projects', 'projects1', 'projects2', 'projects3'));
}
and this is index.blade.php :
<div class="nav-side-menu">
<div class="brand">Menu</div>
<i class="fa fa-bars fa-2x toggle-btn" data-toggle="collapse" data-target="#menu-content"></i>
<div class="menu-list">
<ul id="menu-content" class="menu-content collapse out">
<li data-toggle="collapse" data-target="#products" class="collapsed active">
<i class="fa fa-gift fa-lg"></i> Domains <span class="arrow"></span>
</li>
<ul class="sub-menu collapse" id="products">
<li data-toggle="collapse" data-target="#domain1_projet" class="collapsed active">
<i class="fa fa-gift fa-lg"></i> Domain 1 <span class="arrow"></span>
</li>
<ul class="sub-menu collapse" id="domain1_projet">
#foreach ($projects1 as $key => $project)
<li>{{$project->title}}</li>
#endforeach
<table class="table table-bordered">
<tr>
<th>No</th>
<th>title</th>
<th>code</th>
<th>domain_id</th>
</tr>
#foreach ($projects1 as $key => $project1)
<tr>
<td>{{ ++$i }}</td>
<td>{{ $project1->title }}</td>
<td>{{ $project1->code }}</td>
<td>{{ $project1->domain_id}}</td>
</tr>
#endforeach
</table>
</ul>
<li data-toggle="collapse" data-target="#domain2_projet" class="collapsed active">
<i class="fa fa-gift fa-lg"></i> Domain 2 <span class="arrow"></span>
</li>
<ul class="sub-menu collapse" id="domaine2_projet">
#foreach ($projects2 as $key => $project)
<li>{{$project->title}}</li>
#endforeach
</ul>
</ul>
</ul>
</div>
</div>
the #if clause I added before table was just to test, but I need to change that. I want to be able to display data of each project not in a manual way. I also want to know how to show and hide the information of each project when clicking on the links.
As you can see in index.blade.php, It's because I already know the names of project I did if (($project->intitule)=="Title") and elseif(($project->intitule)=="Project2") But, in fact I have many projects in database. How can I be able to display all the projects and then when I click on one of them, how can get a table containing information of that specific project
CONTROLLER
public function index(Request $request)
{
$projects=DB::table('projects')->get();
return view('projects.index',compact('projects'));
}
VIEW
<div class="nav-side-menu">
<div class="brand">Menu</div>
<i class="fa fa-bars fa-2x toggle-btn" data-toggle="collapse" data-target="#menu-content"></i>
<div class="menu-list">
<ul id="menu-content" class="menu-content collapse out">
<li data-toggle="collapse" data-target="#products" class="collapsed active">
<i class="fa fa-gift fa-lg"></i> Domains <span class="arrow"></span>
</li>
<ul class="sub-menu collapse" id="products">
#for ($i = 0; $i < count($projects); $i++)
<li data-toggle="collapse" data-target="#domain1_projet{{$i}}" class="collapsed active">
<i class="fa fa-gift fa-lg"></i> Domain {{$projects[$i]->domain_id}} <span class="arrow"></span>
</li>
<ul class="sub-menu collapse" id="domain1_projet{{$i}}">
<li>{{$projects[$i]->title}}</li>
<table class="table table-bordered">
<tr>
<th>No</th>
<th>title</th>
<th>code</th>
<th>domain_id</th>
</tr>
<tr>
<td>{{ $i }}</td>
<td>{{ $projects[$i]->title }}</td>
<td>{{ $projects[$i]->code }}</td>
<td>{{ $projects[$i]->domain_id}}</td>
</tr>
</table>
</ul>
#endfor
</ul>
</ul>
</div>
</div>
Try it! and let me know if return errors!

Two ids on the same tbody

I'm trying to display some results on a table based on few dropdown which is used for displaying different results, I choose the parameter followed the date. Unfortunately if I'm not mistaken it is illegal to have two ids on a tbody, as seen my code only takes into consideration of the date and not the parameter selected, so is there any alternative solution to what I'm trying to do?
#extends('app')
#section('header')
<link href="css/reports.css" rel="stylesheet">
#stop
#section('content')
<h1 class="page-header">Reports Archive</h1>
<div class="dropdown">
<a style="font-weight:bold" id="drop5" href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" role="button" aria-expanded="false">
Zone Options:
<span class="caret"></span>
</a>
<ul id="menu2" class="dropdown-menu" role="menu" aria-labelledby="drop5">
<?php $count = 1; ?>
#foreach ($zones as $zone)
<li role="presentation" class="{{ $count == 0 ? 'active' : '' }}">
<a role="menuitem" tabindex="-1" href="#" data-target="#zone{{ $zone->id }}"> {{ $zone->zone_name }}</a></li>
<?php $count++; ?>
#endforeach
</ul>
</div>
<div role="tabpanel">
<!-- hide the below links-->
<ul class="nav nav-tabs" style="display:none;" role="tablist" id="myTab">
<?php $count = 1; ?>
#foreach ($zones as $zone)
<li role="presentation" class="{{ $count == 0 ? 'active' : '' }}">{{ $zone->zone_name }}</li>
<?php $count++; ?>
#endforeach
</ul>
<!-- Tab panes -->
<div class="tab-content">
<?php $count = 1; ?>
#foreach ($zones as $zone)
<div role="tabpanel" class="tab-pane fade in {{ $count == 0 ? 'active' : '' }}" id="zone{{ $zone->id }}">
<div class="col-md-12">
<h2> {{ $zone->zone_name }} </h2>
<table class="table table-responsive table-hover table-bordered">
<thead>
<tr>
<th style="vertical-align:middle">#</th>
<th>
<div class="dropdown">
<a style="font-weight:bold" id="drop5" href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" role="button" aria-expanded="false">
Parameter Name:
<span class="caret"></span>
</a>
<ul id="menu2" class="dropdown-menu" role="menu" aria-labelledby="drop5">
#foreach ($zone->parameter as $param)
<li role="presentation">
<a class="btn btn-link" data-collapse-group="filters" data-target="#{{ $param->id }}" data-toggle="collapse">{{ $param->parameter_name }}</a></li>
#endforeach
</ul>
</div>
</th>
<th style="vertical-align:middle">Reading Value</th>
<th style="vertical-align:middle">User</th>
<th style="vertical-align:middle">Status</th>
<th style="vertical-align:middle">
<div class="dropdown" style="position:relative">
<a style="font-weight:bold" href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Timestamp
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<?php $validate = "default" ?>
<?php $records = App\Reading::sort()->get() ?>
#foreach ($records as $record)
#if ($record->created_at->year != $validate)
<li>
<a class="trigger right-caret">
{{ $record->created_at->year }}
</a>
<ul class="dropdown-menu sub-menu">
<li>January</li>
<li>February</li>
<li>March</li>
<li>April</li>
<li>May</li>
<li>June</li>
<li>July</li>
<li>August</li>
<li>September</li>
<li>October</li>
<li>November</li>
<li>December</li>
</ul>
</li>
<?php $validate = $record->created_at->year ?>
#endif
#endforeach
</ul>
</div>
</th>
</tr>
</thead>
<?php $validate = "default" ?>
#foreach ($records as $record)
#if ($record->created_at->year != $validate)
<?php $month = 1; ?>
#while ($month != 13)
#foreach ($parameters as $param)
<?php $index = 1; ?>
#if ($param->zone_id == $zone->id)
<tbody id="{{ $record->created_at->year }}-{{ $month }}" class="collapse">
#foreach ($readings as $reading)
#if ($reading->parameter_id == $param->id)
#if ($reading->created_at->year == $record->created_at->year)
#if ($reading->created_at->month == $month)
<tr>
<td>{{ $index }}</td>
<td>{{ $reading->parameter->parameter_name }} </td>
<td>{{ $reading->reading_value }} </td>
<td>{{ $reading->user->name }} </td>
<td>{{ $reading->parameter->threshold->getStatus($reading->reading_value) }} </td>
<td>{{ $reading->created_at }} </td>
</tr>
<?php $index++; ?>
#endif
#endif
#endif
#endforeach
#endif
</tbody>
</div>
#endforeach
<?php $month++; ?>
#endwhile
<?php $validate = $record->created_at->year ?>
#endif
#endforeach
</div>
</table>
</div>
</div>
<?php $count++; ?>
#endforeach
</div>
</div>
#stop
#section('scripts')
<script>
$(function(){
$(".dropdown-menu > li > a.trigger").on("click",function(e){
var current=$(this).next();
var grandparent=$(this).parent().parent();
if($(this).hasClass('left-caret')||$(this).hasClass('right-caret'))
$(this).toggleClass('right-caret left-caret');
grandparent.find('.left-caret').not(this).toggleClass('right-caret left-caret');
grandparent.find(".sub-menu:visible").not(current).hide();
current.toggle();
e.stopPropagation();
});
$(".dropdown-menu > li > a:not(.trigger)").on("click",function(){
var root=$(this).closest('.dropdown');
root.find('.left-caret').toggleClass('right-caret left-caret');
root.find('.sub-menu:visible').hide();
});
});
</script>
#stop
It is illegal to have two ids on the same HTML element, as in this example
<div id="id1" id="id2"> <!-- Here be dragons -->
You can skirt this by just having a delimeter in a single id:
<div id="id1--id2">
Or, you can use arbitrary data attributes:
<div id="" data-date="2015-10-14" data-parameter="zone_id">
Since you're using jQuery, here is a question that specifically asks about how to retrieve a data attribute.

Categories