mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 21:43:17 +00:00
Add DiscoverController and hashtag posts view
This commit is contained in:
parent
befa82dc04
commit
3dafc278b5
2 changed files with 59 additions and 0 deletions
22
app/Http/Controllers/DiscoverController.php
Normal file
22
app/Http/Controllers/DiscoverController.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\{Hashtag, Status, StatusHashtag};
|
||||
|
||||
class DiscoverController extends Controller
|
||||
{
|
||||
public function home()
|
||||
{
|
||||
return view('discover.home');
|
||||
}
|
||||
|
||||
public function showTags(Request $request, $hashtag)
|
||||
{
|
||||
$tag = Hashtag::whereSlug($hashtag)->firstOrFail();
|
||||
$posts = $tag->posts()->has('media')->orderBy('id','desc')->paginate(12);
|
||||
$count = $tag->posts()->has('media')->orderBy('id','desc')->count();
|
||||
return view('discover.tags.show', compact('tag', 'posts', 'count'));
|
||||
}
|
||||
}
|
37
resources/views/discover/tags/show.blade.php
Normal file
37
resources/views/discover/tags/show.blade.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="profile-header row my-5">
|
||||
<div class="col-12 col-md-3">
|
||||
<div class="profile-avatar">
|
||||
<img class="img-thumbnail" src="https://placehold.it/300x300" style="border-radius:100%;" width="172px">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-9 d-flex align-items-center">
|
||||
<div class="profile-details">
|
||||
<div class="username-bar pb-2 d-flex align-items-center">
|
||||
<span class="h1">{{$tag->name}}</span>
|
||||
</div>
|
||||
<p class="font-weight-bold">
|
||||
{{$count}} posts
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="profile-timeline mt-5 row">
|
||||
@foreach($posts as $status)
|
||||
<div class="col-12 col-md-4 mb-4">
|
||||
<a class="card" href="{{$status->url()}}">
|
||||
<img class="card-img-top" src="{{$status->thumb()}}" width="300px" height="300px">
|
||||
</a>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@endsection
|
Loading…
Reference in a new issue