Summary
A custom blade directive does not use the current value in the database without clearing the view cache first. Since that value can be changed by the user and affects the view I need the directive to always pull the current value from the DB, not use the cached one (this works for directives like @auth, so why not my custom one?).
Background
I have written a custom directive using this tutorial, it does basically the same thing shows different content depending on a value stored in the database. The problem I'm running into is if the variable changes from false to true for example, the directive is stuck with the old value, it doesn't update it when it is changed in the DB. It does work when I clear the view cache, but I want it to always use the current value stored in the database.
Code
\Blade::directive('signup_done', function () {
$condition = false;
if (\Auth::check()) {
if (\Auth::user()->signup_done) $condition = true;
}
return "<?php if ($condition) { ?>";
});
Expected vs actual results
signup_done
is false
by default for each user, if it changes to true
I want the directive to output true, but it's stuck in false until I clear the view cache.