title: How to know the controller and method name inside blade file in Laravel 6?
body: <p>I am new to Laravel. I was practicing setting up a blog in <strong>Laravel 6</strong>. I have a <code>layout.blade.php</code> file where all the basic HTML is written. In the content section of the <code>layout.blade file</code>, I want to <code>@include</code> other blade file depending on the controller and method name. </p>
  
  <p>I have 2 controllers, <code>HomeController</code> and <code>ArticleController</code>. In <code>HomeController</code> file, there is a method <code>index()</code> which returns the view <code>home.blade.php</code>. Again, <code>home.blade.php</code> <code>@extends</code> <code>layout.blade.php</code>. Now I want to know which controller and method called the view file inside from <code>layout.blade.php</code> file.</p>
  
  <p>I want something like this-</p>
  
  <pre><code>&lt;!-- This is layout.blade.php file --&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
    @if (Controller == HomeController AND Method == index)
      @include('home')
    @endif
  
    @if (Controller == ArticleController AND Method == index)
      @include('articles')
    @endif
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I didn't find any answer on Google. I got some questions in StackOverflow, but they have very confusing answers and those versions are older also.</p>
  
  <p>Thank you.</p>
  
  <p>EDIT 1:</p>
  
  <ol>
  <li>Due to the low reputation score, I cannot reply in comments. As I am
  new, I know some basic tags of blade, so if there is any other
  solution to achieve this, please share it with me.</li>
  <li>I found
  <a href="https://stackoverflow.com/questions/29549660/get-laravel-5-controller-name-in-view">Get Laravel 5 controller name in view</a>
  before making this question. But I don't think it answers my
  question.</li>
  <li>I know <code>Controller == HomeController AND Method == index</code> is crazy.
  I just illustrated what I need. I know basic <code>@yield</code> and <code>@section</code>
  tags, but I don't want to use this in my case. Because, if I make a
  card/home section entirely in a different file, I can call it in
  other files later. If I use <code>@yield</code>, I will have to use <code>@section</code> in
  different files also, which I don't want to do.</li>
  </ol>