当我试图在 laravel 中制作帖子的轮播滑块时,我遇到了一个错误
Posted
技术标签:
【中文标题】当我试图在 laravel 中制作帖子的轮播滑块时,我遇到了一个错误【英文标题】:while I were trying to make carousel slider of posts in laravel I have get an error that is 【发布时间】:2019-07-24 06:27:17 【问题描述】:@extends('layouts.app')
<style type="text/css">
.avatar
border-radius: 100%;
max-width:100px;
</style>
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 col-md-offset">
@if(count($errors) > 0)
@foreach($errors->all() as $error)
<div class="alert alert-danger">$error</div>
@endforeach
@endif
<div class="card-body">
@if (session('response'))
<div class="alert alert-success" role="alert">
session('response')
</div>
@endif
<div class="card">
<div class="card-header">Dashboard</div>
<div class="panel-body">
<div class="col-md-4">
@if(!empty($profile))
<img src=" $profile->profile_pic" class="avatar" >
@else
<img src=" url('images/avatar.jpg')" class="avatar" >
@endif
@if(!empty($profile))
<p class="lead"> $profile->name</p>
@else
<p></p>
@endif
@if(!empty($profile))
<p class="lead"> $profile->designation</p>
@else
<p></p>
@endif
</div>
<div class="group-home-slideshow">
<div class="home-slideshow-inner col-sm-12">
<div class="home-slideshow">
<div id="home_main-slider" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators">
@foreach($posts as $post)
<li data-target="#home_main-slider" data-slide-to=" $loop->index " class=" $loop->first ? 'active' : '' "></li>
@endforeach
</ol>
<div class="carousel-inner">
@foreach($posts as $post)
<div class="item image $loop->first ? ' active' : '' ">
<img src="url('images')/$slider->photo" title="Image Slideshow">
<div class="slideshow-caption position-right">
<div class="slide-caption">
<div class="group-caption">
<div class="content">
@if(count($posts) >0)
@foreach($posts->all() as $post)
<h4>$post->post_title</h4>
<img src="$post->post_image" >
<p> substr($post->post_body , 0 , 150)</p>
</div>
<ul class="nav nav-pills">
<li role="presentation">
<a href=' url("/view/$post->id") '>
<span class="fa fa-eye"> View</span>
</a>
</li>
<li role="presentation">
<a href=' url("/edit/$post->id") '>
<span class="fa fa-edit"> Edit</span>
</a>
</li>
<li role="presentation">
<a href=' url("/delete/$post->id") '>
<span class="fa fa-trash-alt"> Delete</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
@endforeach
</div>
<a class="left carousel-control" href="#home_main-slider" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#home_main-slider" data-slide="next">
<span class="icon-next"></span>
</a>
</div>
</div>
</div>
</div>
@endsection
我有 ErrorException 的错误消息抛出
"语法错误,文件意外结束,期待 elseif (T_ELSEIF) 或 else (T_ELSE) 或 endif (T_ENDIF) (查看: C:\xampp\htdocs\blog\resources\views\home.blade.php)"
堆栈跟踪:
0 Symfony\Component\Debug\Exception\FatalThrowableError in C:\xampp\htdocs\blog\storage\framework\views\78e09b18337fc09824b99eedafb8d772ac9d9d5d.php:125
【问题讨论】:
【参考方案1】:您还没有关闭一个if
和一个foreach
:
<div class="content">
@if(count($posts) >0)
@foreach($posts->all() as $post)
<h4>$post->post_title</h4>
<img src="$post->post_image" >
<p> substr($post->post_body , 0 , 150)</p>
@endforeach
@endif
</div>
【讨论】:
以上是关于当我试图在 laravel 中制作帖子的轮播滑块时,我遇到了一个错误的主要内容,如果未能解决你的问题,请参考以下文章