Laravel | More than one CubePortfolio gallery in blade's view - laravel

how can I add more CubePortfolio gallery in my view. My code:
#foreach($page->subpages as $subpage)
<div id="js-grid-lightbox-gallery" class="cbp ">
#foreach($subpage->photos as $photo)
<div class="cbp-item {{ $subpage->id }}">
<a href="/project/storage/app/{{ $photo->filename }}" class="cbp-caption cbp-lightbox" data-title="" rel="nofollow">
<div class="cbp-caption-defaultWrap">
<img src="/project/storage/app/{{ $photo->filename }}" alt="">
</div>
</a>
</div>
#endforeach
</div>
#endforeach
currently only shows one gallery to me, and should display multiple galleries. One is ok, the other revolves around the loader.
I understand that there cannot be two galleries with the same ID? How can I solve this problem? Thanks for the help.

Append an identifier from the loop to the ID, the same way you do that with the class
<div id="js-grid-lightbox-gallery-{{ $subpage->id }}" class="cbp">
Then initialize the element like so (example from jQuery)
$('[id^=js-grid-lightbox-gallery]').cubeportfolio({
Hope this helps

Related

After Click Add to Cart Button then Button Change to Go to Cart in Laravel 8

Please help me, i'm right now try to change Add to Cart Button to Go to Cart after click, how possible I can do that?, please help me, I have trying but didn't work, here my condition code in Controller:
if (Temporary::where('course_id','=', $request->IDCourse)->exists()) {
Session::flash('failed-session','Go to card');
}
else
{
Session::flash('failed-session','Add to cart');
}
and below my blade for looping product on cart box
#foreach($carts as $cart)
<ul class="list-group list-group-flush">
<li class="list-group-item bg-light">
<div class="row">
<div class="col">
<input type="text" name="IDCourse" value="{{ $cart->course_id }}">
<a href="{{ route('course.detail', $cart->course->id) }}" class="text-body">
<div class="d-flex">
#if($cart->course->image == '')
<img src="{{ asset('storage/courses/Default_Photo.png') }}" alt="" class="avatar-md square" />
#else
<img src="{{ asset('storage/courses/'.$cart->course->image) }}" alt="" class="avatar-md square" />
#endif
<div class="ms-3">
<h5 class="fw-bold mb-1">
{{ $cart->course->title }}
</h5>
<span class="fs-6 text-muted">
<span>{{ __('Oleh ') }}{{ $cart->course->user->name }}</span>
</span>
</div>
</div>
</a>
</div>
</div>
</li>
</ul>
<hr class="my-0">
#endforeach
And the last code to display the result from condition in controller
#if(Session::has('failed-session'))
<div class="alert alert-danger">
{{Session::get('failed-session')}}
</div>
#endif
I try dd($request->course_id) and displaying null. My planning is to check if customer have add to cart that item then the button change to Go to Cart. Please help me.Thank u so much for any help.
simply just check this item in your controller then initialize the variable and check if variable is empty or not , then you can change the action of the form or change the src of the button ,
for example : if user->cart->count() > 0
redirect to the page
you can add another button for continue shopping as well too .

Vue component does not render html under hidden dropdown-menu

<div class="dropdown notification-dropdown" data-toggle="dropdown">
<img src="{{ asset('front/img/notification-bell-ico.svg') }}" alt="">
<ul class="dropdown-menu">
<div class="card notification-card">
<div class="card-header">
<p>Notification</p>
See all
</div>
<notification :user="{{ auth()->user() }}"></notification>
</div>
</ul>
</div>
I am loading my vue component as notification as seed in above code but some how it does not render html when i click header bell icon to open it
I don't know how to resolve it
if any help will be greatly appreciated.
thanks in advance.
Your snippet looks like a blade template and notification bells are often in a site's header area. It's possible your header is not within the root element you've got Vue controlling.

making pagination in laravel for image

Hello for everyone I have a problem in laravel that about the showing images in one view, the problem is: I have a page that just show the images but it show all the images stored in table with specific id but I want to show some of that and have a button (show more) and when click on button it show the other images I don't know hove can I do this if someone can help me please!
This is my controller code:
public function listHostel()
{
$hostels = Hostel::all();
return view('front/khabgah_list',compact('hostels'));
}
And this is my blade code:
#foreach($hostels as $hostel)
#foreach($hostel->attachments as $photo)
<div class=" col-12 col-sm-6 col-md-6 col-lg-3 px-1 mt-3">
<div class="card card-shadow custom-height-1 " style="border-radius: 0%">
<a href="">
<img src="/assets-/app/media/img/blog/hostels-img/{{$photo->file_name}}"
class="card-img-top card-img custom-card-img-height" alt="">
</a>
<div class="car-body">
<div class="card-footer">
<div class="custom-circle">
<p class="custom-circle-text card-text">
<b>
#if($hostel->type == 1)
{{ 'ذکور'}}
#else
{{ 'اناث' }}
#endif
</b>
</p>
</div>
<div class="custom-prices card-text text-left"> کرایه فی ماه
: {{$hostel->remark }}
</div>
</div>
</div>
</div>
</div>
#endforeach
#endforeach
Pagination is likely what you're looking for. Change your controller to:
public function listHostel()
{
$hostels = Hostel::all()->paginate(5);
return view('front/khabgah_list',compact('hostels'));
}
Then you can get the links in your Blade template:
{{ $hostels->links() }}
You might need to change it a bit to work for your specific situation. The documentation gives some more info: https://laravel.com/docs/5.8/pagination

Show a collection in laravel from controller on different columns in view

got this problem:
I want to show the info from a collection where a publication has a "featured" column in true.
$pub_destacadas = Publicaciones::take(3)->where('destacado', '=', 1)->get();
The problem is that my layout has 3 elements to fill with this information that have different sizes so i wasn't able to solve this using the chunk() method in the foreach in my blade template, so I tried the following:
$individual_destacada = $pub_destacadas->take(1);
$grupo_destacada = $pub_destacadas->take(2);
and show them in the view as follows:
<div class="publicaciones-destacadas">
<div class="container">
<h2>Publicaciones Destacadas</h2>
<div class="row">
#foreach($individual_destacada as $destacada)
<div class="col-md-6">
<div class="item-destacado size-2">
<img class="img-responsive" src="{{ asset('img/publicaciones/' . $destacada->imagen ) }}">
{{ $destacada->titulo }}
{{ $destacada->descripcion }}
</div>
</div>
#endforeach
<div class="col-md-6">
#foreach($grupo_destacada as $destacada)
<div class="row doble-publicacion">
<div class="col-md-12">
<div class="item-destacado size-1">
<img class="img-responsive" src="{{ asset('img/publicaciones/' . $destacada->imagen ) }}">
{{ $destacada->titulo }}
{{ $destacada->descripcion }}
</div>
</div>
</div>
#endforeach
</div>
</div>
</div>
</div>
So... now it shows it correctly in the layout but the first item that the query gets is shown 2 times in this layout. How can I exclude this first element in the second variable where I get the featured publications?
Hope I explained the problem correctly.
Here's the layout:
You can use splice.
$individual_destacada = $pub_destacadas->splice(1);
$grupo_destacada = $pub_destacadas->splice(2);

Rendering images in Twig

I have a form which takes Image (png file type) and saves it's name in the database. The image is uploaded to web/uploads/Images/ directory, my question is, how do I render this image in my Twig template? This is what I have so far:
<div class=products>
{% for key,product in products %}
<div class="product-{{ key }}">
<div class="p-name"> {{ product.name }}</div>
<div class="p-price"> {{ product.price }}</div>
<div class="p-description"> {{ product.description }}</div>
<div class="p-image">
<img src="{{ asset('uploads/Images/' ~ product.Image) }}"></img>
</div>
</div>
{% endfor %}
</div>
And this is what I have in DOM
I am completely new to Symfony, so please bear with me.
EDIT: The path to the image is wrong, how should it be written?
In your img tag you have the spelling of "src" incorrect. Should be like so:
<img src="{{ asset('uploads/Images/' ~ product.Image) }}"></img>
Maybe that's the problem? Otherwise, it looks correct.

Resources