如何在Laravel 5.5中重用包含mysql获取数据的刀片模板

如何在Laravel 5.5中重用包含mysql获取数据的刀片模板,laravel,laravel-blade,extends,Laravel,Laravel Blade,Extends,我是一个初学者,我正在控制器中创建一个视图,如下所示 public function withdrawals() { return view('withdrawals') ->with(array( 'title'=>'withdrawals', 'withdrawals' => withdrawals::where('user', Auth::user()->id)->get(), 'settings' =>

我是一个初学者,我正在控制器中创建一个视图,如下所示

public function withdrawals()
 {
   return view('withdrawals')
     ->with(array(
     'title'=>'withdrawals',
     'withdrawals' => withdrawals::where('user', Auth::user()->id)->get(),
     'settings' => settings::where('id', '=', '1')->first(),
     'wmethods' => wdmethods::where('type', 'withdrawal')
     ->where('status','enabled')->orderby('name')->get(),
     ));
 } 

因此,我将视图返回到
resources/views/drawings.blade.php
。还有另一个文件
dashboard.blade.php
并从
返回视图('dashboard')
为仪表板创建视图。我还想重用
dashboard.blade.php
文件中的
取款
视图,而无需创建另一个文件。如何访问从另一个刀片模板中的数据库中提取的现有刀片内容及其所有数据?

基本上,您必须关注刀片扩展中的组件和插槽

看看这个

我基本上在布局设置时使用这个。因为页眉、页脚、侧边栏等内容在所有页面中都很常见。请看一看,它可能对你有帮助

master.blade.php

<!DOCTYPE html>
<html>
<head>
    @include('Admin::Layouts.head-scripts')
    @yield('head-content')
    @yield('page-style')
</head>
<body class="hold-transition skin-blue sidebar-mini">

    {{------------------------------------------CONTENT GOES HERE-----------------------------------------}}
<div class="wrapper">
    @include('Admin::Layouts.header')
    @include('Admin::Layouts.sidebar')
    @yield('page-content')
    @include('Admin::Layouts.footer')
</div>



@include('Admin::Layouts.footer-scripts')
@yield('page-scripts')
</body>
</html>

@包括('Admin::Layouts.head脚本')
@产量(‘总含量’)
@收益率('页面样式')
{{-------------------------------------------内容在这里--------------------------------}
@包括('Admin::Layouts.header')
@包括('Admin::Layouts.sidebar')
@收益率('页面内容')
@包括('Admin::Layouts.footer')
@包括('Admin::Layouts.footer脚本')
@产量('page-scripts')
使用中提到的@section和@overwrite语法来实现这一点

@extends('default')

@section('content')

    {{-- First Panel --}}
    @section('heading')
        Welcome, {{ $user->name }}
    @overwrite
    @section('inner')
        <p>Welcome to the site.</p>
    @overwrite
    @include('panel')

    {{-- Second Panel --}}
    @section('heading')
        Your Friends
    @overwrite
    @section('inner')
        <ul>
        @foreach($user->friends as $friend)
            <li>{{ $friend->name }}</li>
        @endforeach
        </ul>
    @overwrite
    @include('panel')

@stop
@extends('default')
@节(“内容”)
{{--第一个面板--}
@节(“标题”)
欢迎,{{$user->name}
@覆盖
@节(“内部”)
欢迎来到这个网站

@覆盖 @包括(‘面板’) {{--第二个面板--} @节(“标题”) 你的朋友 @覆盖 @节(“内部”)
    @foreach($user->friends as$friends)
  • {{$friend->name}
  • @endforeach
@覆盖 @包括(‘面板’) @停止
仪表板是否确实需要包含
取款
视图,或者您只需要在
取款
方法中附加到视图的数据?是的,正如我提到的,我也想从mysql获取数据。我试过了@在dashboard.blade.php中扩展(“取款”)。它带来了整个页面,但没有数据。我还想要取款的某些特定部分。blade页面而不是整个页面。谢谢您的回答,那么我如何使用上述方法将
取款的所有数据添加到
内部
仪表板。blade
?你能说得更具体些吗?