jeudi 27 juillet 2017

Blade file return the code only

The blade file is like this index.blade.php

@foreach ( $users as $user ) 

    <li>{ !! $user['first_name']!! } { !! $user['last_name']!! } from { !! $user['location']!! }</li>

@endforeach

The controller is UsersController and the code is like

class UsersController extends Controller
{
    public function index() {
        $users = [
            0 => [
                'first_name' => 'Ranjit',
                'last_name'  => 'Pradhan',
                'location'   => 'Bhubaneswar'
            ],
            1 => [
                'first_name' => 'Rojalin',
                'last_name'  => 'Pradhan',
                'location'   => 'Angul'
            ]
        ];

        return view( 'admin.users.index', compact('users') );       
    }
}

and the web.php file is like this

Route::get( 'users', [ 'uses' => 'UsersController@index'] );

But i cant get the result like an li, but it is returning the code of blade file.

{ !! $user['first_name']!! } { !! $user['last_name']!! } from { !! $user['location']!! }
{ !! $user['first_name']!! } { !! $user['last_name']!! } from { !! $user['location']!! }

where is the problem ? did i do any mistake ? I am learner.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire