6

I'm wondering if it is worth moving from this code.

@extends('layouts.app')
 
@section('title', 'Page Title')
 
@section('content')
    @foreach ($tasks as $task)
        {{ $task }}
    @endforeach
@endsection

To this one.

<x-layout>
    <x-slot:title>
        Custom Title
    </x-slot>
 
    @foreach ($tasks as $task)
        {{ $task }}
    @endforeach
</x-layout>

I mean is it better to use Laravel components instead of just using @extend, @yeild, and @section etc..

  • 1
    for ````@foreach```` you are still following blade pattern which is inconsistent to the vue template. so, IMO it's not wise now to move it from blade to vue. when all the directives are available in vue component, you can slowly migrate to those. – S K R Mar 03 '22 at 12:43
  • Thank you for replying first. but, Actually I'm not using vue and I don't know about it even. my question is about laravel component which was introduce in laravel 7 – Issa Abdulaziz Mar 03 '22 at 14:42
  • 1
    But you should stick to single type of code. It's good to have consistent quality code. either switch to blade-x or blade. but check which one has all the directives. so, you don't have to mix-up stuffs between them – S K R Mar 03 '22 at 15:37
  • yeah, but just to ensure that I got you right. you're saying that it doesn't matter which one I choose but don't mix between them... one last thing, you sad 'but check which one has all the directives' what does this means – Issa Abdulaziz Mar 03 '22 at 19:34
  • 1
    blade templates is pretty old and has all the required and handy directives (the ````@functions()````) but for blade-x, i dont think all the directives are available as it's quite recent (````````) and also, blade-x is not supported for type hinting and code suggestions in most of the IDEs – S K R Mar 04 '22 at 16:09

0 Answers0