Main Category showing posts underneath - php

PostController.php
public function index($id)
{
$post = Post::where('post_id', $id)->first();
$categories = DB::table('categories')->select('name AS category_name', 'slug AS category_slug', 'category_id AS cid')->get();
return view('post', compact('post','categories'));
}
post.blade.php
<div class="accordion sticky-top" id="sideNavigation" style="top:55px">
#foreach($categories as $category)
<?php $posts_list = DB::table('posts')->join('categories', 'categories.category_id', 'posts.category_id')
->where('posts.category_id', $category->cid)
->get();
?>
<h2 class="mb-0 border-bottom py-2 ">
<button class="btn btn-link" type="button" data-toggle="collapse"
data-target="#{{$category->category_slug}}" aria-expanded="true"
aria-controls="{{$category->category_slug}}">
{{ $category->category_name}}
</button>
</h2>
<div id="{{$category->category_slug}}" class="collapse" aria-labelledby="headingOne"
data-parent="#sideNavigation">
<div class="card-body">
<ul class="list-unstyled">
#foreach($posts_list as $post_list)
<li>{{$post_list->title}}</li>
#endforeach
</ul>
</div>
</div>
#endforeach
</div>
The idea is so have this:
Category
Post
Post
Post
Category 2
Post
Post
My current solution works but I can see this becoming a problem very quickly to maintain.

You need to add relationships to your models. Documentation is here.
Providing its a one to many relationship you would do the following
In your Category model
public function posts()
{
return $this->hasMany('App\Post', 'category_id', 'category_id');
}
In your Post model
public function category()
{
return $this->hasOne('App\Category', 'category_id', 'category_id');
}
Then you can clean up your view
<div class="accordion sticky-top" id="sideNavigation" style="top:55px">
#foreach($categories as $category)
<h2 class="mb-0 border-bottom py-2 ">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#{{$category->category_slug}}" aria-expanded="true" aria-controls="{{$category->category_slug}}">{{ $category->category_name}}</button>
</h2>
<div id="{{$category->category_slug}}" class="collapse" aria-labelledby="headingOne" data-parent="#sideNavigation">
<div class="card-body">
<ul class="list-unstyled">
#foreach($category->posts as $post)
<li>{{$post->title}}</li>
#endforeach
</ul>
</div>
</div>
#endforeach
</div>
I would also think this line is not the best way of going about it, you will likely need a route applying
<a href="{{ $post->post_id}}">

Related

Is there any way to pass object as a parameter in laravel livewire?

I have an array of product and i am trying to pass a single item as a parameter for quick view, but I can't. anyone have any sollution? thanks in advance.
#foreach ($products as $product)
#php
$product = (object) $product;
#endphp
<div class="col-md-3 mb-4">
<div class="product-item product-item-border custom-product-item">
<a class="product-item-thumb" href="shop-single-product.html">
#if (count($product->related_images) > 0)
<img src="{{ $product->related_images[0]['image'] }}" width="233" height="245" alt="Image-HasTech">
#endif
</a>
<div class="product-item-action">
<button type="button" class="product-action-btn action-btn-wishlist" data-bs-toggle="modal" data-bs-target="#action-WishlistModal">
<i class="icon-heart"></i>
</button>
<button type="button" class="product-action-btn action-btn-compare" data-bs-toggle="modal" data-bs-target="#action-CompareModal">
<i class="icon-shuffle"></i>
</button>
<button type="button" wire:click="quickView({{ $product }})" class="product-action-btn action-btn-quick-view">
<i class="icon-magnifier"></i>
</button>
</div>
<div class="product-bottom">
<div class="product-item-info text-center pb-6">
<h5 class="product-item-title mb-2">{{ $product->product_name }}</h5>
{{-- <div class="product-item-price mb-0">{{ $product->default_price }}<span class="price-old">{{ $product->default_price }}</span></div> --}}
</div>
<div class="d-flex justify-content-between">
<div class="ms-4 product-item-price mb-4">{{ $product->default_price }}</div>
<button type="button" wire:click="addToCart({!! $product->id !!})" class="info-btn-cart me-4 mb-4"><i class="icon-handbag"></i></button>
</div>
</div>
</div>
</div>
#endforeach
<div class="col-12">
<div class="text-center">
<div wire:click="nextPage" type="button" class="btn btn-primary">Load more</div>
</div>
</div>
and in my controller I am trying to do something like this:
public function quickView($product)
{
$this->view_product = $product;
}
I tried to pass the object but I am getting error such:
htmlspecialchars() expects parameter 1 to be string, object given
The error happens because in blade {{ }} will automatically escape the output. And this function only escapes strings.
Instead what you can do is
wire:click="quickView( {{ $product->id }} )
And within your livewire component
public function quickView($product_id)
{
// I assume $products is collection
$this->view_product = $this->products->where('id', $product_id)->first();
}
EDIT:
If you do not want to add "extra query" inside quickView()
I suggest you change how $products collection is collected
$this->products = $existing_query->get()->keyBy('id');
This will resulting array list of object product.
After that within quickView() do the following
public function quickView($product_id)
{
$this->view_product = $this->products[$product_id];
}
Extra note: please do add some kind of check or validation in case product with selected id is not found
It may be a little too late but I got to solve something similar by type hinting the object class. From the docs
So maybe you can do something like this:
public function quickView(Product $product)
{
$this->view_product = $product;
}

