简体   繁体   中英

how to pass database variable in URL anchor tag

            $permissions = DB::table('file_permissions')
                           ->leftjoin('adminfiles','file_permissions.fileid','adminfiles.id')
                           ->where('user_id', $user)
                           ->get();

I am getting these file permissions as per user from the database and listing them in the left column of the admin panel

<ul class="treeview-menu">
            @foreach($permissions as $permission)

            <li><a href="{{ url('$permission->fileaddress')  }}"><i class="fa fa-circle-o"></i> {{ $permission->filename }}</a></li>

            @endforeach
          </ul>

But in the output it makes url like this

http://localhost/laravel/$permission-%3Efileaddress

thanks in advance

Check the Laravel route parameters

https://laravel.com/docs/5.5/routing#route-parameters

Example (see docs)

Route::get('user/{id}', function ($id) {
  return 'User '.$id;
});

Link like that

<a href="{{ route('route-name', ['id' => $id]) }}">link</a>

我认为这可以解决问题。

<a href="{{ url('') }}/{{ $permission->fileaddress }}">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM