'yield inside section in Laravel 8

I am trying to yield a section inside another section which is itself yielded in master.blade.php, but it does not work.

master.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    welcome to X store
    
    @yield('content')
</body>
</html>

shop.blade.php (This is the view that I have called in the router) view('shop')

@extends('master')

@section('content') 
    <h1> Hello ! This is Shop page </h1>
    @yield('products')
@endsection

products-grid.blade.php => this is the section that i want to yield in Shop view

@extends('shop')

@section('products')
    <h3> product 1 </h3>
    <h3> product 2 </h3>
    <h3> product 3 </h3>
    <h3> product 4 </h3>
@endsection

result

welcome to X store
Hello ! This is Shop page


Solution 1:[1]

In products-grid.blade.php try @parent after @section('products')

Solution 2:[2]

you can simply use

@include ('products-grid') instead of @yield('products')

Solution 3:[3]

I guess this is the problem that you cannot yield before finishing a section try to call the yield out side of the section

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Harsh vaghasiya
Solution 2 Dhruvik Ghevariya
Solution 3 VANITA CHAUDHARI