added permission can edit blog_post to view

This commit is contained in:
2024-01-23 12:17:17 +03:00
parent 3a3365723b
commit 01beefd69b
2 changed files with 261 additions and 134 deletions

View File

@@ -2,113 +2,168 @@
@section('page_title', 'Blog Post ' . $blogPost->title)
@php
$blogPostViewsCount = views($blogPost)->unique()->count();
$blogPostViewsCount = views($blogPost)
->unique()
->count();
@endphp
@section('main_section')
<section class="py-5" id="main">
<div class="container d-flex justify-content-between align-items-center flex-nowrap mb-4 px-4 py-3 --bg_white --shadow --radius --mw-1000 --f_bold --f_main overflow-x-xs-scroll">
<a href="{{ route('blog_post.index') }}" class="d-flex w-2/5 align-items-center --f_bold">
<svg width="17" height="16" class="me-2"><use xlink:href="#GoBack"></use></svg>
<span class="d-none d-md-inline --f_main">Посты в блоге</span>
</a>
<div class="d-flex align-items-center fs-6">
<svg width="20" height="14" class="me-2"><use xlink:href="#Eye_Black"></use></svg>
<span class="me-4">{{ $blogPostViewsCount }}</span>
<svg width="16" height="14" class="me-2"><use xlink:href="#Heart_Black"></use></svg>
<span class="me-4">@livewire('blog-post.like-count', ['blogPost' => $blogPost])</span>
<svg width="14" height="14" class="me-2"><use xlink:href="#Comment_Black"></use></svg>
<span>{{ $blogPost->comments_count }}</span>
</div>
<div class="d-none d-md-flex w-2/5 ps-3 justify-content-end align-items-center">
<span class="me-2 text-end">
<a href="{{ route('profile.show', $author->id) }}" class="text-black">
{{ $author['name'] }}
</a>
</span>
<a href="{{ route('profile.show', $author->id) }}" class="d-none d-sm-block overflow-hidden rounded-full" >
<div class="centered-bg-img" style="background-image: url('{{ $author->profile_photo_url }}')"></div>
<section class="py-5" id="main">
<div
class="container d-flex justify-content-between align-items-center flex-nowrap mb-4 px-4 py-3 --bg_white --shadow --radius --mw-1000 --f_bold --f_main overflow-x-xs-scroll">
<a href="{{ route('blog_post.index') }}" class="d-flex w-2/5 align-items-center --f_bold">
<svg width="17" height="16" class="me-2">
<use xlink:href="#GoBack"></use>
</svg>
<span class="d-none d-md-inline --f_main">Посты в блоге</span>
</a>
</div>
</div>
<div class="d-flex align-items-center fs-6">
<svg width="20" height="14" class="me-2">
<use xlink:href="#Eye_Black"></use>
</svg>
<span class="me-4">{{ $blogPostViewsCount }}</span>
<svg width="16" height="14" class="me-2">
<use xlink:href="#Heart_Black"></use>
</svg>
<span class="me-4">@livewire('blog-post.like-count', ['blogPost' => $blogPost])</span>
<svg width="14" height="14" class="me-2">
<use xlink:href="#Comment_Black"></use>
</svg>
<span>{{ $blogPost->comments_count }}</span>
</div>
<div class="d-none d-md-flex w-2/5 ps-3 justify-content-end align-items-center">
<span class="me-2 text-end">
<a href="{{ route('profile.show', $author->id) }}" class="text-black">
{{ $author['name'] }}
</a>
</span>
<a href="{{ route('profile.show', $author->id) }}" class="d-none d-sm-block overflow-hidden rounded-full">
<div class="centered-bg-img" style="background-image: url('{{ $author->profile_photo_url }}')"></div>
</a>
</div>
<div class="container mb-5 p-0 --mw-1000">
<div class="--bg_white --shadow --radius --no_wrap">
<div class="row m-0 p-3 position-relative">
<div class="col-12 col-md-5 mb-2 mb-md-0 ps-0 pe-0 pe-md-3">
<img src="/storage/{{ $blogPost->image }}" class="w-full --radius">
</div>
<div class="container mb-5 p-0 --mw-1000">
<div class="--bg_white --shadow --radius --no_wrap">
<div class="row m-0 p-3 position-relative">
<div class="col-12 col-md-5 mb-2 mb-md-0 ps-0 pe-0 pe-md-3">
<img src="/storage/{{ $blogPost->image }}" class="w-full --radius">
</div>
<div class="col-12 col-md-7 pe-0 d-flex flex-column justify-content-between">
<div>
<div class="mb-3 fs-18 --f_bold --no_wrap_normal">{{ $blogPost->title }}</div>
<div class="mt-3 lh-sm --no_wrap_normal">
<small>
{!! $blogPost->description !!}
</small>
</div>
</div>
<div class="mt-3 fs-14 --f_bolder">
@if (filter_var($blogPost->youtube_url, FILTER_VALIDATE_URL))
<a href="{{ $blogPost->youtube_url }}" class="d-inline-flex align-items-center"
target="_blank">
<span class="--f_main">Посмотреть рецепт на YouTube</span>
<svg width="18" height="14" class="ms-2">
<use xlink:href="#YouTubeIcon"></use>
</svg>
</a>
@endif
</div>
</div>
<ul class="navbar-nav --abs --dotted --r w-auto mt-2 me-2 mt-md-3 me-md-3 p-0"
style="--bs-scroll-height:100px;">
<li class="nav-item dropdown">
{{-- <a id="dLabel" class="nav-link py-0 dropdown-toggle-js" href="#" --}}
{{-- data-bs-toggle="dropdown" aria-expanded="false" role="button"> --}}
{{-- <svg width="18" height="4"> --}}
{{-- <use xlink:href="#Dots"></use> --}}
{{-- </svg> --}}
{{-- </a> --}}
<div class="announcement__actions">
<button x-data="{ open: false }" x-on:click="open = ! open" type="button"
class="announcement__actions-btn icon-more-horizontal"></button>
<ul class="announcement__actions-list">
<li class="announcement__actions-item">
<a href="{{ route('blog_post.show', $blogPost) }}"
class="announcement__action">Посмотреть</a>
</li>
@can('edit', $blogPost)
<li class="announcement__actions-item">
<a href="{{ route('blog_post.edit', $blogPost) }}"
class="announcement__action">Редактировать</a>
</li>
@endcan
<li class="announcement__actions-item">
<button type="button" class="announcement__action">О рекламодателе</button>
</li>
<li class="announcement__actions-item">
<button type="button" class="announcement__action">Не интересно</button>
</li>
<li class="announcement__actions-item">
<button type="button" class="announcement__action">Пожаловаться</button>
</li>
</ul>
</div>
{{-- <ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown"> --}}
{{-- <li><a class="dropdown-item" href="{{ route('blog_post.edit', $blogPost->id) }}">Edit</a> --}}
{{-- </li> --}}
{{-- <li><a class="dropdown-item" href="#">Другое действие</a></li> --}}
{{-- <li> --}}
{{-- <hr class="dropdown-divider"> --}}
{{-- </li> --}}
{{-- <li><a class="dropdown-item" href="#">Что-то еще</a></li> --}}
{{-- </ul> --}}
</li>
</ul>
</div>
<div class="col-12 col-md-7 pe-0 d-flex flex-column justify-content-between">
<div>
<div class="mb-3 fs-18 --f_bold --no_wrap_normal">{{ $blogPost->title }}</div>
<div class="mt-3 lh-sm --no_wrap_normal">
<small>
{!! $blogPost->description !!}
</small>
<div class="row m-0 mt-2 p-3 bg_lightest_blue-v2">
<div class="col-12 col-md-3 mt-3 mt-md-0 fs-14">
<div class="h6 mb-2 mb-md-3 --f_bold --f_grey text-uppercase">Теги:</div>
<div class="fs-6 --tags --m_large --no_wrap_normal">
@foreach ($blogPost->tags as $curTag)
<a href="{{ $curTag->index_url }}"
class="btn badge --radius --bg-blue --f_bold --f_main">{{ $curTag->name }}</a>
@endforeach
</div>
</div>
<div class="mt-3 fs-14 --f_bolder">
@if(filter_var($blogPost->youtube_url, FILTER_VALIDATE_URL))
<a href="{{ $blogPost->youtube_url }}" class="d-inline-flex align-items-center" target="_blank">
<span class="--f_main">Посмотреть рецепт на YouTube</span>
<svg width="18" height="14" class="ms-2"><use xlink:href="#YouTubeIcon"></use></svg>
</a>
@endif
</div>
</div>
<ul class="navbar-nav --abs --dotted --r w-auto mt-2 me-2 mt-md-3 me-md-3 p-0" style="--bs-scroll-height:100px;">
<li class="nav-item dropdown">
<a id="dLabel" class="nav-link py-0 dropdown-toggle-js" href="#" data-bs-toggle="dropdown" aria-expanded="false" role="button">
<svg width="18" height="4"><use xlink:href="#Dots"></use></svg>
</a>
<ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown">
<li><a class="dropdown-item" href="{{ route('blog_post.edit', $blogPost->id) }}">Edit</a></li>
<li><a class="dropdown-item" href="#">Другое действие</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Что-то еще</a></li>
</ul>
</li>
</ul>
</div>
<div class="row m-0 mt-2 p-3 bg_lightest_blue-v2">
<div class="col-12 col-md-3 mt-3 mt-md-0 fs-14">
<div class="h6 mb-2 mb-md-3 --f_bold --f_grey text-uppercase">Теги:</div>
<div class="fs-6 --tags --m_large --no_wrap_normal">
@foreach($blogPost->tags as $curTag)
<a href="{{ $curTag->index_url }}" class="btn badge --radius --bg-blue --f_bold --f_main">{{ $curTag->name }}</a>
@endforeach
</div>
<div class="d-flex p-4 align-items-center justify-content-between justify-content-sm-center --f_bold">
<a href="#" class="d-flex align-items-center me-4 me-sm-5 --f_main">
<small>
<svg width="21" height="20" class="me-1">
<use xlink:href="#ActionComment"></use>
</svg>
Комментировать
</small>
</a>
@livewire('blog-post.like', ['blogPost' => $blogPost])
<a href="#" class="d-flex align-items-center --f_main">
<small>
<svg width="21" height="22" class="me-1">
<use xlink:href="#Share"></use>
</svg>
<span class="d-none d-sm-inline">Поделится</span>
</small>
</a>
</div>
</div>
<div class="d-flex p-4 align-items-center justify-content-between justify-content-sm-center --f_bold">
<a href="#" class="d-flex align-items-center me-4 me-sm-5 --f_main">
<small>
<svg width="21" height="20" class="me-1">
<use xlink:href="#ActionComment"></use>
</svg>
Комментировать
</small>
</a>
@livewire('blog-post.like', ['blogPost' => $blogPost])
<a href="#" class="d-flex align-items-center --f_main">
<small>
<svg width="21" height="22" class="me-1">
<use xlink:href="#Share"></use>
</svg>
<span class="d-none d-sm-inline">Поделится</span>
</small>
</a>
</div>
</div>
</div>
<div id="commentsList" class="container p-0 --mw-1000">
@livewire('blog-post.comment.show', ['blogPost' => $blogPost])
</div>
<div class="container px-0 mb-4 --mw-1000 --bg_white --radius fs-4_5">
@livewire('blog-post.comment.create', ['blogPost' => $blogPost, 'user' => Auth::user()])
</div>
</section>
<div id="commentsList" class="container p-0 --mw-1000">
@livewire('blog-post.comment.show', ['blogPost' => $blogPost])
</div>
<div class="container px-0 mb-4 --mw-1000 --bg_white --radius fs-4_5">
@livewire('blog-post.comment.create', ['blogPost' => $blogPost, 'user' => Auth::user()])
</div>
</section>
@endsection
@push('jq_scripts')
<script src="/js/bootstrap.min.js"></script>
<script src="/js/bootstrap.bundle.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/bootstrap.bundle.min.js"></script>
@endpush

View File

@@ -1,5 +1,6 @@
<section class="py-5" id="main">
<div class="container d-block d-sm-flex justify-content-between align-items-end align-items-lg-center mb-4 p-0 --mw-1000" wire:key="search">
<div class="container d-block d-sm-flex justify-content-between align-items-end align-items-lg-center mb-4 p-0 --mw-1000"
wire:key="search">
<div class="d-block d-lg-flex align-items-center col-12 col-sm-9 me-lg-2 mb-1 mb-sm-0 p-0 pe-sm-2">
<div class="h4 me-md-3 mb-3 mb-lg-0 --f_grey text-uppercase">Популярные записи</div>
<div class="d-flex align-items-center -search flex-grow-1">
@@ -8,84 +9,154 @@
<use xlink:href="#SearchIcon"></use>
</svg>
</span>
<input class="form-control" name="search" wire:model.live.debounce.500ms="search" type="search" placeholder="Поиск записи" />
<input class="form-control" name="search" wire:model.live.debounce.500ms="search" type="search"
placeholder="Поиск записи" />
</div>
</div>
<div class="col-12 col-sm px-0 flex-grow-1">
<button type="submit" class="btn btn-lg btn-primary btn-block w-100 ps-4 pe-sm-4 --f_bold text-uppercase --no_wrap --radius">Найти запись</button>
<button type="submit"
class="btn btn-lg btn-primary btn-block w-100 ps-4 pe-sm-4 --f_bold text-uppercase --no_wrap --radius">Найти
запись</button>
</div>
{{-- <span class="posts-str-search">{{ $search }}</span> --}}
</div>
<div class="container mb-4 p-3 overflow-hidden --bg_white --shadow --radius --mw-1000" wire:key="filter-type">
{{-- <span class="posts-type-filter">{{ $typeFilter }}</span> --}}
<ul class="nav nav-pills flex-nowrap --no_wrap w-100 --bordered --radius --tabs_blue overflow-x-xs-scroll" role="radiogroup">
<ul class="nav nav-pills flex-nowrap --no_wrap w-100 --bordered --radius --tabs_blue overflow-x-xs-scroll"
role="radiogroup">
<li class="col nav-item" role="presentation" id="type-all" wire:key="type-all">
<label @class(["btn", "btn-lg", "nav-link", "py-3", "--radius", "active" => $typeFilter === 'all']) data-bs-toggle="pill" role="radio" aria-selected="true">
<input type="radio" wire:model.live="typeFilter" value="all" @checked(($typeFilter == '' || $typeFilter == 'all')) />
<label @class([
'btn',
'btn-lg',
'nav-link',
'py-3',
'--radius',
'active' => $typeFilter === 'all',
]) data-bs-toggle="pill" role="radio" aria-selected="true">
<input type="radio" wire:model.live="typeFilter" value="all" @checked($typeFilter == '' || $typeFilter == 'all') />
Все
</label>
</li>
<li class="col nav-item" role="presentation" id="type-consultant" wire:key="type-consultant">
<label @class(["btn", "btn-lg", "nav-link", "py-3", "--radius", "active" => $typeFilter === 'consultant']) data-bs-toggle="pill" role="radio" aria-selected="false">
<input type="radio" wire:model.live="typeFilter" value="consultant" @checked(($typeFilter == 'consultant')) />
<label @class([
'btn',
'btn-lg',
'nav-link',
'py-3',
'--radius',
'active' => $typeFilter === 'consultant',
]) data-bs-toggle="pill" role="radio" aria-selected="false">
<input type="radio" wire:model.live="typeFilter" value="consultant"
@checked($typeFilter == 'consultant') />
От Консультантов
</label>
</li>
<li class="col nav-item" role="presentation" id="type-user" wire:key="type-user">
<label @class(["btn", "btn-lg", "nav-link", "py-3", "--radius", "active" => $typeFilter === 'user' ]) data-bs-toggle="pill" role="radio" aria-selected="false" >
<input type="radio" wire:model.live="typeFilter" value="user" @checked(($typeFilter == 'user')) />
<label @class([
'btn',
'btn-lg',
'nav-link',
'py-3',
'--radius',
'active' => $typeFilter === 'user',
]) data-bs-toggle="pill" role="radio" aria-selected="false">
<input type="radio" wire:model.live="typeFilter" value="user" @checked($typeFilter == 'user') />
Пользовательские
</label>
</li>
</ul>
</div>
<div id="recordsList" class="container p-0 --mw-1000" wire:key="posts-result">
@foreach($blogPosts as $post)
@foreach ($blogPosts as $post)
@php
$author = $post->author()->first();
$authorPhoto = $author->profile_photo_url;
$image = Storage::url($post->image);
$blogPostViewsCount = views($post)->unique()->count();
$blogPostViewsCount = views($post)
->unique()
->count();
@endphp
<div class="mb-4 p-3 --bg_white --shadow --radius --no_wrap" data-record_type="user" wire:key="post_{{ $post->id }}" id="post_id_{{ $post->id }}">
<div class="mb-4 p-3 --bg_white --shadow --radius --no_wrap" data-record_type="user"
wire:key="post_{{ $post->id }}" id="post_id_{{ $post->id }}">
<div class="d-flex mb-4 align-items-center justify-content-between">
<div class="d-flex align-items-center">
<!--img src="{{ $authorPhoto }}" width="42px" height="42px" class="me-2 --radius_100"-->
<a href="{{ route('profile.show', $author->id) }}" class="d-none d-sm-block overflow-hidden rounded-full mr-4" >
<a href="{{ route('profile.show', $author->id) }}"
class="d-none d-sm-block overflow-hidden rounded-full mr-4">
<div class="centered-bg-img" style="background-image: url('{{ $authorPhoto }}')"></div>
</a>
<small>
<span class="d-block --f_bold lh-1"><a href="{{ route('profile.show', $author->id) }}" class="text-black">{{ $author->name }}</a></span>
<span class="--f_grey"><a class="text-black" href="{{ route('blog_post.show', $post->id) }}">{{ $post->created_at }}</a></span>
<span class="d-block --f_bold lh-1"><a href="{{ route('profile.show', $author->id) }}"
class="text-black">{{ $author->name }}</a></span>
<span class="--f_grey"><a class="text-black"
href="{{ route('blog_post.show', $post->id) }}">{{ $post->created_at }}</a></span>
</small>
</div>
<ul class="navbar-nav" style="--bs-scroll-height:100px;">
<li class="nav-item dropdown">
<a id="dLabel" class="nav-link py-0 dropdown-toggle-js" href="#" data-bs-toggle="dropdown" aria-expanded="false" role="button">
<svg width="18" height="4"><use xlink:href="#Dots"></use></svg>
</a>
<ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown">
<li><a class="dropdown-item" href="{{ route('blog_post.edit', $post->id) }}">Edit</a></li>
<li><a class="dropdown-item" href="{{ route('blog_post.show', $post->id) }}">Show</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Что-то еще</a></li>
</ul>
</li>
</ul>
<div class="announcement__actions">
<button x-data="{ open: false }" x-on:click="open = ! open" type="button"
class="announcement__actions-btn icon-more-horizontal"></button>
<ul class="announcement__actions-list">
<li class="announcement__actions-item">
<a href="{{ route('blog_post.show', $post) }}"
class="announcement__action">Посмотреть</a>
</li>
@can('edit', $post)
<li class="announcement__actions-item">
<a href="{{ route('blog_post.edit', $post) }}"
class="announcement__action">Редактировать</a>
</li>
@endcan
<li class="announcement__actions-item">
<button type="button" class="announcement__action">О рекламодателе</button>
</li>
<li class="announcement__actions-item">
<button type="button" class="announcement__action">Не интересно</button>
</li>
<li class="announcement__actions-item">
<button type="button" class="announcement__action">Пожаловаться</button>
</li>
</ul>
</div>
{{-- <ul class="navbar-nav" style="--bs-scroll-height:100px;"> --}}
{{-- <li class="nav-item dropdown"> --}}
{{-- <a id="dLabel" class="nav-link py-0 dropdown-toggle-js" href="#" data-bs-toggle="dropdown" aria-expanded="false" role="button"> --}}
{{-- <svg width="18" height="4"><use xlink:href="#Dots"></use></svg> --}}
{{-- </a> --}}
{{-- <ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown"> --}}
{{-- <li><a class="dropdown-item" href="{{ route('blog_post.edit', $post->id) }}">Edit</a></li> --}}
{{-- <li><a class="dropdown-item" href="{{ route('blog_post.show', $post->id) }}">Show</a></li> --}}
{{-- <li><hr class="dropdown-divider"></li> --}}
{{-- <li><a class="dropdown-item" href="#">Что-то еще</a></li> --}}
{{-- </ul> --}}
{{-- </li> --}}
{{-- </ul> --}}
</div>
<div class="h6 --f_bold --no_wrap_normal"><a class="text-black" href="{{ route('blog_post.show', $post->id) }}">{{ $post->title }}</a></div>
<div class="h6 --f_bold --no_wrap_normal"><a class="text-black"
href="{{ route('blog_post.show', $post->id) }}">{{ $post->title }}</a></div>
<small class="d-block --no_wrap_normal my-3">{!! $post->description !!}</small>
<div class="d-flex justify-center position-relative post_img">
<img src="{{ $image }}" class="w-8/12 --radius">
<div class="post_v_l w-100 d-flex justify-content-center align-items-center position-absolute --f_white">
<svg width="20" height="14" class="me-2"><use xlink:href="#Eye_White"></use></svg>
<div
class="post_v_l w-100 d-flex justify-content-center align-items-center position-absolute --f_white">
<svg width="20" height="14" class="me-2">
<use xlink:href="#Eye_White"></use>
</svg>
<span class="me-3">{{ $blogPostViewsCount }}</span>
<svg width="16" height="14" class="me-2"><use xlink:href="#Heart_White"></use></svg>
<livewire:blog-post.like-count :blogPost="$post" wire:key="post-likes-count-key-{{ $post->id }}" />
<svg width="16" height="14" class="me-2">
<use xlink:href="#Heart_White"></use>
</svg>
<livewire:blog-post.like-count :blogPost="$post"
wire:key="post-likes-count-key-{{ $post->id }}" />
</div>
</div>
<div class="d-flex mt-4 mb-3 align-items-center justify-content-between justify-content-sm-center --f_bold">
<a href="{{ route('blog_post.show', $post->id) }}#commentsList" class="d-flex align-items-center me-4 me-sm-5 --f_main">
<div
class="d-flex mt-4 mb-3 align-items-center justify-content-between justify-content-sm-center --f_bold">
<a href="{{ route('blog_post.show', $post->id) }}#commentsList"
class="d-flex align-items-center me-4 me-sm-5 --f_main">
<small>
<svg width="21" height="20" class="me-1">
<use xlink:href="#ActionComment"></use>
@@ -96,7 +167,9 @@
<livewire:blog-post.like :blogPost="$post" wire:key="post-like-key-{{ $post->id }}" />
<a href="#" class="d-flex align-items-center --f_main">
<small>
<svg width="21" height="22" class="me-1"><use xlink:href="#Share"></use></svg>
<svg width="21" height="22" class="me-1">
<use xlink:href="#Share"></use>
</svg>
<span class="d-none d-sm-inline">Поделится</span>
</small>
</a>
@@ -106,4 +179,3 @@
{{ $blogPosts->links() }}
</div>
</section>