मैं लैरवेल 4 दस्तावेज के माध्यम से पढ़ रहा हूं और सीखने में मदद के लिए डेमो एप्लीकेशन बना रहा हूं।लैरवेल 4 कंट्रोलर टेम्पलेटिंग/ब्लेड - सही तरीका?
मुझे ब्लेड और नियंत्रकों के साथ विचारों के टेम्पलेटिंग पर अधिक दस्तावेज नहीं मिल सका। सही विधि कौन सा है या क्या यह व्यक्तिगत वरीयता पर आती है?
E.g. 1
नियंत्रकों/HomeController.php
protected $layout = 'layouts.main';
public function showWelcome()
{
$this->layout->title = "Page Title";
$this->layout->content = View::make('welcome');
}
दृश्य/लेआउट/main.blade.php
<html>
<head>
<title>{{ $title }}</title>
</head>
<body>
{{ $content }}
</body>
</html>
दृश्य/welcome.blade.php
<p>Welcome.</p>
E.g. 2
नियंत्रकों/HomeController.php
protected $layout = 'layouts.main';
public function showWelcome()
{
$this->layout->content = View::make('welcome');
}
दृश्य/लेआउट/main.blade.php
<html>
<head>
<title>@yield('title')</title>
</head>
<body>
@yield('content')
</body>
</html>
दृश्य/welcome.blade.php
@section('title', 'Welcome')
@section('content')
// content
@stop
उपरोक्त के सर्वोत्तम सम्मेलन और/या फायदे क्या हैं?
कृपया उपरोक्त उदाहरणों या सही तरीके से नहीं, तो कृपया मुझे सही करें! – Mediabeastnz