-2
Laravel에서 일하고있는 Im에 문제가 있습니다.Laravel - 컨트롤러 하나로보기가 몇 개 안됨
나는 두 개의 컨트롤러를 만들었습니다 : PostController -보기가 있고 PostController는보기가 있습니다.
다음 컨트롤러를 HomeController라고하고 여기에 컨트롤러 인 PostController와 MyProfileController를 모두 실행하려고합니다.
나는 HomeController의 방법을 만들어 :public function index()
{
$profile_view = app('App\Http\Controllers\MyProfileController')->index();
$post_view = app('App\Http\Controllers\PostController')->index();
return view('home',
[
'profile_view' => $profile_view,
'post_view' => $post_view
]
);
}
그리고 메신저보기에 표시 할
@extends('layout')
@section('main-content')
Something
{!! $profile_view !!}
{!! $post_view !!}
@endsection
(home.blade.php)를 시도하고 $의 post_view에서 하나의보기를 볼 수 있습니다. 누구나이 문제에 대한 아이디어가 있습니까?
컨트롤러에서는 @include가 작동하지 않습니다. 보기와 함께 컨트롤러를 연결해야합니다. – wlodziu
@include는 블레이드 템플릿 작업의 일부이므로 작동하지 않습니다. 업데이트 된 답변보기 –
컨트롤러에서 데이터가있는 뷰가 몇 개 있는데 뷰를 포함하고있을 때 기존 변수가 아닌 오류가 있습니다. – wlodziu