Php 三个不同的表合一视图laravel 5.2
嗨,我想用laravel 5.2在一个视图中显示三个不同的表格。但我似乎有问题 my HomeController.phpPhp 三个不同的表合一视图laravel 5.2,php,arrays,laravel,laravel-5.2,Php,Arrays,Laravel,Laravel 5.2,嗨,我想用laravel 5.2在一个视图中显示三个不同的表格。但我似乎有问题 my HomeController.php namespace App\Http\Controllers; use Illuminate\Http\Request; use DB; use App\Http\Requests; use App\Http\Controllers\Controller; class HomeController extends Controller { public func
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class HomeController extends Controller
{
public function index()
{
$about = DB::select('select * from about');
$teams = DB::select('select * from teams');
$services = DB::select('select * from services');
return view('master', ['about' => $about], ['teams' => $teams], ['services' => $services]);
}
}
我认为:
@foreach ($about as $abt)
<h4>{{$abt->title}}</h4>
<span class="semi-separator center-block"></span>
<p>{{$abt->description}}</p>
@endforeach
@foreach ($teams as $team)
<div class="creative-symbol cs-creative">
<img src="assets/images/new/{{$team->icon}}" alt="">
<span class="semi-separator center-block"></span>
<h4><b>{{$team->title}}</b></h4>
<p>{{$team->description}}</p>
</div>
@endforeach
@foreach($abt左右)
{{$abt->title}
{{$abt->description}
@endforeach
@foreach($teams作为$team)
图标}}“alt=”“>
{{$team->title}
{{$team->description}
@endforeach
我无法显示第三个,即$services。请帮助我。
当我添加第三个时,它将显示一个错误请更改:
return view('master', ['about' => $about], ['teams' => $teams], ['services' => $services]);
为此:
return view('master', ['about' => $about, 'teams' => $teams, 'services' => $services]);
在Laravel 5.1中,我在
/vendor/Laravel/framework/src/illumb/Foundation/helpers.php
中找到了以下代码:
if (! function_exists('view')) {
/**
* Get the evaluated view contents for the given view.
*
* @param string $view
* @param array $data
* @param array $mergeData
* @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
*/
function view($view = null, $data = [], $mergeData = [])
{
$factory = app(ViewFactory::class);
if (func_num_args() === 0) {
return $factory;
}
return $factory->make($view, $data, $mergeData);
}
}
这是您试图调用的函数。请注意有多少个参数(共3个)。您试图传入4个参数。我认为您试图执行的操作如下:
return view('master', [
'about' => $about,
'teams' => $teams,
'services' => $services
]);
这正在调用同一个函数,但只传递了两个参数。什么意思?你不能显示第三个参数?你只发布了两个参数的代码。当我添加第三个参数时,它将显示一个错误@ceejayoz它显示了什么错误?没问题!我喜欢laravel!快乐编码:-)