IrajJavidan
6 سال پیش توسط IrajJavidan مطرح شد
0 پاسخ

دستور auth در blade

با سلام
دستور @auth و @endauth در blade رو اگه ممکنه توضیح بدید. چطور باید از این ها استفاده کنم. من از لاراول استفاده نمی کنم و فقط از blade استفاده می کنم.
مثالش اینه

require "vendor/autoload.php";

Use eftec\bladeone;

$views = __DIR__ . '/views';
$cache = __DIR__ . '/cache';
$blade=new bladeone\BladeOne($views,$cache,BladeOne::MODE_AUTO);

$blade->setAuth('johndoe','admin'); // where johndoe is an user and admin is the role. The role is optional

echo $blade->run("hello",array("variable1"=>"value1"));

و در view

@auth
    // The user is authenticated...
@endauth

@guest
    // The user is not authenticated...
@endguest

یا

@auth('admin')
    // The user is authenticated...
@endauth

@guest('admin')
    // The user is not authenticated...
@endguest

حالا من چطآر مثلا وقتی سشن کاربری رو چک کردم از این دستور استفاده کنم.
این هم لینک github بسته https://github.com/EFTEC/BladeOne