I am using laravel pagination but url of pagination is not relative and it appends the new url to previous url for example if my current url is "http://localhost:8080/event-home/1" then when I click on 2nd page it generates link as "http://localhost:8080/event-home/1#http://localhost:8080/event-home/1?page=2"
As you can see it appends to the previous url and therefore it does not return the next page. Actually the URL should be like "http://localhost:8080/event-home/1?page=2" Following is the code for the same
if (Session::get('event_id') != null){
$members = Event::find(Session::get('event_id'))->users()->orderBy('name','asc')->paginate(5);
if ($request->ajax()) {
if($request->page) {
return view('event.members', ['members' => $members]);
}
else
return view('event.event-home', ['members' => $members]);
}
Here is my view code:
#foreach($members as $member)
<div class="col-lg-3 col-md-4 col-xs-6 member" id="memberId_{{$member->id}}">
<div class="caption">
<a href="/profile/{{$member->id}}" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="{{url('images/users/'.$member->id.'/profile_image/'.$member->avatar_url)}}" alt="">
</a>
<center> {{$member->name }} {{$member->profiles->last_name}}</center>
</div>
</div>
#endforeach
{{ $members->links() }}
Thanks!
Related
I am trying to create a new blade.php page, I need to access this page by pressing a button on my home page, but it isn't working properly.
How can I do it?
I tried doing
Route::get('/my-page', function () { return view('my-page'); });
inside web.php, it works, but when I press the card button, it doesn't work
`
<div class="col-lg-4 col-md-4 col-sm-4 my-1">
<a href="{{ route('course-page') }}">
<div class="card card-animated text-center py-5">
<span class="">
<img class="img-fluid" src="assets/image/courses.svg" >
</span>
<div class="card-body">
<p class="card-text">COURSES</p>
</div>
</div>
</a>
</div>
You are trying to get a route by route name while you did not define the route name. Add a name for your route:
Route::get('/my-page', function () { return view('my-page'); })->name('course-page');
Try this,
Change in web.php
Route::get('/my-page', function () { return view('my-page'); })->name('course-page');
Welcome in advance.
I am trying to display the single image in the slider, but whenever the user will click on this then it's open a popup in data-src="multiple-images-here" where I am running the slider. But the main issue is with the single image display in for loop. It displays all the available images in the loop. Please suggest me the best solution for this.
Here is my index.blade.php file where I am trying to display the slider using this code.
<div class="container-fluid margin-gallery d-lg-block d-block position-relative">
<div class="row">
<div class="col-lg-12 p-0">
<div class="demo-gallery">
#php
if($propertys->propertyImage!=null){
$images = json_decode($propertys->propertyImage->image_path, true);
}
else{
$images=null;
}
#endphp
<?php
$images_prop = collect($images['property_images']);
?>
<ul id="lightgallery">
#if($images['property_images']!=null)
#forelse($images_prop as $img)
<li class="sizing-li position-relative" data-src="{{ asset($img) }}">
<a href="javascript:void()">
<img class="img-responsive" src="{{ asset($img) }}" style="width:929px; height:495px;">
</a>
</li>
#empty
#endforelse
#endif
</ul>
</div>
</div>
</div>
</div>
I want to display the first image from for loop here
<img class="img-responsive" src="{{ asset($img) }}" style="width:929px; height:495px;">
You can pass ->first() function to get only 1 images, It will show you only the first item from your data in database.
I'm trying to get a movie title from TMDb API but:
ErrorException
Trying to access array offset on value of type int
Controller
$getPopuler = Http::withToken(config('services.tmdb.token'))
-> get('http://api.themoviedb.org/3/movie/popular')
-> json();
dump($getPopuler);
return view('pages.index', [
'getPopuler' => $getPopuler
]);
The result of dump($getPopuler) gives this.
Blade
#foreach ($getPopuler as $populer)
<div class="card text-center">
<div class="container">
<img class="img-fluid img-thumbnail" src="{{ asset('assets/image/poster01.jpg') }}" alt="Poster-01">
</div>
<div class="card-body">
<h6 class="card-title">{{ $populer['title'] }}</h6>
<i class="fas fa-star"><span class="ml-1">85%</span></i>
<p class="tahun"><small>Mar 20, 2020</small></p>
Read More
</div>
</div>
#endforeach
Thanks in advance.
Assuming your API call is working, I think you need to access the results array of the API response, as per the documentation.
#foreach ($getPopuler['results'] as $populer)
Side note: 'populer' is spelled 'popular'.
When i try to paginate i got an exception Call to undefined method App\Clothes::links() (View: D:\work\Laravel\winter\resources\views\pages\home.blade.php).my data is view in the blade file but i am not been able to do pagination because of the above exception.please help
public function images(){
if(auth::check()){
$user = Auth::user();
$renimage = Clothes::orderBy('id','desc')->paginate(3);
$cart = cart::where('user_id',$user->id)->get();
$cart_added=count($cart);
return view('pages.home',['renimage'=>$renimage,'google_avater'=>$user,
'cart_added'=>$cart_added]);
}
}
In the blade file.
<div class="container" style="margin-top:50px;margin-bottom:50px">
<div>
#foreach ($renimage as $renimage)
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="hovereffect">
<img class="img-responsive" src="{{asset('upload/'.$renimage->img) }}" alt="">
</br>
<div class="overlay">
<h2>{{$renimage->name}}</h2>
<h3 style="color: white;padding-top: 70px;">{{'$'.$renimage->price}}</h2>
<a class="info" href="{{ route('product',['id'=>$renimage->id])}}" style="margin-top:
20px;">Buy Now</a>
</div>
</div>
</div>
#endforeach
{{$renimage->links()}}
you need to handle empty collections
#unless (count($renimage))
{{$renimage->links()}}
#endunless
I am trying to add and display a image from mysql database stored in BLOB type in my web App, but while using {{ Auth::user()->profile_pic }} getting errors, can someone tell me what mistake i am doing and how to do this using laravel 5.
dashboard.blade.php
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading">Profile</div>
<div class="panel-body">
<img src="{{ Auth::user()->profile_pic }}" class="img-circle" width="200" height="200">
<h3>{{ Auth::user()->name }}</h3>
<h5>{{ Auth::user()->email }}</h5>
<hr>
<h6>{{ Auth::user()->created_at }}</h6>
</div>
</div>
</div>
<div class="col-md-9">
</div>
</div>
</div>
#endsection
The html <img src="{{ Auth::user()->profile_pic }}" class="img-circle" width="200" height="200"> needs address url instead of {{ Auth::user()->profile_pic }}
Add code in route first get the address using response object
Route::get('/' function($user) {
$Image = Auth::user()->profile_pic;
return response($Image)->header('Content-Type', 'image/jpeg');
}
then now pass address of response to the html element
Route::get('/dashboard', function() {
$id = Auth::user()->id;
$Image_url = "user/$id/profile-pic";
return view('/dashboard', ['Image_url' => $Image_url]);
}
Passing address in blade
<img src="{{ $Image_url }}" class="img-circle" width="200" height="200">