tobia

tobia

Member Since 2 Years Ago

Experience Points 1,110
Experience
Level
Lessons Completed 4
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

06 Jul
2 years ago

tobia left a reply on Render Template From Blade Template In Database

I know this is old, but other people might find the answer useful.

As you have figured out, you can use Blade::compileString() to compile a piece of Blade template, taken for example from a DB column. What are Blade templates compiled to? If you look into storage/framework/views/ in your project folder, you will see that they are compiled into PHP code.

In fact, this is what compileString does:

Blade::compileString('Hello, {{ $planet }}!') 
===
'Hello, <?php echo e($planet); ?>!'

How can you evaluate that piece of PHP code against a custom array of variables?

Taking a hint from Illuminate\View\Engines\PhpEngine, here is one possible implementation:

function render($__php, $__data)
{
    $obLevel = ob_get_level();
    ob_start();
    extract($__data, EXTR_SKIP);
    try {
        eval('?' . '>' . $__php);
    } catch (Exception $e) {
        while (ob_get_level() > $obLevel) ob_end_clean();
        throw $e;
    } catch (Throwable $e) {
        while (ob_get_level() > $obLevel) ob_end_clean();
        throw new FatalThrowableError($e);
    }
    return ob_get_clean();
}

And here is how you'd use it in a route or in a controller method:

$blade = 'Hello, {{ $planet }}!';
$php = Blade::compileString($blade);
return render($php, ['planet' => 'World']);
06 Jun
2 years ago

tobia started a new conversation Can A Section @yield Itself? (Decorator Pattern)

I would like to use the Decorator pattern on blade views, like this:

Master layout: ... ... @yield('content')

Sub-layout: @extends('layouts.master') @section('content') @yield('content') @stop

View: @extends('layout.subLayout') @section('content') My Content @stop

But I'm not getting the markup added by the sub-layout. Can a section @yield itself, meaning using / decorating the content defined by the child view?

15 Apr
2 years ago

tobia left a reply on .gitignore What Should Be Ignored?

On the other hand, if you gitignore the vendor folder, you won't be able to use Git for deployment (push to your server to update your website) because you will have to run composer on your server. Plus, if some repository suddenly goes away from the Internet or is modified or corrupted (it happens) then you won't be able to run your old project anymore.

tobia left a reply on Do You Add Your CSS Files In Public/css/* To Your .gitignore ?

What about development vs. production then?

Should I require all developers to run gulp --production (and commit) before pushing changes?

Otherwise I'll deploy non-minified public/css and js files

02 Mar
2 years ago

tobia left a reply on How To Change The .env Filename

My point is that .gitignore is a configuration file for version control, that is only edited when you need to and then left alone.

OTOH the ENV file needs to be visible and prominent (I'm even thinking of making it all caps) because it's the central configuration file for a given deployment or working copy. Whenever something is not working, it's the first place you (or an admin) should look into. Making it a hidden file is just looking for trouble and for a lot of wasted time.

29 Feb
2 years ago

tobia left a reply on How To Change The .env Filename

Not unless you hide all hidden files and folders by default:

"file_exclude_patterns": [".*"],
"folder_exclude_patterns": [".*"],

which is how hidden files and folders should stay, IMHO

tobia started a new conversation How To Change The .env Filename

I would like to load the environment from a env file instead of .env The reason is that my team will use Linux and Mac OS X, where dotfiles are hidden by default, so it may (will) become bothersome to check the existence of a hidden file whenever something is not working, especially one that is ignored by version control (as the env should be.) I managed to do it like this. Is it the right way? bootstrap/app.php: $app->loadEnvironmentFrom('env');

22 Jan
2 years ago

tobia started a new conversation Why Do All Generated Files Use Spaces For Indentation?

I was under the impression that Laravel favoured tabs over spaces (which I agree on) but all generated files, by the installer, by migrations, and so on, use four spaces.

Is there a global preference somewhere?

I'm using 5.2.10