how to display many to many relationship data in laravel livewire?

Good night all. I have a problem when I want to display many to many relationship data, namely postal data based on tags with livewire. Previously I tried in laravel can appear.
Now I want to display post data by tag with livewire but still can't.
the following is the code that I have made.
web.php
Route::get('tag/{tag:slug}',[FrontController::class, 'tag'])->name('tag');
FrontController.php
public function tag(Tag $tag)
{
$categories = Category::all();
$general = General::find(1);
$locale = App::currentLocale();
$search = request("search");
$posts = $tag->posts()->where([
['status','PUBLISH'],
['lang',$locale],
])->latest()->paginate(12);
if ($this->search !== null) {
$posts = $tag->posts()->where([
['title','like', '%' . $search . '%'],
['lang',$locale],
['status','PUBLISH'],
])->latest()->paginate(12);
}
// dd($posts);
$tags = Tag::all();
$top = Post::where('status','PUBLISH')->orderBy('views','desc')->limit(5)->get();
return view ('front.tag',compact('categories','general','locale','posts','tags','top'));
}
tag.blade.php
#extends('layouts.front')
#section('content')
<main id="main">
<section class="post-category">
<div class="container-fluid">
<div class="row mt-3">
<div class="col-lg-3 col-md-12 col-sm-12 d-none d-lg-block">
<div class="sticky-top" style="top: 90px;">
<div class="card mb-3 rounded-3">
<div class="card-body">
<a href="#" target="_blank" rel="noreferrer">
<img src="{{ asset('front/img/ads.png') }}" alt="..." height="300" width="279" class="card-img-top" />
</a>
</div>
</div>
<div class="d-flex flex-column mb-3 bg-light shadow bg-body rounded">
<div class="card-header bg-primary bg-gradient text-white fw-bold fs-5">
{{ __('sentence.category') }}
</div>
<ul class="list-group list-group-flush">
#foreach ($categories as $category)
<li class="list-group-item d-flex justify-content-between align-items-center">
{{ $category->name }}
</li>
#endforeach
</ul>
</div>
<div class="d-flex flex-column bg-light bg-body shadow-lg rounded-3">
<div class="card-header bg-primary bg-gradient text-white fw-bold fs-5">
Tags
</div>
<div class="p-3 overflow-auto" style="max-height: 42vh">
<div class="nav tag-cloud">
#foreach ($tags as $tag)
{{ $tag->name }}
#endforeach
</div>
</div>
</div>
</div>
</div>
<livewire:tag-index>
<div class="col-lg-3 col-md-12 col-sm-12">
<div class="sticky-top" style="top: 90px;">
<div class="card rounded-3 shadow-lg mb-3">
<div class="card-body">
<img src="{{ asset('front/img/ads1.png') }}" height="117" width="279" class="card-img-top" alt="...">
</div>
</div>
<div class="bg-light shadow bg-body rounded-3 mb-3">
<div class="card-header bg-primary bg-gradient text-white fw-bold fs-5">
{{ __('sentence.top_article') }}
</div>
<ul class="list-group list-group-flush mb-2">
#foreach ($top as $top)
<li class="list-group-item">
{{ $top->title }}
<div class="d-flex justify-content-between mt-3">
<small class="text-muted">{{ Carbon\Carbon::parse($top->created_at)->format("d F, Y") }}</small>
<small class="text-muted">{{ $top->views }} views </small>
</div>
</li>
#endforeach
</ul>
</div>
<div class="d-flex flex-column mb-3 bg-light shadow bg-body rounded d-lg-none d-xl-none">
<div class="card-header bg-primary bg-gradient text-white fw-bold fs-5">
{{ __('sentence.category') }}
</div>
<ul class="list-group list-group-flush">
#foreach ($categories as $category)
<li class="list-group-item d-flex justify-content-between align-items-center">
{{ $category->name }}
</li>
#endforeach
</ul>
</div>
<div class="d-flex flex-column bg-light bg-body shadow-lg rounded-3 d-lg-none d-xl-none">
<div class="card-header bg-primary bg-gradient text-white fw-bold fs-5">
{{ __('sentence.tag') }}
</div>
<div class="p-3 overflow-auto" style="max-height: 42vh">
<div class="nav tag-cloud">
#foreach ($tags as $tag)
{{ $tag->name }}
#endforeach
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
#endsection
#push('scripts')
#livewireScripts
<script type="text/javascript">
window.onscroll = function (ev) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
window.livewire.emit('tag-index');
}
};
</script>
<script>
document.getElementById('load-more').onclick = function() {
window.livewire.emit('tag-index');
};
</script>
#endpush
livewire\TagIndex.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\{Tag, Post};
use Illuminate\Support\Facades\App;
class TagIndex extends Component
{
public $limitPerPage = 10;
public $search;
protected $listeners = [
'tag-index' => 'TagIndex'
];
protected $updatesQueryString = [
['search' => ['except' => '']],
];
public function TagIndex()
{
$this->limitPerPage = $this->limitPerPage + 6;
}
public function render(Tag $tag)
{
$locale = App::currentLocale();
$posts = $tag->posts()->where([
['status','PUBLISH'],
['lang',$locale],
])->latest()->paginate($this->limitPerPage);
if ($this->search !== null) {
$posts = $tag->posts()->where([
['title','like', '%' . $this->search . '%'],
['status','PUBLISH'],
['lang',$locale],
])->latest()->paginate($this->limitPerPage);
}
$this->emit('postStore');
return view('livewire.tag-index', ['posts' => $posts]);
}
}
livewire\tag-index.blade.php
<div class="col-lg-6 col-md-12 col-sm-12">
<div id="section-title" class="section-title p-1 pt-3">
<h2 class="text-center fw-bold">{{ trans('sentence.recent_posts')}}</h2>
</div>
<div class="form-group has-search mb-3">
<span class="bi bi-search form-control-feedback"></span>
<input type="text" wire:model="search" class="form-control" placeholder="{{ __('sentence.search_form') }}">
</div>
#foreach ($posts as $data)
<div class="card bg-light shadow bg-body rounded-3 mb-2">
<div class="card-header bg-primary text-white d-flex justify-content-between">
<small>by {{$data->admin->name}}</small>
<small>{{ Carbon\Carbon::parse($data->created_at)->format("d F, Y") }}</small>
</div>
<div class="card-body">
<h2 class="card-title">
{{ $data->title }}
</h2>
<div class="card-footer bg-body d-flex justify-content-between align-items-center pb-0 px-0">
<div class="d-flex my-1">
#foreach ($data->tags as $tag)
{{ $tag->name }}
#endforeach
</div>
</div>
</div>
</div>
#endforeach
#if ($posts->count() == 0)
<div class="alert alert-danger" role="alert">
Data not found!
</div>
#endif
#if($posts->count() >= 10)
<div class="text-center d-md-none d-lg-none d-xl-none">
<button id="load-more" class="btn btn-primary my-3">
Load More
</button>
</div>
#endif
</div>
what is the correct way or code to display many to many relationship data with livewire? in this case, I want to display post data by tag. thank you
There is a lot of additional stuff going on in your question so I have put together a simplified example for you. You will need to do the remainder of the work to get it into your project.
I don't know how you're displaying your tag labels or anything, so I have gone with checkboxes as it seems the most sensible. These could be styled to be hidden so they more closely resemble the tag labels on SO but again, I will leave the bike shedding to you.
I created a Livewire component called Tags with an associated blade view.
tags.blade.php
<div>
{{-- loop over each of the tags --}}
#foreach ($this->tags as $tag)
{{-- wire:key is important here as Livewire requires it for effective DOM diffing! --}}
<div wire:key="tag-{{ $tag->id }}" class="block px-4 py-2">
{{--
this is where we bind the checkboxes
to a property on the Livewire component
--}}
<input wire:model="selectedTags" type="checkbox" id="tag-{{ $tag->id }}" name="{{ $tag->title }}" value="{{ $tag->id }}">
<label for="{{ $tag->title }}">{{ $tag->title }}</label>
</div>
#endforeach
{{-- loop over each of the posts --}}
#foreach ($this->posts as $post)
{{-- again, don't overlook wire:key! --}}
<div wire:key="post-{{ $post->id }}" class="block px-4 py-2">
<h4 class="text-sm">{{ $post->title }}</h4>
</div>
#endforeach
</div>
The above should be mostly self explanatory, the only bit that might not be is wire:model="selectedTags". A public property called selectedTags is defined on the Tags component (as you'll see in a moment) and what this does is allow us to manage elements in that array when one of the checkboxes is selected. So for example when someone checks the checkbox for tag with id of 12, the selectedTags array has an element added with the value of 12.
Tags.php
class Tags extends Component
{
// array of selected tags (checked checkboxes)
public $selectedTags = [];
// get just the id and title of each tag
public function getTagsProperty()
{
return Tag::select('id', 'title')->get();
}
public function getPostsProperty()
{
$tags = array_filter($this->selectedTags);
// if no tags are selected, return all posts
// you might decide to return nothing, up to you
if (!$tags) {
return Post::all();
}
// if there are some selected tags
// query the database for posts with the selectedTags
// this is an `OR` operation on tags
// if you want `AND` you'll need to change it
return Post::whereHas('tags', function ($query) use ($tags) {
$query->whereIn('tags.id', $tags);
})->get();
}
public function render()
{
return view('livewire.tags');
}
}
Again the above should be self explanatory as there is nothing out of the ordinary going on.
The getPostsProperty() and getTagsProperty() functions define computed properties which are optional, you could just use normal properties if you wish. However, if you're referencing $tags and $posts multiple times in your component views, a computed property is more performant as it doesn't make a call to the backend component each time.
SOLVED
thanks #Peppermintology for helping my two issues and now this issue is solved with below code.
FrontController.php
public function tag(Tag $tag)
{
$categories = Category::all();
$general = General::find(1);
$locale = App::currentLocale();
$tag_id = $tag->id;
$search = request("search");
$posts = $tag->posts()->where([
['status','PUBLISH'],
['lang',$locale],
])->latest()->paginate(12);
if ($this->search !== null) {
$posts = $tag->posts()->where([
['title','like', '%' . $search . '%'],
['lang',$locale],
['status','PUBLISH'],
])->latest()->paginate(12);
}
$tags = Tag::all();
$top = Post::where('status','PUBLISH')->orderBy('views','desc')->limit(5)->get();
return view ('front.tag',compact('categories','general','locale','posts','tags','tag_id','top'));
}
livewire\TagIndex.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\{Tag, Post};
use Illuminate\Support\Facades\App;
class TagIndex extends Component
{
public $limitPerPage = 10;
public $search, $tagId;
protected $listeners = [
'tag-index' => 'TagIndex'
];
protected $updatesQueryString = [
['search' => ['except' => '']],
];
public function TagIndex()
{
$this->limitPerPage = $this->limitPerPage + 6;
}
public function render()
{
$locale = App::currentLocale();
$tag_id = $this->tagId;
$tag = Tag::find($tag_id);
$posts = $tag->posts()->where([
['status','PUBLISH'],
['lang',$locale],
])->latest()->paginate($this->limitPerPage);
if ($this->search !== null) {
$posts = $tag->posts()->where([
['title','like', '%' . $this->search . '%'],
['status','PUBLISH'],
['lang',$locale],
])->latest()->paginate($this->limitPerPage);
}
$this->emit('postStore');
// dd($posts);
return view('livewire.tag-index', ['posts' => $posts, 'tag' => $tag]);
}
}

Order the categories by the number of conferences associated with each category

Im getting all the categories like:
public function index(){
return view('home')
->with('categories', Category::orderBy('created_at', 'desc')->get())
->with('conferences', Conference::orderBy('created_at','desc')->where('status','P')->take(8)->get())
}
Then in the blade file I show the categories like below. But do you know how to order the categories by the number of conferences associated with each category? That is, show first the categories that have more conferences associated with it. Do you know how that can be achieved?
<div class=" d-md-block">
<div class="container">
<div class="row">
<div class="col p-0 m-0">
<ul class="Categories__Menu">
#foreach($categories->take(6) as $category)
<li class="">
{{$category->name}}
</li>
#endforeach
<li><a data-toggle="modal" id="showCategories" data-target=".bd-example-modal-lg" href="">More <i class="fa fa-caret-down" aria-hidden="true"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
Use this.
Category::withCount('conferences')->orderBy('conferences_count', 'desc')->get();

Laravel 5: how to do multi threaded comments

I am using Laravel Commentable package which uses Nested Sets pattern with Baum.
I have managed to allow users to make comments on posts but they're not threaded, each comment has depth set to zero in the database.
So I'm wondering how does one go about making multi threaded comments like reddit for example?
These are my tables
users: id, name, email...
posts: id, user_id, subreddit_id...
comments: id, body, parent_id, lft, rgt, depth, commentable_id, commentable_type, user_id
My Models (Comment and User)
class Comment extends Model
{
use Commentable;
public function commentable()
{
return $this->morphTo();
}
public function user() {
return $this->belongsTo('App\User');
}
public function posts() {
return $this->belongsTo('App\Post');
}
}
class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
public function posts() {
return $this->hasMany('App\Post');
}
public function comments() {
return $this->hasMany('App\Comment');
}
}
This is how I'm submitting comments in PostsController
public function createComment($id) {
$post = Post::with('user.votes')->with('subreddit.moderators')->where('id', $id)->first();
$comment = new Comment;
$comment->body = Input::get('comment');
$comment->user_id = Auth::id();
$post->comments()->save($comment);
}
And this is the view
<div class="post-comments">
{!! Form::open(['route' => ['comment', $post]]) !!}
<div class="form-group">
<label for="comment">Your Comment</label>
<textarea name="comment" class="form-control" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-default">Send</button>
{!! Form::close() !!}
<div class="comments-nav">
<ul class="nav nav-pills">
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
there are {{ count($comments) }} comments <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Best</li>
<li>Hot</li>
</ul>
</li>
</ul>
</div>
<div class="row">
<div class="media">
<!-- first comment -->
#foreach($comments as $comment)
<div class="media-heading">
<button class="btn btn-default btn-xs" type="button" data-toggle="collapse" data-target="#{{ $comment->id }}" aria-expanded="false" aria-controls="collapseExample"><span class="glyphicon glyphicon-minus" aria-hidden="true"></span></button> <span class="label label-info">12314</span> {{ $comment->user->name }} 12 hours ago
</div>
<div class="panel-collapse collapse in" id="{{ $comment->id }}">
<div class="media-left">
<div class="vote-wrap">
<div class="vote up">
<i class="glyphicon glyphicon-menu-up"></i>
</div>
<div class="vote inactive">
<i class="glyphicon glyphicon-menu-down"></i>
</div>
</div>
<!-- vote-wrap -->
</div>
<!-- media-left -->
<div class="media-body">
<p>{{ $comment->body }}</p>
<div class="comment-meta">
<span>delete</span>
<span>report</span>
<span>hide</span>
<span>
<a class="" role="button" data-toggle="collapse" href="#replyCommentT" aria-expanded="false" aria-controls="collapseExample">reply</a>
</span>
<div class="collapse" id="replyCommentT">
<form>
<div class="form-group">
<label for="comment">Your Comment</label>
<textarea name="comment" class="form-control" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-default">Send</button>
</form>
</div>
</div>
<!-- comment-meta -->
</div>
</div>
<!-- comments -->
#endforeach
</div>
<!-- first comment -->
</div>
</div>
<!-- post-comments -->
I haven't used Laravel Commentable package, but the docs look pretty good.
I believe you need use Commentable; on your Post model and not your Comment model.
It looks like your Comment model needs to extend Baum\Node and not Model
Then what you have should work.
$post = Post::with('user.votes')->with('subreddit.moderators')->where('id', $id)->first();
$comment = new Comment;
$comment->body = Input::get('comment');
$comment->user_id = Auth::id();
$post->comments()->save($comment);
// or you could do
$comment->makeChildOf($post);
To make a comment on a comment, it looks like you do something like this. I would probably make a CommentsController.
public function addComment(Request $request){
$parent = Comment::find(Input::get('parent_id'));
$comment = new Comment;
$comment->body = Input::get('comment');
$comment->user_id = Auth::id();
$comment->makeChildOf($parent);
}
The Relations, Root and Leaf scopes, Accessing the ancestry/descendancy chain section of the docs have several examples on how to then retrieve the comments for comments.
Edit
It looks like the Comment model in the package already extends the Baum\Node so you don't need to do that. In order to use this package, it looks like you need to use his Comment model. I am sure you could use his model as a base and roll your own.
You could do something like this. You would have to set up a route.
<div class="collapse" id="replyCommentT">
{!! Form::open(['route' => ['comment', $comment]]) !!}
<input type="hidden" name="parent_id" value="{{ $comment->id }}"/>
<div class="form-group">
<label for="comment">Your Comment</label>
<textarea name="comment" class="form-control" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-default">Send</button>
{!! Form::close() !!}
</div>

Laravel Eloquent HasOne::$id Undefined Property

I have a Users table, a Images table and a Bookmarks table. I've specified the relationships for each one in my database and I am capable of accessing all the images that a user has uploaded. However I cannot access the images they have bookmarked.
This is what my databases relationships look like:
I am able to access the data I want using the SQL input on PHPMyAdmin however I cannot when using Laravel:
Using Laravel yields this error:
This is my User Model:
<?php
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
use Cartalyst\Sentry\Users\Eloquent\User as SentryUserModel;
class User extends SentryUserModel implements UserInterface, RemindableInterface {
public $activated = true;
public function getAuthIdentifier() {
return $this->getKey();
}
public function getAuthPassword() {
return $this->password;
}
public function getRememberToken() {
return $this->remember_token;
}
public function setRememberToken($value) {
$this->remember_token = $value;
}
public function getRememberTokenName() {
return 'remember_token';
}
public function getReminderEmail() {
return $this->email;
}
public function images() {
return $this->hasMany('image', 'poster_id', 'id');
}
public function bookmarks() {
return $this->hasMany('bookmark', 'bookmarker_id', 'id');
}
}
This is my Image Model:
<?php
class Image extends Eloquent {
public function poster() {
return $this->belongsTo('user', 'poster_id', 'id');
}
}
This is my Bookmark Model:
<?php
class Bookmark extends Eloquent {
public $timestamps = false;
public function bookmarker() {
return $this->belongsTo('user', 'bookmarker_id', 'id');
}
public function image() {
return $this->hasOne('image', 'image_id', 'id');
}
}
This is the view in which the error is being thrown:
#extends('master')
#section('content')
<!-- Page Content -->
<header class="navbar navbar-inverse" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
Egami
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
#if(!Sentry::check())
<li>
Login
</li>
<li>
Signup
</li>
#endif
#if(Sentry::check())
#if(Sentry::getUser()->id == $user->id)
<li class="active">
#else
<li>
#endif
Profile
</li>
<li>
Logout
</li>
#endif
</ul>
</div>
</div>
</header>
<div class="container" id="profile">
<div class="row">
<div class="tac col-md-3">
<img src="/img/{{ $user->profile_image }}" alt="{{ $user->username }}'s Profile Image">
</div>
<div class="tal col-md-8">
<h2>{{ $user->username }}</h2>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="navbar navbar-inverse" role="navigation">
<ul class="nav navbar-nav navbar-center">
<li>
Uploaded Images
</li>
<li class="active">
Bookmarked Images
</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="row">
<?php
$bookmarks = $user->bookmarks()->orderBy('id', 'DESC')->simplePaginate(15);
?>
#foreach($bookmarks as $bookmark)
<div class="col-md-4 user-image">
<a href="{{ URL::action('ImageController#show', $bookmark->image()->id) }}">
<img src="/uimg/{{ $bookmark->image()->id }}.png" alt="{{ $bookmark->image()->title }}">
</a>
</div>
#endforeach
</div>
<div class="row">
<div class="container">
{{ $bookmarks->links() }}
</div>
</div>
</div>
</div>
</div>
<footer class="navbar-fixed-bottom">
<div class="container">
<p>
Copyright © Egami {{ date('Y') }}
</p>
</div>
</footer>
#stop
#section('scripts')
#stop
Try this:
<a href="{{ URL::action('ImageController#show', $bookmark->image->id) }}">
<img src="/uimg/{{ $bookmark->image->id }}.png" alt="{{ $bookmark->image->title }}">
</a>
Removed parentheses $bookmark->image()->id to $bookmark->image->id.

Categories