Hi all i will be needing an assistance. I have a navbar that all link on my app use but i will like to seclude a search form from some of the link in the app but am having difficulty doing that. This what i have tried on my nabvar so far example
Tried using route but no success
#if( (route('portfolio') &&(route('portfolio.details)
content here
#else
content
#endif
then i tried targeting the URI
#if( Request::is('/portfolio') &&(route('portfolio/details)
content here
#else
content
#endif
None seems to working.
I don't think you should be using the route helper method in your if statement. I think if you just do something like this, it should work.
#if (request()->is('portfolio'))
content
#else
content
#endif
Related
I am trying to pick the master blade template dynamically as per the current user roll logged in. (here it should go to the 'shopowner' auth block)
#auth('shopmanager')
#extends('theme::Admins.shopmanager.layout.master')
#endauth
#auth('shopowner')
#extends('theme::Admins.shopowner.layout.master')
#endauth
but this always gives error as it tries to compile the 'shopmanager' master template. It is not going into the 'shopmanager' #auth block because it's not printing anything if I print inside that block.
It only works if I completely comment out that line.
P.S.:
This is the master theme::Admins.shopmanager.layout.master template file
which must not be loaded.
#extends('theme::Admins.outline.layout.master')
#include('theme::Admins.shopmanager.layout.common.header')
#include('theme::Admins.shopmanager.layout.common.left-sidebar') // The error throws from inside this view.
#include('theme::Admins.shopmanager.layout.common.footer')
#section('title-head', __('Shop Manager'))
I can wrap the #auth check around #include lines but the point is, this complete file should be skipped from the compilation.
SOLVED
As per my learning, #extend(...) will always be compiled regardless of outer wrap conditions. so must be moved to dynamic variable based blocks.
#auth('shopmanager')
#php
$masterTemplate = 'theme::Admins.shopmanager.layout.master';
#endphp
#endauth
#auth('shopowner')
#php
$masterTemplate = 'theme::Admins.shopowner.layout.master';
#endphp
#endauth
#extends($masterTemplate)
Try below code ,i hope this ans help you:
#if(Auth::check())
#if(Auth::user()->role=='shopmanager')
#extends('theme::Admins.shopmanager.layout.master')
#else
#extends('theme::Admins.shopowner.layout.master')
#endif
#endif
If you have multi-authentication that time try below :
#if(Auth::guard('shopmanager')->user())
#extends('')
#else
#extends('')
#endif
In my case, I'm handling manager, customer and admin with this code.
Manager : Auth::guard('manager')->user()
Admin : Auth::user()
Customer : Auth::guard('customer')->user()
hi sorry for my language.
im using laravel 5.6 to create a simple article site.
i have a problem with show article comments as string. the problem is : laravel try to render php codes and the page give me some errors.
imagine a user wants to send his laravel code as comment to me:
(this is just an example)
#foreach($article->tags as $tag)
<a class="tags" href="/tags/{{ $tag->slug }}">{{ $tag->title }}</a>
#endforeach
if user send this codes as comment to me, my page not loading and give me errors
my code to show comments :
{!!$comment->body !!}
help me please . thank you
Replace {!!$comment->body !!} with {{$comment->body }}.
When you use {!! !!}}, the template engine tries to parse the contents within the braces. Use {{ }} so that the contents are displayed as it is escaping all html.
i found the problem :
problem is for laravel blade codes.
like: #foreach . #if . #auth and ....
i have to scape this codes with space :
# foreach . # if and ....
I am using laravel 5.3.
I know that how can paginate large data set and how to work it.
Pagination links shown Even if just one page is require to show result. but I want to hide pagination links in this case?
I use render() method to show pagination links like this :
<nav id="pagination">
{!! $posts->render() !!}
</nav>
Any idea?
The best way to handle this is to hide the links to the pagination in your front-end if total <= per_page.
If you're using laravel's links() method you can do the following:
#if($results->total() > $results->perPage())
{{ $results->links }}
#endif
Here is better approach by undocumented method, for Laravel 5.0 and later.
#if ($results->hasPages())
{{ $results->links() }}
#endif
Link to method:
https://laravel.com/api/5.8/Illuminate/Contracts/Pagination/Paginator.html#method_hasPages
Because I want to apply this behavior to all paginations on the whole laravel project ,I used #Vuldo suggested approach to default.blade.php view in the resources/views/vendor/pagination directory like this :
#if($paginator->total() > $paginator->perPage())
<ul class="pagination">
...
</ul>
#endif
I have this in my blade file:
#if(Session::has('logged'))
#include('layouts.usernav')
#else
#include('layouts.publicnav')
#endif
When I run my page, it is just a blank page.
When I change it to look like this:
#if(1 == 1)
#include('layouts.usernav')
#else
#include('layouts.publicnav')
#endif
My page gets displayed. I don't know what I am doing wrong. What would/could be causing this?
How would you do this using blade's #import method? I've tried:
#if (#include('/path/to/phpfile'))
#include('/path/to/phpfile')
#else
<h2>Oops! It doesn't look like this page exists!</h2>
#endif
also tried with file_exists(), no dice :(
You may try this:
#if(View::exists('viewname'))
#include('viewname')
#endif