T
T
The-TS2020-10-23 22:43:19
Laravel
The-TS, 2020-10-23 22:43:19

Blade and error?

I'm trying to create my own directive, but PHP decided to give me THIS error. How to fix it?

/app/Providers/AppServiceProvider.php :

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Blade::component('particlas.modal', 'modal');
        view()->composer('particlas.modal', function ($view) {
          $view->with('test', 'test');
        });
        Blade::directive('ifTest', function () {
          return "<?php if(!1>2): ?>";
        });
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2020-10-23
@Pyhon3x

<?php if(!1>2): ?>

Well, what do you want? Insert such a line into any code and it will fail with the same error.
This should be complete working code.
And so you get inserted into the template if(1=2) {without a closing bracket.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question