You are using laravel-4 template comment syntax to define/set variables which is may be not working with L5.x.
But you can try @php ($p3 = $key['p3'])
OR
@php
$p3 = $key['p3']
@endphp
Above both are same.
Further you go with create own service provider like
<?php
//app/Providers/BladeServiceProvider.php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class BladeServiceProvider extends ServiceProvider
{
public function boot()
{
/* @datetime($var) */
\Blade::extend(function($view, $compiler)
{
$pattern = $compiler->createOpenMatcher('datetime');
return preg_replace($pattern, '$1<?php echo $2->format(\'m/d/Y H:i\')); ?>', $view);
});
/* @eval($var++) */
\Blade::extend(function($view)
{
return preg_replace('/\@eval\((.+)\)/', '<?php ${1}; ?>', $view);
});
}
public function register()
{
//
}
}
<?php
//in config/app.php add
return [
// ...
'providers' => [
// ...
'App\Providers\BladeServiceProvider',
Clear complied
artisan clear-compiled
Assign value to variable
@datetime($updated_at)
OR
@eval($var = 1)
Taken reference from: Laravel 5 alternative
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community