laravel foreach broke column - php

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

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

error - my categories are not shown - laravel

I can't find the error, my categories are not shown according to their type, also does not throw laravel error..
blade.php
#extends('store.template')
#section('content')
<!-- Page Content -->
<div style="margin-top: 70px;" class="container text-center">
<!-- Page Heading -->
<div class="card bg-white ht-50 w-60">
<h1 class="">{{$tipo->tipo}}</h1>
</div>
<div style="margin-top: 10px;" class="row">
#foreach($categories as $category)
<div class="col-lg-4 col-sm-6 mb-4">
<div class="card h-100">
<a href="#">
#if(!empty($category->image))
<img class="card-img-top" src="{{url($category->image)}}" alt="">
#else
<img class="card-img-top" src="http://placehold.it/700x400" alt="">
#endif
</a>
<div class="card-body">
<h4 class="card-title">
{{$category->name}}
</h4>
<p class="card-text">{{$category->descripcion}}</p>
</div>
</div>
</div>
#endforeach
</div>
<!-- /.row -->
</div>
<!-- /.container -->
#stop
controller:
public function categoryType($type)
{
$tipo = Tipo::where('tipo',$type)->first();
//dd($tipo->categories);
return view('store.categories-types')->with(['categories'=>$tipo->categories,'tipo'=>$tipo]);
}
in the table categories_type defined the categories
table categories:
error:

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.

Move the widget to the right side of the web page using bootstrap 4

I want the information tag to be at the right side of the web page. Rest of the things are in the middle of the page. While I am not able to move the information to the right side. Also, because of it the footer disappeared. While I remove the information code, the footer works. Please help me right-align the information widget and also have the footer too.
<div class="container">
<div class="card border-light mb-3 text-center">
<p class="card-header">Videos</p>
</div>
<div id="userSuccess" class="hide" role="alert">
<div id="successUserContent"></div>
</div>
<div class="row" id="userVid">
<?php
$allVid = Schema::getAll();
for ($i = 0; $i < count($allVid); $i++) {
echo <<<HTML
<div class="col-lg-4 col-md-6 mb-4">
<div class="card h-100">
<div class="card-body">
<img class="card-img-top" src="http://placehold.it/700x400" alt="">
<h4 class="card-title">{$allVid[$i]->getTitle()} </h4>
</div>
</div>
</div>
HTML;
}
?>
</div>
<div class="row">
<div class="col-md-4 order-md-2 mb-4">
<div class="card my-4">
<h5 class="card-header">Information</h5>
<div class="card-body">
<div class="row">
<ul class="list-unstyled mb-0">
<li>
...
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
require_once './page/footer.php';
?>
For right align, you'll want to add the class of "justify-content-end" after your "row" class.
<div class="row justify-content-end"><!-- ADDED HERE-->
<div class="col-md-4 order-md-2 mb-4">
<div class="card my-4">
<h5 class="card-header">Information</h5>
<!-- REST OF YOUR CODE-->
For your footer, you'll need to wrap your URL in parenthesis.
<?php require_once('/yourdirectory/yourfooter.php'); ?>

Laravel foreach database issue

I am making a forum and when the user clicks on a theme, a page shows up with every topic that belongs to that theme. The problem is, how do I do this?
I made a for each loop which shows ALL the topics from the database instead of the topics that belong to that theme I clicked on. How can I do this?
Web.php
Route::get('/', 'ThemesController#index')->name('home');
Route::get('/theme/{id}', 'ThemesController#show')->name('showtheme');
ThemesController.php
I only show the show method because I believe that's the only one necessary here
public function show($id)
{
$topics = Topic::all($);
return view('themes/topics')->with('topics', $topics);
}
topics.blade.php
#extends('layouts.default')
#section('content')
<div class="container main-content">
<div class="row first-row">
<div class="col s12">
<div class="card">
<div class="card-content clearfix">Nieuw topic</div>
</div>
</div>
<div class="col s12">
<div class="card">
<div class="card-content"><span class="card-title"> - Topics</span>
<div class="collection">
#foreach($topics as $topic)
<a href="" class="collection-item avatar collection-link"><img src="/uploads/avatars/{{ $topic->user->avatar }}" alt="" class="circle">
<div class="row">
<div class="col s6">
<div class="row last-row">
<div class="col s12"><span class="title">Theme - {{ $topic->topic_title }}</span>
<p>{!! str_limit($topic->topic_text, $limit = 100, $end = '...') !!}</p>
</div>
</div>
<div class="row last-row">
<div class="col s12 post-timestamp">Gepost door: {{ $topic->user->username }} op: {{ $topic->created_at }}</div>
</div>
</div>
<div class="col s2">
<h6 class="title center-align">Replies</h6>
<p class="center replies">{{ $topic->replies->count() }}</p>
</div>
<div class="col s2">
<h6 class="title center-align">Status</h6>
<div class="status-wrapper center-align"><span class="status-badge status-open">open</span></div>
</div>
<div class="col s2">
<h6 class="title center-align">Laatste reply</h6>
<p class="center-align">Naam</p>
<p class="center-align">Tijd</p>
</div>
</div>
</a>
#endforeach
</div>
</div>
</div>
</div>
<div class="col s12">
<div class="card">
<div class="card-content clearfix">Nieuw topic</div>
</div>
</div>
</div>
</div>
#endsection
I believe I'm doing something obviously wrong but I can't see what.
Help will be appreciated. Thanks in advance
If I miss some code, Please inform me.
How are you defining the relationship between a theme and it's topics? You'll have to have something like a one to many or many to many established in your database for you to be able to query correctly. Do you have anything like that yet?
****edit****
public function show($id)
{
$topics = Theme::find($id)->topics;
return view('themes/topics')->with('topics', $topics);
}

Categories