Asking for your help please. I want to show different Applicants on different tabs in my edit.blade.php, I just wondering how can I do that? Please help me.
Controller.php
public function edit($id)
{
$applications = application::where('id', $id)->first();
return view('user.application.edit', compact('applications'));
}
edit.blade.php
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link {{ request()->is('applicant1') ? 'active' : null }}" href="{{ url('applicant1') }}" role="tab">Main Applicant</a>
</li>
<li class="nav-item">
<a class="nav-link {{ request()->is('applicant2') ? 'active' : null }}" href="{{ url('applicant2') }}" role="tab">Applicant 2</a>
</li>
<li class="nav-item">
<a class="nav-link {{ request()->is('applicant3') ? 'active' : null }}" href="{{ url('applicant3') }}" role="tab">Applicant 3</a>
</li>
</ul><!-- Tab panes -->
<div class="tab-pane {{ request()->is('applicant1') ? 'active' : null }}" id="{{ url('applicant1') }}" role="tabpanel">
//FORM HERE
</div>
web.php I was trying different approaches on routes too.
Route::get('applicant1', 'ApplicationController#edit')->name('application.edit');
Route::get ('/applicant2', function () {
return view('application.edit');});
Route::get ('/applicant3', function () {
return view('application.edit');});
Please help me.
Why don't you use a foreach for each applicant element?
In your controller
public function edit($id)
{
$applications = application::all();
return view('user.application.edit', compact('applications'));
}
I your view:
<ul class="nav nav-tabs" role="tablist">
#foreach($applications as $applicant)
<li class="nav-item">
<a class="nav-link {{ request('id') == $applicant->id ? 'active' : ''}}" href="{{ route('application.edit', $applicant->id) }}" role="tab">Main Applicant</a>
</li>
#endforeach
</ul>
<div class="tab-content" id="myTabContent">
#foreach($applications as $applicant)
// the rest of panels
<div class="tab-pane fade show {{ request('id') == $applicant->id ? 'active' : '' }}" id="tab-{{ $loop->iteration }}" role="tabpanel"></div>
#endforeach
</div>
In your routes.php
Route::get('applicants/{id}', 'ApplicationController#edit')->name('application.edit');
Related
I already tried this 2 types of code which is {{Request::is('residential') ? 'active' : ''}} and {{ 'contractor' == request()->path() ? 'active' : '' }} But still nothing is happened. This is my whole code for sidebar.blade.php
<div id="sidebar-nav" class="sidebar">
<div class="sidebar-scroll">
<nav>
<ul class="nav">
#if(auth()->user()->role == 'admin')
<li class="{{Request::is('residential') ? 'active' : ''}}">
<i class="lnr lnr-apartment"></i><span>Residence</span>
</li>
<li class="{{ 'contractor' == request()->path() ? 'active' : '' }}">
<i class="lnr lnr-magic-wand"></i><span>Contractor</span>
</li>
#endif
</ul>
</nav>
</div>
</div>
web.php
Route::group(['middleware' => 'auth','checkRole:admin'], function () {
Route::get('/residential','ResidentialController#index');
Route::get('/contractor', 'ContractorController#index')->name('contractor')
}
What I suppose to do? I hope someone can help me to figure this out.
how to show navbar only when i opening special view. example i have create this is app.blade.php
#guest
<li class="nav-item">
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
</li>
#if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
#endif
#Post
<div>post New</div>
#endPost
#else
#endguest
i want to showing those navbar only if i opening post.blade.php ini my view
Get the route name whois to load post.blade.php this view and then checked if the current route Route::currentRouteName(); match your routes.
//Example
#if('load_view_route_name' == Route::currentRouteName())
//Your Nav or Other elements
#endif
How can I set active selected tab and and also open the sub tab if the page I'm on is a sub page on my sidebar? For example if I open Contractor Association page, the Users tab should expand the highlight Contractor Association tab. Right now every time I open a new page the sidebar is will reset back
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link {{ (request()->is('home')) ? 'text-primary' : '' }}"
href="{{ route('dev-admin.home') }}">
<i class="ni ni-tv-2"></i> {{ __('Dashboard') }}
</a>
</li>
<li class="nav-item">
<a class="nav-link {{ (strpos(Route::currentRouteName(), 'dev-admin.home') == 0) ? 'text-primary' : '' }}"
href="#users" data-toggle="collapse" role="button" aria-expanded="true" aria-controls="users">
<i class="fa fa-users"></i>
<span class="nav-link-text">{{ __('Users') }}</span>
</a>
<div class="collapse {{ (request()->is('dev-admin/developer-admins*') ? 'show' : '' }}"
id="users">
<ul class="nav nav-sm flex-column">
<li class="nav-item">
<a class="nav-link {{ (request()->is('developer-admins')) ? 'text-primary' : '' }}"
href="{{ route('dev-admin.developer-admins.index') }}">
{{ __('Admins') }}
</a>
<a class="nav-link {{ (request()->is('dev-admin/defect-types*')) ? 'text-primary' : '' }}"
href="{{ route('dev-admin.clerk-of-works.index') }}">
{{ __('Clerks of Work') }}
</a>
<a class="nav-link {{ (request()->is('developer-admins')) ? 'text-primary' : '' }}"
href="{{ route('dev-admin.developer-contractor-associations.index') }}">
{{ __('Contractor Association') }}
</a>
</li>
</ul>
</div>
</li>
</ul>
you can write the code like in side bar all the section
<li class="#if(Route::is('developer-admins')) {{ 'active' }} #endif"
<a href="{{ route('dev-admin.developer-admins.index') }}">
{{ __('Admins') }}
</a></li>
and also you can use like
<li class="{{ set_active(['login*']) }}">
Login
</li>
<li class="{{ set_active(['register*']) }}">
Signup
</li>
I am using bellow code for many project which is used into production ready web app and api.
Add bellow line into html class attributes for highlighting active route.
{{ request()->is('dashboard/report') ? 'active' : '' }}
This is really handy for active class.
So I fix it and also show/open tab for selected page by doing something like this, it appears the url I gave is incomplete, thanks everyone for the suggestion..
<div class="collapse {{ (request()->is('dev-admin/developer-admins*') || request()->is('dev-admin/clerks-of-works*') || request()->is('dev-admin/developer-contractor-associations*')) ? 'show' : '' }}"
id="users">
<ul class="nav nav-sm flex-column">
<li class="nav-item">
<a class="nav-link {{ (request()->is('dev-admin/developer-admins*')) ? 'text-primary' : '' }}"
href="{{ route('dev-admin.developer-admins.index') }}">
{{ __('Admins') }}
</a>
<a class="nav-link {{ (request()->is('dev-admin/clerks-of-works*')) ? 'text-primary' : '' }}"
href="{{ route('dev-admin.clerk-of-works.index') }}">
{{ __('Clerks of Work') }}
</a>
</li>
</ul>
</div>
I am new to laravel5.4. By using this url i am trying to make user management. After installing everything i got below error. Please help this out to fix this error
(3/3) ErrorException
Call to undefined method Illuminate\Database\Query\Builder::hasRole() (View: /var/www/html/laravel5/resources/views/layouts/app.blade.php) (View: /var/www/html/laravel5/resources/views/layouts/app.blade.php)
My layout app.blade.php is as below
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
#if (Auth::guest())
<li>Login</li>
<li>Register</li>
#else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
{{ Auth::user()->name }} <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
#role('Admin') {{-- Laravel-permission blade helper --}}
<i class="fa fa-btn fa-unlock"></i>Admin
#endrole
<a href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
Logout
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
</ul>
</li>
#endif
</ul>
I have 2 users which is seller and user. Login function for both is fine but when I login to seller there is no logout button.
Route:
Route::post('/logout', 'Auth\PsController#logout');
psblade:
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
#if (Auth::guest())
<li>Loginnn</li>
<li>Registerr</li>
#else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
{{ Auth::user()->name }} <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="{{ route('/logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
Logout
</a>
<form id="logout-form" action="{{ route('/logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
</ul>
</li>
#endif