Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php laravel 5.6旋转木马引导_Php_Laravel_Carousel - Fatal编程技术网

Php laravel 5.6旋转木马引导

Php laravel 5.6旋转木马引导,php,laravel,carousel,Php,Laravel,Carousel,我正在准备上次考试 所以,可能有一些明显的东西我没有看到 我已经创建了一个旋转木马,工作良好 问题是,当我调用数据时,它不会循环遍历我的所有数据: 编辑 对不起,我想我还不够清楚: 我设法得到了所有的数据。db有4个项目,分别命名为项目1、项目2、项目3和项目4 我的问题是,当我通过foreach()循环时,只有一个幻灯片在移动:第一个 我的索引视图: @extends('layouts.app') @section('content') <br>

我正在准备上次考试

所以,可能有一些明显的东西我没有看到


我已经创建了一个旋转木马,工作良好

问题是,当我调用数据时,它不会循环遍历我的所有数据:


编辑

对不起,我想我还不够清楚:

我设法得到了所有的数据。db有4个项目,分别命名为项目1、项目2、项目3和项目4

我的问题是,当我通过foreach()循环时,只有一个幻灯片在移动:第一个


我的索引视图:

    @extends('layouts.app')
    @section('content')
    <br>
    <br>
    <br>
    <title>{{$title}}</title>
            <h1 class="text-center">This is my work:</h1>
            <br>
            <br>
    <div id="carouselExampleIndicators" class="carousel slide" data-

ride="carousel">
        @foreach($projects as $project)
            <div class="carousel-inner text-center" role="listbox">
                <div class="carousel-item active">
                    <h2>{{$project->name}}</h2>
                    <img class="d-block w-100 img-fluid" src="{{asset('Caroussel/laravel.png')}}" height="150" width="150">
                    <p>{{$project->description}}</p>
                    <!--TAGS-->
                </div>

                <div class="carousel-item">
                        <h2>{{$project->name}}</h2>
                        <img class="d-block w-100 img-fluid" src="{{asset('Caroussel/chatbot.png')}}" height="150" width="150">
                        <p>{{$project->description}}</p>
                        <!--TAGS-->
                </div>

                <div class="carousel-item">
                        <h2>{{$project->name}}</h2>
                        <img class="d-block w-100 img-fluid" src="{{asset('Caroussel/iot.png')}}" height="150" width="150">
                        <p>{{$project->description}}</p>
                        <!--TAGS-->
                </div>

                <div class="carousel-item">
                        <h2>{{$project->name}}</h2>
                        <img class="d-block w-100 img-fluid" src="{{asset('Caroussel/php.png')}}" height="150" width="150">
                        <p>{{$project->description}}</p>
                        <!--TAGS-->
                </div>
            </div>
        @endforeach

        <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
        </a>

        <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>
    </div> 
    @endsection
@extends('layouts.app'))
@节(“内容”)



{{$title}} 这是我的工作:

@foreach($项目作为$项目) {{$project->name} {{$project->description}

{{$project->name} {{$project->description}

{{$project->name} {{$project->description}

{{$project->name} {{$project->description}

@endforeach @端部
控制员:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Project;
use App\Tag;

class ProjectController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $title = 'My work';
        $projects = Project ::all();
        return view('projects.index')->with('title',$title)->with('projects',$projects);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}

那么,如果我理解正确,它不会从数据库中获取所有项目?您可以a)检查数据库中的实际内容吗?b)检查
dd(Project::all())
返回的内容吗?您好,谢谢您的回答。在我的数据库中,我有项目1、项目2、项目3和项目4。我设法把它们都弄到手了。项目1应与laravel img相连;项目2到PHP img等。在我的工作中,项目1链接到所有东西:laravel、PHP等。它也是唯一一个“移动”的项目。你想要4个不同的旋转木马还是一个循环所有项目的旋转木马?嗨,谢谢你的回答。我想要一个能循环所有项目的。
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Project extends Model
{
    public function tags(){
        return $this->belongsToMany('App\Tag','project_tag','projects_id','tags_id');        
    }

}