laravel 9 (how can i make this code better..more compact) - php

I have 3 lists from 3 different stages of a client. I want to list all the clients, but separated by the stages of those clients.
<div class="container">
<!-- Title and Top Buttons Start -->
<div class="page-title-container">
<div class="row">
<!-- Title Start -->
<div class="col-12 col-md-7">
<!-- #include('_layout.breadcrumb',['breadcrumbs'=>$breadcrumbs]) -->
</div>
<!-- Title End -->
</div>
</div>
<!-- Title and Top Buttons End -->
<!-- Content Start -->
<div>
<div class="row">
<!-- Buttons Start -->
<div class="col-xl-6 mb-5">
<section class="scroll-section" id="buttons">
<!-- Lista Prospecção -->
<div class="d-flex justify-content-between">
<h2 class="small-title">Prospecção</h2>
</div>
<div class="scroll-out">
<div class="scroll-by-count" data-count="5">
#foreach ($clientes->where('etapa', '1') as $cliente)
<div class="card mb-2">
<div class="row g-0 sh-14 sh-md-10">
<div class="col">
<div class="card-body pt-0 pb-0 h-700">
<div class="row g-0 h-100 align-content-center">
<div class="col-12 col-md-7 d-flex flex-column mb-2 mb-md-0">
<div>{{$cliente->nome}} </div>
<div class="text-small text-muted text-truncate">{{$cliente->contato}}</div>
<div class="text-small text-muted text-truncate">{{$cliente->mes}}/{{$cliente->ano}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
#endforeach
</div>
</div>
<!-- Fim Lista Prospecção -->
<br />
<!-- Lista Necessidade do Cliente -->
<div class="d-flex justify-content-between">
<h2 class="small-title">Necessidade do Cliente</h2>
</div>
<div class="scroll-out">
<div class="scroll-by-count" data-count="5">
#foreach ($clientes->where('etapa', '2') as $cliente)
<div class="card mb-2">
<div class="row g-0 sh-14 sh-md-10">
<div class="col">
<div class="card-body pt-0 pb-0 h-700">
<div class="row g-0 h-100 align-content-center">
<div class="col-12 col-md-7 d-flex flex-column mb-2 mb-md-0">
<div>{{$cliente->nome}} </div>
<div class="text-small text-muted text-truncate">{{$cliente->contato}}</div>
<div class="text-small text-muted text-truncate">{{$cliente->mes}}/{{$cliente->ano}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
#endforeach
</div>
</div>
<!-- Fim Lista Necessidade do Cliente -->
<br />
<!-- Lista Marcou Consulta -->
<div class="d-flex justify-content-between">
<h2 class="small-title">Marcou Consulta</h2>
</div>
<div class="scroll-out">
<div class="scroll-by-count" data-count="5">
#foreach ($clientes->where('etapa', '3') as $cliente)
<div class="card mb-2">
<div class="row g-0 sh-14 sh-md-10">
<!-- <div class="col-auto h-100">
<img src="/img/product/small/product-2.webp" alt="alternate text" class="card-img card-img-horizontal sw-11" />
</div> -->
<div class="col">
<div class="card-body pt-0 pb-0 h-700">
<div class="row g-0 h-100 align-content-center">
<div class="col-12 col-md-7 d-flex flex-column mb-2 mb-md-0">
<div>{{$cliente->nome}} </div>
<div class="text-small text-muted text-truncate">{{$cliente->contato}}</div>
<div class="text-small text-muted text-truncate">{{$cliente->mes}}/{{$cliente->ano}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
#endforeach
</div>
</div>
<!-- Fim Lista Marcou Consulta -->
<br />
<!-- Lista Apresentou Proposta -->
<div class="d-flex justify-content-between">
<h2 class="small-title">Apresentou Proposta</h2>
</div>
<div class="scroll-out">
<div class="scroll-by-count" data-count="5">
#foreach ($clientes->where('etapa', '4') as $cliente)
<div class="card mb-2">
<div class="row g-0 sh-14 sh-md-10">
<!-- <div class="col-auto h-100">
<img src="/img/product/small/product-2.webp" alt="alternate text" class="card-img card-img-horizontal sw-11" />
</div> -->
<div class="col">
<div class="card-body pt-0 pb-0 h-700">
<div class="row g-0 h-100 align-content-center">
<div class="col-12 col-md-7 d-flex flex-column mb-2 mb-md-0">
<div>{{$cliente->nome}} </div>
<div class="text-small text-muted text-truncate">{{$cliente->contato}}</div>
<div class="text-small text-muted text-truncate">{{$cliente->mes}}/{{$cliente->ano}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
#endforeach
</div>
</div>
<!-- Fim Lista Apresentou Proposta -->
<br />
</section>
</div>
<!-- Buttons End -->
</div>
</div>
<!-- Content End -->
</div>
The code is working.
#foreach ($clientes->where('etapa', '1') as $cliente)
#endforeach
This is the main loop.
I have to make a foreach inside this foreach?
Showing each "etapa" (stage) that my client is?

<div class="container">
<!-- Title and Top Buttons Start -->
<div class="page-title-container">
<div class="row">
<!-- Title Start -->
<div class="col-12 col-md-7">
<!-- #include('_layout.breadcrumb',['breadcrumbs'=>$breadcrumbs]) -->
</div>
<!-- Title End -->
</div>
</div>
<!-- Title and Top Buttons End -->
<!-- Content Start -->
<div>
<div class="row">
<!-- Buttons Start -->
<div class="col-xl-6 mb-5">
<section class="scroll-section" id="buttons">
<!-- Listas -->
#php
$etapa = [
'1' => 'Prospecção',
'2' => 'Necessidade do Cliente',
'3' => 'Marcou Consulta',
'4' => 'Apresentou Proposta',
'5' => 'Negócio Fechado',
'6' => 'Negócio Perdido',
'7' => 'Oportunidades Futuras'
];
#endphp
#foreach ($etapa as $keyetapa => $e)
<div class="d-flex justify-content-between">
<h2 class="small-title">{{ $e }}</h2>
</div>
<div class="scroll-out">
<div class="scroll-by-count" data-count="5">
#foreach ($clientes->where('etapa', $keyetapa) as $cliente)
<div class="card mb-2">
<div class="row g-0 sh-14 sh-md-10">
<div class="col">
<div class="card-body pt-0 pb-0 h-700">
<div class="row g-0 h-100 align-content-center">
<div class="col-12 col-md-7 d-flex flex-column mb-2 mb-md-0">
<div>{{$cliente->nome}} </div>
<div class="text-small text-muted text-truncate">{{$cliente->contato}}</div>
<div class="text-small text-muted text-truncate">{{$cliente->mes}}/{{$cliente->ano}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
#endforeach
</div>
</div>
<br />
#endforeach
</section>
</div>
<!-- Buttons End -->
</div>
</div>
<!-- Content End -->
</div>

Related

Trying to set default Cateogry View in frontend Laravel 6

I am a total amateur on Laravel and I am trying to find a way to display by default a specific category with it's services instead of showing ALL the services for alla the categories that exist.
<section class="categories sp-80-50 bg-dull">
<div class="container">
<div class="row">
<div class="col-12">
<div class="all-title">
<p>#lang('front.categoriesTitle')</p>
<h3 class="sec-title">
#lang('front.categories')
</h3>
</div>
</div>
</div>
<div id="categories" class="row justify-content-center">
#foreach ($categories as $category)
#if($category->services->count() > 0)
<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6 col-12 mb-30 categories-list" data-category-id="{{ $category->id }}">
<div class="ctg-item" style="background-image:url('{{ $category->category_image_url }}')">
<a href="javascript:;">
<div class="icon-box">
<i class="flaticon-fork"></i>
</div>
<div class="content-box">
<h5 class="mb-0">
{{ ucwords($category->name) }}
</h5>
</div>
</a>
</div>
</div>
#endif
#endforeach
</div>
</div>
</section> */
<section class="listings sp-80 bg-w">
<div class="container">
<div class="row">
<div class="col-12">
<div class="all-title">
<p> #lang('front.servicesTitle') </p>
<h3 class="sec-title">
#lang('front.services')
</h3>
</div>
</div>
</div>
<div id="services" class="row">
#foreach ($services as $service)
<div class="col-lg-3 col-md-6 col-12 mb-30 services-list service-category-{{ $service->category_id }}">
<div class="listing-item">
<div class="img-holder" style="background-image: url('{{ $service->service_image_url }}')">
<div class="category-name">
<i class="flaticon-fork mr-1"></i>{{ ucwords($service->category->name) }}
</div>
</div>``
and
var categories = `
<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6 col-12 mb-30 categories-list">
</div>`;
response.categories.forEach(category => {
if (category.services.length > 0) {
var url = category.category_image_url;
categories += `
<div class="col-xl-2 col-lg-3 col-md-4 col-sm-4 col-12 mb-30 categories-list" data-category-id="${category.id}">
<div class="ctg-item" style="background-image:url('${url}')">
<a href="javascript:;">
<div class="icon-box">
<i class="flaticon-fork"></i>
</div>
<div class="content-box">
<h5 class="mb-0">
${category.name}
</h5>
</div>
</a>
</div>
</div>`
}
});
$('#categories').html(categories);
var services = '';
if (response.services.length > 0) {
response.services.forEach(service => {
services += `
<div class="col-lg-3 col-md-6 col-12 mb-30 services-list service-category-${service.category_id}">
<div class="listing-item">
<div class="img-holder" style="background-image: url('${ service.service_image_url }')">
<div class="category-name">
<i class="flaticon-fork mr-1"></i>${service.category.name}
</div>
<div class="time-remaining">
<i class="fa fa-clock-o mr-2"></i>
<span>έως ${service.time} ${makeSingular(service.time, service.time_type)}</span>
</div>
</div>
You can access the webpage at https://click-away.store
I need to set the default Services view for the 1st Button Category.
Sorry if my question is silly or the solution is simple but I couldn't find out what to do!
Your error is that you never loop over the category's services.
You check if there are any services, but you never loop over them. So, within the #if you should do that.
#foreach ($categories as $category)
#if($category->services->count() > 0)
#foreach($category->services as $service)
// your code
#endforeach
#endif
#endforeach

When i return value to my view pages then there should be an error . $student is defined variable . I Laravel

here is the function is given below
public function index(){
$student=Administration::Where('payment',1)->get();
//dd($student);
return view('HallAuthority.index',compact('student'));
}
Here is the view blade
<div class="container-fluid page-body-wrapper">
<div class="row row-offcanvas row-offcanvas-right">
<!-- partial:partials/_sidebar.html -->
#include('HallAuthority.inc.sidebar')
<!-- partial -->
<div class="content-wrapper">
<div class="row">
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
{{$student->count()}}
<h2 class="card-title">Total sutdent Student</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-1" class="card-float-chart"></div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
<h2 class="card-title">Total Department</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-2" class="card-float-chart"></div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
<h2 class="card-title">stock price Price</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-3" class="card-float-chart"></div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
<h2 class="card-title">Revenue</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-4" class="card-float-chart"></div>
</div>
</div>
</div>
</div>
</div>
<!-- content-wrapper ends -->
<!-- partial:partials/_footer.html -->
<div class="card card-body">
<div class="card-header text-center">
Mahfujur#2019
</div>
</div>
<!-- partial -->
</div>
<!-- row-offcanvas ends -->
</div>
The Route file is given below
Route::get('/student/hall','HallController#index')->name('student.hall');
Given this type an error
Undefined variable: student (View: C:\xampp\htdocs\ProjectFinall\resources\views\HallAuthority\index.blade.php) (View: C:\xampp\htdocs\ProjectFinall\resources\views\HallAuthority\index.blade.php)*
I get the value properly but i cannot compact this value to the view pages its always shows that it is undefined value i am totally fed up to solve this . Please anyone help me.
Try this
public function index(){
$student=Administration::Where('payment',1)->count();
return view('HallAuthority.index',compact('student'));
}
<div class="card-body">
{{$student}}
<h2 class="card-title">Total sutdent Student</h2>
</div>

Setting Categories using tabs with Laravel

I would like to ask how to pull categories using tabs. I was able to pull all the items on one tab but I could not pull them per category. here is my code. The data comes from the database and seems to work on All items but I could not figure out how to pull them individually. I need some help with you expertise.
<div class="tab-content">
<div class="tab-pane container active" id="home">...</div>
<div class="tab-pane container fade" id="allItems">All Items
<div>
<div class="row">
<div class="col-12">
<div class="row">
#foreach($items as $per_item)
<div class="col-lg-4 col-6">
<div class="card mb-3">
<img src="{{$per_item->image_path}}" class="card-img-top">
<div class="card-body">
<small>{{$per_item->category->name}}</small>
<h4 class="card-title">
<a href="/items/{{$per_item->id}}">
{{$per_item->name}}
</a>
</h4>
<p class="card-text">{{$per_item->description}}</p>
<h3>{{$per_item->price}}</h3>
<form action="/cart/{{$per_item->id}}" method="POST">
#csrf
<div class="row">
<div class="col-12 col-md-5 col-lg-12 mb-2">
<input type="number" name="quantity" id="quantity"
class="w-100">
</div>
<div class="col-12 col-md-7 col-lg-12 mb-2">
<button type="submit" class="btn btn-primary">Add To
Cart</button>
</div>
</div>
</form>
</div>
</div>
</div>
#endforeach
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane container fade" id="consumables">Consumables
<div>
</div>
</div>
<div class="tab-pvane container fade" id="pnuematicTools">Pnuematic
Tools</div>

How to fix: no query results for model [App\User] error

I'm trying to browser the home page of particular script but I face this problem
"ErrorException (E_ERROR) No query results for model [App\User] 5
(View: /.../core/resources/views/newhome/home.blade.php)"
/home2/.../core/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php
Code:
$result = $this->find($id, $columns);
if (is_array($id)) {
if (count($result) == count(array_unique($id))) {
return $result;
}
} elseif (! is_null($result)) {
return $result;
}
throw (new ModelNotFoundException)->setModel(
get_class($this->model), $id
);
}
/**
* Find a model by its primary key or return fresh model instance.
*
* #param mixed $id
* #param array $columns
* #return \Illuminate\Database\Eloquent\Model
*/
public function findOrNew($id, $columns = ['*'])
{
if (! is_null($model = $this->find($id, $columns))) {
The View Code
#extends('layouts.newfrontend')
#section('style')
<link rel="stylesheet" href="{{ asset('assets/css/ion.rangeSlider.css') }}">
<link rel="stylesheet" href="{{ asset('assets/css/ranger-style.css') }}">
<link rel="stylesheet" href="{{ asset('assets/css/ion.rangeSlider.skinFlat.css') }}">
<style>
.price-table {
margin-bottom: 45px;
</style>
#endsection
#section('content')
<!--Header section start-->
<section id="particles-js" class="header-area header-bg" style="background-image: url('{{ asset('assets/images/slider') }}/{{$slider_text->image}}')">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center">
<div class="header-section-wrapper">
<div class="header-section-top-part">
<div class="text-first wow slideInLeft" data-wow-duration="2s">{!!$slider_text->title!!}</div>
<p style="font-size: 1.5em;" class=" wow slideInDown" data-wow-duration="2s">{!!$slider_text->subtitle!!}</p>
</div>
<div class="header-section-bottom-part">
<div class="domain-search-from">
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!--Header section end-->
<div class="clearfix"></div>
<!-- Admin section start -->
<div class="admin-section wow slideInRight" data-wow-duration="2s">
<div class="container">
<div class="row">
<div class="col-md-12">
<!-- admin content start -->
<div class="admin-content">
<!-- admin text start -->
<div class="admin-text">
<p>Get access to Your account</p>
</div>
<!-- admin text end -->
<!-- admin user start -->
<div class="admin-user">
<button type="submit" name="login">sign in</button>
<button type="submit" name="register">register now</button>
</div>
<!-- admin user end -->
</div>
<!-- admin-content end -->
</div>
</div>
</div>
</div>
<!-- Admin section end -->
<div class="clearfix"></div>
<!-- Circle Section Start -->
<section class="circle-section section-padding wow slideInUp" data-wow-duration="2s">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="section-header">
<h2>HOW <span> {{ $basic_setting->title }} </span> Works </h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
</div>
</div>
<div class="row">
#foreach($features as $feature)
<div class="col-md-3">
<div class="circle-item wow flipInY" data-wow-duration="2s">
<img src="{{ asset('assets/images/features') }}/{{$feature->photo}}" alt="items">
<div class="circle-content">
<h6>{{$feature->title}}</h6>
<p>{{$feature->description}}</p>
</div>
</div>
</div>
#endforeach
</div>
</div>
</section>
<!-- Circle Section End -->
<div class="clearfix"></div>
<!--About community Section Start-->
<section class="section-padding sale-section">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="section-title text-center">
<div class="sale-header wow slideInDown" data-wow-duration="2s">
<h2>about <span> {{ $site_title }} </span></h2>
</div>
<div class="sale-content">
<div class="row">
<div class="col-md-6 wow slideInLeft" data-wow-duration="2s">
<p class="about-community-text">
{!! $page->about_leftText !!}
</p>
</div>
<div class="col-md-6 wow slideInRight" data-wow-duration="2s">
<p class="about-community-text text-justify">
{!! $page->about_rightText !!}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!--About community Section end-->
<div class="clearfix"></div>
<!--service section start-->
<section class="service-section">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="section-title text-center section-padding padding-bottom-0 wow slideInLeft" data-wow-duration="2s">
<div class="section-header">
<h2>Our <span>Services</span></h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
<p>{!! $page->service_subtitle !!}</p>
</div>
</div>
</div>
<div class="row wow slideInRight" data-wow-duration="2s">
#foreach($service as $s)
<div class="col-md-3 col-sm-6">
<div class="service-wrapper text-center">
<div class="service-icon ">
{!! $s->code !!}
</div>
<div class="service-title">
<p>{{ $s->title }}</p>
</div>
</div>
</div>
#endforeach
</div>
</div>
</section>
<!--service section end-->
<!--start investment plan-->
<section class="section-background">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="section-title text-center section-padding padding-bottom-0 wow slideInLeft" data-wow-duration="2s">
<div class="section-header">
<h2>Our awesome <span> plans</span></h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
<p>{!! $page->plan_subtitle !!}</p>
</div>
</div>
</div>
<div class="row">
#foreach($plan as $p)
<div class="col-md-3 col-sm-6 pricing-list-botom-margin wow zoomIn" data-wow-duration="3s">
<!-- Pricing List1 Start -->
<div class="pricing-list1">
<div class="pricing-header1">
<h5>{{ $p->name }}</h5>
<p>{{ $p->compound->name }} {{ $p->percent }}% for {{ $p->time }} times</p>
</div>
<div class="pricing-info1">
<ul>
<li> <p>for <span class="color-text">{{ $p->time }}</span> times</p></li>
<li><p> <span class="color-text">{{ $p->percent }}%</span> roi each time</p></li>
</ul>
</div>
<div class="price-range">
<div class="row">
<div class="col-md-6 text-left col-sm-6 col-xs-6">
<div class="min-price">
<h6>Minimum<span class="color-text">{{ $basic->symbol }} {{ $p->minimum }}</span></h6>
</div>
</div>
<div class="col-md-6 text-right col-sm-6 col-xs-6">
<div class="min-price">
<h6>Maximum<span class="color-text">{{ $basic->symbol }} {{ $p->maximum }}</span></h6>
</div>
</div>
</div>
</div>
<div class="invest-type__profit plan__value--{{ $p->id }}">
<input type="text" value="{{ $basic->symbol }} {{ ($p->minimum + $p->maximum) / 2 }}" class="custom-input invest-type__profit--val" data-slider=".slider-input--{{ $p->id }}" style="color:#FFF; font-size: 25px">
<input type="hidden" name="amount" value="{{ ($p->minimum + $p->maximum) / 2 }}" class=" slider-input slider-input--{{ $p->id }}" data-perday="{{ $p->percent }}" data-peryear="{{ $p->time }}" data-min="{{ $p->minimum }}" data-max="{{ $p->maximum }}" data-dailyprofit=".daily-profit-{{ $p->id }}" data-totalprofit=".total-profit-{{ $p->id }} " data-valuetag=".plan__value--{{ $p->id }} .invest-type__profit--val"/>
</div>
<input type="hidden" name="plan_id" value="{{ $p->id }}">
<div class="price-range">
<div class="row">
<div class="col-md-6 text-left col-sm-6 col-xs-6 invest-type__calc invest-type__calc--daily">
<div class="min-price">
<h6>per time<span class="color-text"><b class="daily-profit-{{ $p->id }}">{{ $basic->symbol }} {{ (($p->minimum + $p->maximum) / 2 ) * $p->percent /100 }}.0</b></span></h6>
</div>
</div>
<div class="col-md-6 text-right col-sm-6 col-xs-6 invest-type__calc invest-type__calc--total">
<div class="min-price">
<h6>Total Return<span class="color-text"><b class="total-profit-{{ $p->id }}">{{ $basic->symbol }} {{ (((($p->minimum + $p->maximum) / 2) * $p->percent) /100 ) * $p->time }}.0</b></span></h6>
</div>
</div>
</div>
</div>
<!--Order Now!-->
</div>
<!-- Pricing List1 End -->
</div>
#endforeach
</div>
<div class="row section-padding padding-bottom-0">
<div class="col-md-6 col-sm-6">
<div class="contact-middel-info wow bounceInLeft" data-wow-duration="2s">
<div class="contact-middel-title">
<h4>Have a question <span>we are here to help!</span></h4>
</div>
<div class="contact-middel-details">
<p><i class="fa fa-phone"></i> {{ $basic->phone }}</p>
<p><i class="fa fa-envelope"></i> {{ $basic->email }}</p>
</div>
</div>
</div>
<div class="col-md-6 col-sm-6">
<div class="discunt-middel-text wow bounceInRight" data-wow-duration="2s">
<h3>{{ $basic->reference_percent }}<i class="fa fa-percent"></i> <br /> referral <br /> commission</h3>
</div>
</div>
</div>
</div>
</section>
<!--end start investment plan-->
<!--Our Top Investor Section Start-->
<div class="clearfix"></div>
<section class="commission-section section-padding ">
<div class="container">
<!-- section header start -->
<div class="section-header wow slideInLeft" data-wow-duration="2s">
<h2>Our top <span> Investors</span></h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
<p class="margin-b-35 wow slideInRight" data-wow-duration="2s">{{ $page->investor_subtitle }}</p>
<!-- section header end -->
<div class="row">
#php $i=1 #endphp
#foreach($top_investor as $key => $inv)
<div class="col-md-3">
<div class="referral-amount wow zoomIn" data-wow-duration="3s">
<p>{{ \App\User::findOrFail($inv->user_id)->name }}</p>
<h4><span> {{ $basic->symbol }} </span>{{ number_format($inv->total_invest) }}</h4>
<h5>{{$i++}}</h5>
</div>
</div>
#endforeach
</div>
</div>
</section>
<!--Our Top Investor Section Start-->
<div class="clearfix"></div>
<!--staticies sectioin-->
<section class="sale-section section-padding">
<div class="container">
<div class="row">
<div class="col-md-3">
<!-- Counter List -->
<div class="counter-list wow shake" data-wow-duration="2s">
<!-- Counter Item -->
<div class="counter-item">
<div class="counter-thumb"><i class="fa fa-user"></i><p class="counter">{{ $total_user }}</p></div>
<div class="counter-content">
<p>Total User</p>
</div>
</div>
<!-- Counter Item -->
</div>
<!-- Counter List -->
</div>
<div class="col-md-3">
<!-- Counter List -->
<div class="counter-list wow shake" data-wow-duration="2s" data-wow-delay="2s">
<!-- Counter Item -->
<div class="counter-item">
<div class="counter-thumb"> <i class="fa fa-recycle"></i><p class="counter">{{ $total_repeat }}</p></div>
<div class="counter-content">
<p>Total Repeat</p>
</div>
</div>
<!-- Counter Item -->
</div>
<!-- Counter List -->
</div>
<div class="col-md-3">
<!-- Counter List -->
<div class="counter-list wow shake" data-wow-duration="2s" data-wow-delay="4s">
<!-- Counter Item -->
<div class="counter-item">
<div class="counter-thumb"> <i class="fa fa-cloud-download"></i><p class="counter">{{ $total_deposit }}</p></div>
<div class="counter-content">
<p>Total Deposit</p>
</div>
</div>
<!-- Counter Item -->
</div>
<!-- Counter List -->
</div>
<div class="col-md-3">
<!-- Counter List -->
<div class="counter-list wow shake" data-wow-duration="2s" data-wow-delay="6s">
<!-- Counter Item -->
<div class="counter-item">
<div class="counter-thumb"><i class="fa fa-cloud-upload"></i><p class="counter">{{ $total_withdraw }}</p></div>
<div class="counter-content">
<p>Total Withdraw</p>
</div>
</div>
<!-- Counter Item -->
</div>
<!-- Counter List -->
</div>
</div>
</div>
</section>
<!--staticies sectioin end-->
<div class="clearfix"></div>
<!--testimonial section start-->
<section class="people-say-section section-padding">
<div class="container">
<div class="row">
<div class="col-md-12">
<!-- section header start -->
<div class="section-header wow bounceInLeft" data-wow-duration="2s">
<h2>What People <span>Say</span> </h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
<!-- section header end -->
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="testimonial-area">
<div class="row">
<div class="col-lg-12 col-md-10 ">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-2">
<div class="testimonial-image-slider slider-nav text-center">
#foreach($testimonial as $tes)
<div class="sin-testiImage wow rotateIn" data-wow-duration="2s">
<img src="{{ asset('assets/images') }}/{{ $tes->image }}" alt="slider">
</div>
#endforeach
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 ">
<div class="testimonial-text-slider slider-for text-center wow bounceInRight" data-wow-duration="2s">
#foreach($testimonial as $tes)
<div class="sin-testiText">
<!-- people sat content list start -->
<div class="people-say-content-list " >
<h4>{{ $tes->name }}</h4>
<h6>{{ $tes->position }}</h6>
<ul>
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
</ul>
<p>
{!! $tes->message !!}
</p>
</div>
<!-- people-say-content-list end -->
</div>
#endforeach
</div>
</div>
</div>
</div>
</div>
</div>
</div><!-- row -->
</section><!-- section -->
<!--testimonial section start-->
<div class="clearfix"></div>
<!--Deopsit and Payouts section start-->
<section class="hosting-section hosting-section1 section-padding section-background">
<div class="container">
<div class="row">
<div class="col-md-12">
<!-- section header start -->
<div class="section-header wow bounceInDown" data-wow-duration="3s">
<h2>Latest <span> Deposits & Withdraw</span></h2>
<p><img src="{{asset('assets/images/logo/icon.png') }}" alt="icon"></p>
</div>
<!-- section header end -->
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="section-wrapper wow bounceInLeft" data-wow-duration="2s">
<div class="deposit-title text-center">
<h4>Latest Deposits</h4>
</div>
<div class="hosting-content table-responsive">
<table>
<thead>
<tr>
<th>Name</th>
<th>Date</th>
<th>Currency</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
#foreach($latest_deposit as $ld)
<tr>
<td>{{ $ld->member->name }}</td>
<td>{{ \Carbon\Carbon::parse($ld->created_at)->format('M d,Y') }}</td>
<td><strong>{{ $basic->currency }}</strong></td>
<td><strong>{{ $basic->symbol }}{{ $ld->amount }}</strong></td>
</tr>
#endforeach
</tbody>
</table>
</div>
<!-- hosting content end -->
</div>
</div>
<div class="col-md-6">
<div class="section-wrapper wow bounceInRight" data-wow-duration="2s">
<div class="deposit-title text-center">
<h4>Latest Withdraw</h4>
</div>
<div class="hosting-content table-responsive">
<table>
<thead>
<tr>
<th>Name</th>
<th>Date</th>
<th>Currency</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
#foreach($latest_withdraw as $ld)
<tr>
<td>{{ $ld->user->name }}</td>
<td>{{ \Carbon\Carbon::parse($ld->created_at)->format('M d,Y') }}</td>
<td><strong>{{ $basic->currency }}</strong></td>
<td><strong>{{ $basic->symbol }}{{ $ld->amount }}</strong></td>
</tr>
#endforeach
</tbody>
</table>
</div>
<!-- hosting content end -->
</div>
</div>
</div><!-- row -->
</div><!-- container -->
</section>
<!--Deopsit and Payouts Section End-->
#endsection
#section('script')
<script type="text/javascript" src="{{ asset('assets/js/ion.rangeSlider.js') }}"></script>
<script type="text/javascript">
$(window).load(function() {
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 0,
mobile: true,
live: true
});
wow.init();
});
</script>
<script>
$.each($('.slider-input'), function() {
var $t = $(this),
from = $t.data('from'),
to = $t.data('to'),
$dailyProfit = $($t.data('dailyprofit')),
$totalProfit = $($t.data('totalprofit')),
$val = $($t.data('valuetag')),
perDay = $t.data('perday'),
perYear = $t.data('peryear');
$t.ionRangeSlider({
input_values_separator: ";",
prefix: '{{ $basic->symbol }} ',
hide_min_max: true,
force_edges: true,
onChange: function(val) {
$val.val( '{{ $basic->symbol }} ' + val.from);
var profit = (val.from * perDay / 100).toFixed(1);
profit = '{{ $basic->symbol }} ' + profit.replace('.', '.') ;
$dailyProfit.text(profit) ;
profit = ( (val.from * perDay / 100)* perYear ).toFixed(1);
profit = '{{ $basic->symbol }} ' + profit.replace('.', '.');
$totalProfit.text(profit);
}
});
});
$('.invest-type__profit--val').on('change', function(e) {
var slider = $($(this).data('slider')).data("ionRangeSlider");
slider.update({
from: $(this).val().replace('{{ $basic->symbol }} ', "")
});
})
</script>
#endsection
This line might be the cause of the problem
$inv->user_id is probably null, or deleted. You should check if each of the users
<p>{{ \App\User::findOrFail($inv->user_id)->name }}</p>
If you're okay with the user not existing,
(\App\User::find($inv->user_id))['name']
You shouldn't use something like this in your view. Try moving this in your controller.
{{ \App\User::findOrFail($inv->user_id)->name }}
Check $inv->user_id. It's either null or there's no user in database for this ID.

laravel foreach broke column

Sorry for title i couldn't think better title!
anyway, this is my blog page code:
#extends('layouts.frontend_index')
#section('title', 'Blog')
#section('content')
<div class="container">
<div class="row" style="margin-bottom:30px;">
<div class="col-md-8">
<div class="row">
#forelse($posts as $post)
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12" style="margin-bottom:15px;">
<div class="card card2">
<div class="cardimg">
<img src="{{ url('images/') }}/{{ $post->image }}" class="card-img-top" style="width:100%; height:auto; max-height:500px;" alt="{{ $post->title }}">
</div>
<div class="card-block">
<h4 class="card-title">{{$post->title}}</h4>
<p class="card-text">{!! str_limit($post->body, 10) !!}</p>
<p><a class="btn btn-block btn-link" href="{{ route('frontshow', $post->slug ) }}">Read More <i class="fa fa-arrow-right"></i></a></p>
</div>
</div>
</div>
#empty
<p>No Post Available yet!</p>
<div class="text-center">
<a class="btn btn-error" href="{{url('/')}}">Back to Main Page</a>
</div>
#endforelse
<div class="col-md-12 text-center">
{{$posts->links()}}
</div>
</div><!--end row-->
</div><!--end col-md-8-->
<div class="col-md-4">
<h3>Get Latest Updates...</h3>
<a target="_blank" href="https://t.me/studiotjd"><div id="telegram"></div></a>
<a target="_blank" href="https://www.facebook.com/studiotjd"><div id="facebook"></div></a>
<a target="_blank" href="https://www.instagram.com/studiotjd/"><div id="instagram"></div></a>
</div><!--end col-md-4-->
</div><!--end row-->
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-4 span3 wow rollIn" style="animation-delay: 1s;"><div id="Library"></div></div><!--end col-md-4-->
<div class="col-md-4 span3 wow bounceInDown center" style="animation-delay: 1s;"><div id="Library2"></div></div><!--end col-md-4-->
<div class="col-md-4 span3 wow bounceInRight" style="animation-delay: 1s;"><div id="Library3"></div></div><!--end col-md-4-->
</div><!--end row-->
</div><!--end col-md-12-->
</div><!--end row-->
</div>
#endsection
here is how it looks like in view:
I tried almost everything to fix this issue but nothing works!
As you can see in my inspect all col-md-4 goes under first col-md-4 and i don't know why
Is there anyone knows how to fix this issue?
try this
{{ strip_tags(str_limit($post->body, 10)) }}
I think you have html element stored in your database, and you are just using str_limit so the tags in your body is not closed.
problem is a height of div, check it on the inspector code. 1 px or more is

Categories