With this following, I code I can view all the categories but I want to show the subcategories of the first array item.
#elseif ($categoriesOptions['cat_display_type'] == 'c_bigIcon_list')
#if (isset($categories) and $categories->count() > 0)
#foreach($categories as $key => $cat)
<div class="col-lg-2 col-md-3 col-sm-4 col-6 f-category">
<a href="{{ \App\Helpers\UrlGen::category($cat) }}">
#if (in_array(config('settings.list.show_category_icon'), [2, 6, 7, 8]))
<i class="{{ $cat->icon_class ?? 'fas fa-folder' }}"></i>
#endif
<h6>
{{ $cat->name }}
#if (config('settings.list.count_categories_listings'))
({{ $countPostsByCat->get($cat->id)->total ?? 0 }})
#endif
</h6>
</a>
</div>
#endforeach
#endif
and if I do dd() this. It shows the following result.
<?php dd($categories); ?>
Any suggestion?
Related
I need to show nested notes if were exist into my table, I have worked it these way, it works only for first row, and I can't know what i did wrong.
this is my code:
<td>
#inject('Common', 'App\Http\Controllers\AuditYearController')
#if($Common->has_entry_note($entry->id) == 'true')
<ul id="treeview1">الملاحظات
#foreach($entry_notes=$Common->get_entry_notes($entry->id) as $es)
<li>{{ $es->text }}
<ul>
<li>{{ $es->suggestion }}</li>
<li>{{ $es->clarification }}</li>
</ul>
</li>
#endforeach
</ul>
#else
لا يوجد ملاحظات
#endif
</td>
and this is the result.
I solved it by using accordion.
<td>
#inject('Common', 'App\Http\Controllers\AuditYearController')
#if ($Common->has_entry_note($entry->id) == 'true')
#foreach ($entry_notes = $Common->get_entry_notes($entry->id) as $es)
<div class="accordion accordion-flush" id="e{{ $es->en_id }}">
<div class="accordion-item">
<h6 class="accordion-header" id="head{{ $es->en_id }}">
<a class="collapsed" type="button" data-toggle="collapse"
data-target="#one{{ $es->en_id }}" aria-expanded="true"
aria-controls="one{{ $es->en_id }}">
<i class="si si-plus text-teal"></i><strong>{{ $es->text }}</strong></a></h6>
<div id="one{{ $es->en_id }}" class="accordion-collapse collapse"
aria-labelledby="head{{ $es->en_id }}" data-parent="#e{{$es->en_id }}">
<div class="accordion-body">
{{ $es->suggestion }}
{{ $es->clarification }}
</div><br>
</div>
</div>
</div>
#endforeach
#else
لا يوجد ملاحظات
#endif
</td>
I'm getting this error when clicking a button on my dashboard
And this error only happens in the customization part, in other sections everything works fine
It gives me the solution below but I don't know how to apply
$name is undefined
Make the variable optional in the blade template. Replace {{ $name }} with {{ $name ?? '' }}
Undefined variable $name (View: /home/dir/mysite.com/resources/views/admin/settings/personalization.blade.php)
#push('styles_top')
#endpush
#section('content')
<section class="section">
<div class="section-header">
<h1>{{ trans('admin/main.personalization') }} {{ trans('admin/main.settings') }}</h1>
<div class="section-header-breadcrumb">
<div class="breadcrumb-item active">{{ trans('admin/main.dashboard') }}</div>
<div class="breadcrumb-item active">{{ trans('admin/main.settings') }}</div>
<div class="breadcrumb-item ">{{ trans('admin/main.personalization') }}</div>
</div>
</div>
<div class="section-body">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
#php
$items = ['page_background','home_sections','home_hero','home_hero2','home_video_or_image_box',
'panel_sidebar','find_instructors','reward_program','become_instructor_section',
'theme_colors', 'theme_fonts', 'forums_section', 'navbar_button','cookie_settings','mobile_app',
'others_personalization'
]
#endphp
<ul class="nav nav-pills" id="myTab3" role="tablist">
#foreach($items as $item)
<li class="nav-item">
<a class="nav-link {{ ($item == $name) ? 'active' : '' }}" href="/admin/settings/personalization/{{ $item }}">{{ trans('admin/main.'.$item) }}</a>
</li>
#endforeach
</ul>
<div class="tab-content">
#include('admin.settings.personalization.'.$name,['itemValue' => (!empty($values)) ? $values : ''])
</div>
</div>
</div>
</div>
</div>
</div>
</section>
#endsection
#push('scripts_bottom')
#endpush
I've tried several solutions suggested in other posts, but none worked.
What's wrong?
IN:
/home/dir/mysite.com/resources/views/admin/settings/personalization.blade.php)
error: You have not any variable $name.
Solution:
check that into controller, you are sending variable with view file?
return view('file_path')->with("name", $valueVariable);
return view("file_path".["name" => $valueVariable]);
I have two tables name is courses and admissions. Now i want to set if user purchase the course then show admitted else show course price. please check the below code:
$courses = Course::orderby('id', 'desc')->get();
$admission = Admission::where('users_id', Auth::user()->id)->first() ?: app(Admission::class);
return view('Backend.Student.courses', compact('courses', 'admission'));
here is my condition in blade file:
#if( $course->id == $admission->courses_id )
<li class="list-inline-item">
<h5 class="p-0 m-0 text-white"> {{ __('Admitted') }}</h5>
</li>
#if( !empty($admission->status == 'active') )
<li class="list-inline-item">
<h5 class="p-0 m-0 text-white"> {{ __('Continue Course') }}</h5>
</li>
#endif
#else
<li class="list-inline-item">
<h5 class="p-0 m-0 text-white"> {{ __('Admission Now') }}</h5>
</li>
<li class="list-inline-item">{{ __('Price') }}: ৳{{ number_format( $course->price , 0 , '.' , ',' ) }} BDT</li>
#endif
This course is working but its showing only one course. When same user purchage multiple course it will show only one course is admitted. But i want if a user purchases multiple courses it should be shown admitted each course. Sorry for my bad english and thanks for your kindness.
You are fetching just the first record for admissions, hence there will be only one record.
To get all Admission records for the currently logged in user
$courses = Course::latest('id')->get();
$admissions = Admission::where('user_id', Auth::id())->get();
return view('Backend.Student.courses', compact('courses', 'admissions'));
In blade view, you loop over the user's admissions
#foreach($courses as $course)
{{-- If the user has purchased course --}}
#if(in_array($course->id, $admissions->pluck('course_id')->toArray())
#foreach($admissions as $admission)
{{-- If the course is active --}}
#if($admission->course_id === $course->id && $admission->status === 'active')
<li class="list-inline-item">
<h5 class="p-0 m-0 text-white"> {{ __('Continue Course') }}</h5>
</li>
#elseif($admission->course_id === $course->id && $admission->status !== 'active')
{{-- If the course is not active --}}
<li class="list-inline-item">
<h5 class="p-0 m-0 text-white"> {{ __('Admitted') }}</h5>
</li>
#endif
#endforeach
#else
{{-- User has not purchased the course --}}
<li class="list-inline-item">
<h5 class="p-0 m-0 text-white"> {{ __('Admission Now') }}</h5>
</li>
<li class="list-inline-item">{{ __('Price') }}: ৳{{ number_format( $course->price , 0 , '.' , ',' ) }} BDT</li>
#endif
#endforeach
I want to add my slider to my home page and when i add using #inclued method and it returns error undefended variable in slider page but it works well in slider page however i added it to home page error occurs. how do i correct this.
error msg-
Undefined variable $data (View: \resources\views\frontendslider.blade.php)
In the: \resources\views/frontendslider.blade.php file at line: 29
codes....
homepage
* LaraClassifier - Classified Ads Web Application
* Copyright (c) BeDigit. All Rights Reserved
*
* Website: https://laraclassifier.com
*
* LICENSE
* -------
* This software is furnished under a license and may be used and copied
* only in accordance with the terms of such license and with the inclusion
* of the above copyright notice. If you Purchased from CodeCanyon,
* Please read the full License from here - http://codecanyon.net/licenses/standard
--}}
#extends('layouts.master')
#section('search')
#parent
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.form', 'search.inc.form'])
#endsection
#section('content')
<div class="main-container">
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.breadcrumbs', 'search.inc.breadcrumbs'])
#if (config('settings.list.show_cats_in_top'))
#if (isset($cats) && $cats->count() > 0)
<div class="container mb-2 hide-xs">
<div class="row p-0 m-0">
<div class="col-12 p-0 m-0 border border-bottom-0 bg-light"></div>
</div>
</div>
#endif
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.categories', 'search.inc.categories'])
#endif
<?php if (isset($topAdvertising) && !empty($topAdvertising)): ?>
#includeFirst([config('larapen.core.customizedViewPath') . 'layouts.inc.advertising.top', 'layouts.inc.advertising.top'], ['paddingTopExists' => true])
<?php
$paddingTopExists = false;
else:
if (isset($paddingTopExists) && $paddingTopExists) {
$paddingTopExists = false;
}
endif;
?>
<div class="container">
<div class="row">
{{-- Sidebar --}}
#if (config('settings.list.left_sidebar'))
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.sidebar', 'search.inc.sidebar'])
<?php $contentColSm = 'col-md-9'; ?>
#else
<?php $contentColSm = 'col-md-12'; ?>
#endif
{{-- Content --}}
<div class="{{ $contentColSm }} page-content col-thin-left mb-4">
<div class="category-list {{ config('settings.list.display_mode', 'make-grid') }}{{ ($contentColSm == 'col-md-12') ? ' noSideBar' : '' }}">
<div class="tab-box">
{{-- Nav tabs --}}
<ul id="postType" class="nav nav-tabs add-tabs tablist" role="tablist">
<?php
$aClass = '';
$spanClass = 'alert-danger';
if (config('settings.single.show_listing_types')) {
if (!request()->filled('type') || request()->get('type') == '') {
$aClass = ' active';
$spanClass = 'bg-danger';
}
} else {
$aClass = ' active';
$spanClass = 'bg-danger';
}
?>
<li class="nav-item">
<a href="{!! qsUrl(request()->url(), request()->except(['page', 'type']), null, false) !!}" class="nav-link{{ $aClass }}">
{{ t('All Listings') }} <span class="badge badge-pill {!! $spanClass !!}">{{ $count->get('all') }}</span>
</a>
</li>
#if (config('settings.single.show_listing_types'))
#if (isset($postTypes) && $postTypes->count() > 0)
#foreach ($postTypes as $postType)
<?php
$postTypeUrl = qsUrl(
request()->url(),
array_merge(request()->except(['page']), ['type' => $postType->id]),
null,
false
);
$postTypeCount = ($count->has($postType->id)) ? $count->get($postType->id) : 0;
?>
#if (request()->filled('type') && request()->get('type') == $postType->id)
<li class="nav-item">
<a href="{!! $postTypeUrl !!}" class="nav-link active">
{{ $postType->name }}
<span class="badge badge-pill bg-danger">
{{ $postTypeCount }}
</span>
</a>
</li>
#else
<li class="nav-item">
<a href="{!! $postTypeUrl !!}" class="nav-link">
{{ $postType->name }}
<span class="badge badge-pill alert-danger">
{{ $postTypeCount }}
</span>
</a>
</li>
#endif
#endforeach
#endif
#endif
</ul>
<div class="tab-filter pb-2">
{{-- OrderBy Desktop --}}
<select id="orderBy" title="sort by" class="niceselecter select-sort-by small" data-style="btn-select" data-width="auto">
#if (isset($orderByArray) && !empty($orderByArray))
#foreach($orderByArray as $option)
#if ($option['condition'])
<option{{ $option['isSelected'] ? ' selected="selected"' : '' }} value="{!! $option['url'] !!}">
{{ $option['label'] }}
</option>
#endif
#endforeach
#endif
</select>
</div>
</div>
<div class="listing-filter">
<div class="float-start col-md-9 col-sm-8 col-12">
<h1 class="h6 pb-0 breadcrumb-list">
{!! (isset($htmlTitle)) ? $htmlTitle : '' !!}
</h1>
<div style="clear:both;"></div>
</div>
{{-- Display Modes --}}
#if (isset($posts) && $posts->count() > 0)
<?php $currDisplay = config('settings.list.display_mode'); ?>
<div class="float-end col-md-3 col-sm-4 col-12 text-end listing-view-action">
#if (isset($displayModesArray) && !empty($displayModesArray))
#foreach($displayModesArray as $displayMode => $value)
<span class="grid-view{{ ($currDisplay == $displayMode) ? ' active' : '' }}">
#if ($currDisplay == $displayMode)
<i class="fas fa-th-large"></i>
#else
<a href="{!! $value['url'] !!}">
<i class="{{ $value['icon'] }}"></i>
</a>
#endif
</span>
#endforeach
#endif
</div>
#endif
<div style="clear:both"></div>
</div>
{{-- Mobile Filter Bar --}}
<div class="mobile-filter-bar col-xl-12">
<ul class="list-unstyled list-inline no-margin no-padding">
#if (config('settings.list.left_sidebar'))
<li class="filter-toggle">
<a class=""><i class="fas fa-bars"></i> {{ t('Filters') }}</a>
</li>
#endif
<li>
{{-- OrderBy Mobile --}}
<div class="dropdown">
<a class="dropdown-toggle" data-bs-toggle="dropdown">{{ t('Sort by') }}</a>
<ul class="dropdown-menu">
#if (isset($orderByArray) && !empty($orderByArray))
#foreach($orderByArray as $option)
#if ($option['condition'])
<li>{{ $option['label'] }}</li>
#endif
#endforeach
#endif
</ul>
</div>
</li>
</ul>
</div>
<div class="menu-overly-mask"></div>
{{-- Mobile Filter bar End--}}
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="contentAll" role="tabpanel" aria-labelledby="tabAll">
<div id="postsList" class="category-list-wrapper posts-wrapper row no-margin">
<div class="slider">
#include('frontendslider')
</div>
#if (config('settings.list.display_mode') == 'make-list')
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.posts.template.list', 'search.inc.posts.template.list'])
#elseif (config('settings.list.display_mode') == 'make-compact')
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.posts.template.compact', 'search.inc.posts.template.compact'])
#else
#includeFirst([config('larapen.core.customizedViewPath') . 'search.inc.posts.template.grid', 'search.inc.posts.template.grid'])
#endif
</div>
</div>
</div>
<div class="tab-box save-search-bar text-center">
#if (request()->filled('q') && request()->get('q') != '' && $count->get('all') > 0)
<a id="saveSearch"
data-name="{!! qsUrl(request()->url(), request()->except(['_token', 'location']), null, false) !!}"
data-count="{{ $count->get('all') }}"
>
<i class="far fa-bell"></i> {{ t('Save Search') }}
</a>
#else
#endif
</div>
</div>
#if ($posts->hasPages())
<nav class="mt-3 mb-0 pagination-sm" aria-label="">
{!! $posts->appends(request()->query())->links() !!}
</nav>
#endif
</div>
</div>
</div>
{{-- Advertising --}}
#includeFirst([config('larapen.core.customizedViewPath') . 'layouts.inc.advertising.bottom', 'layouts.inc.advertising.bottom'])
{{-- Promo Listing Button --}}
<div class="container mb-3">
<div class="card border-light text-dark bg-light mb-3">
<div class="card-body text-center">
<h2>{{ t('do_you_have_anything') }}</h2>
<h5>{{ t('sell_products_and_services_online_for_free') }}</h5>
#if (!auth()->check() && config('settings.single.guests_can_post_listings') != '1')
{{ t('start_now') }}
#else
{{ t('start_now') }}
#endif
</div>
</div>
</div>
{{-- Category Description --}}
#if (isset($cat, $cat->description) && !empty($cat->description))
#if (!(bool)$cat->hide_description)
<div class="container mb-3">
<div class="card border-light text-dark bg-light mb-3">
<div class="card-body">
{!! $cat->description !!}
</div>
</div>
</div>
#endif
#endif
{{-- Show Posts Tags --}}
#if (config('settings.list.show_listings_tags'))
#if (isset($tags) && !empty($tags))
<div class="container">
<div class="card mb-3">
<div class="card-body">
<h2 class="card-title"><i class="fas fa-tags"></i> {{ t('Tags') }}:</h2>
#foreach($tags as $iTag)
<span class="d-inline-block border border-inverse bg-light rounded-1 py-1 px-2 my-1 me-1">
<a href="{{ \App\Helpers\UrlGen::tag($iTag) }}">
{{ $iTag }}
</a>
</span>
#endforeach
</div>
</div>
</div>
#endif
#endif
</div>
#endsection
#section('modal_location')
#includeFirst([config('larapen.core.customizedViewPath') . 'layouts.inc.modal.location', 'layouts.inc.modal.location'])
#endsection
#section('after_scripts')
<script>
$(document).ready(function () {
$('#postType a').click(function (e) {
e.preventDefault();
var goToUrl = $(this).attr('href');
redirect(goToUrl);
});
$('#orderBy').change(function () {
var goToUrl = $(this).val();
redirect(goToUrl);
});
});
</script>
#endsection
controller
public function frontendslider(Request $request){
$data=slider::all();
return view('frontendslider',compact('data'));
}
public function frontendslider2(Request $request){
$data=slider::all();
return view('return',compact('data'));
}
web.php
Route::get('frontendslider',[App\Http\Controllers\Admin\SliderController::class,'frontendslider']);
Route::get('return',[App\Http\Controllers\Admin\SliderController::class,'frontendslider2']);
Anyone face like this kind of issue specelly working with lara classifers use this before your importing page or page that content update..
#php
$data=DB::table('slider')->get();
#endphp
PLS note input your data to $data and table name!!!!
i am starting to create an ads site, i display 36 products in a blade index with success, my problem is that 36 of the products display, the leftovers do not display, and i don't know how to display the 2nd page and 3rd and so on depending on the number of pages to display the other products.
AnnoncesController.php
public function index()
{
$categories = Category::all();
$annonces = Annonce::paginate(36);
return view('annonces.index')->with([
'categories' => $categories,
'annonces' => $annonces,
]);
}
index.blade.php
<div class="row mix-grid thumbnails">
#foreach($annonces as $annonce)
<div class="col-md-3 col-xs-3 mix {{ $annonce->category->slug }} cat_all">
<a class="thumbnail-item">
<img src="{{ asset('storage/'.$annonce->image) }}" alt="category" />
</a>
<div class="thumbnail-data">
<h5>{{ $annonce->titre }}</h5>
<p>{{ substr($annonce->description, 0, 34) }}...</p>
<div class="thumbnail-info" align="center">
<button class="btn btn-primary"><span class="fa fa-edit"></span></button>
<button class="btn btn-primary"><span class="fa fa-trash-alt"></span></button>
<button class="btn btn-primary"><span class="fa fa-eye"></span></button>
</div>
</div>
</div>
#endforeach
</div>
<ul class="pagination pagination-sm pull-right">
<li class="disabled">«</li>
<li class="active">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>»</li>
</ul>
You can do like this
#if($annonces->hasPages())
{{ $annonces->links() }}
#endif
If you want custom pagination, save the following as a new blade file and add name to ->links() method as a parameter.
#if ($paginator->lastPage() > 1)
<ul class="pagination">
#if(($paginator->currentPage() > 1))
<li class="{{ ($paginator->currentPage() == 1) ? '' : '' }}">
<<
</li>
#endif
#for ($i = 1; $i <= $paginator->lastPage(); $i++)
<li class="{{ ($paginator->currentPage() == $i) ? 'current' : '' }}">
{{ $i }}
</li>
#endfor
#if(($paginator->currentPage() != $paginator->lastPage()))
<li class="{{ ($paginator->currentPage() == 1) ? '' : '' }}">
>>
</li>
#endif
</ul>
#endif