Skip to content

Commit 51a0bc6

Browse files
committed
blog settings updated
1 parent 55b5d37 commit 51a0bc6

16 files changed

+479
-630
lines changed

app/Http/Livewire/Blogs/Create.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function draft()
7272
$blog = Blog::create([
7373
'title' => $this->title,
7474
'body' => $this->body,
75-
'status' => "drafted",
75+
'published'=>0,
7676
'user_id' => auth()->id(),
7777
'cover_image'=> $this->coverImage->store('/','images')
7878
]);

app/Http/Livewire/Blogs/Manage.php

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace App\Http\Livewire\Blogs;
4+
5+
use App\Models\Blog;
6+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
7+
use Livewire\Component;
8+
9+
class Manage extends Component
10+
{
11+
use AuthorizesRequests;
12+
public $tab = "manage";
13+
public $blog;
14+
public $comment_access;
15+
public $blog_access;
16+
public $adult_warning;
17+
public $age_confirmation;
18+
public function mount(Blog $blog)
19+
{
20+
$this->blog = $blog;
21+
$this->comment_access = $blog->comment_access;
22+
$this->blog_access = $blog->access;
23+
$this->adult_warning = $blog->adult_warning;
24+
$this->age_confirmation = $blog->age_confirmation;
25+
}
26+
public function render()
27+
{
28+
return view('livewire.blogs.manage');
29+
}
30+
// protected $rules = [
31+
// ];
32+
public function update()
33+
{
34+
35+
$this->authorize('update', $this->blog);
36+
// $this->validate();
37+
$this->blog->access = $this->blog_access;
38+
$this->blog->comment_access = $this->comment_access;
39+
$this->blog->adult_warning = $this->adult_warning;
40+
$this->blog->age_confirmation = $this->age_confirmation;
41+
$saved = $this->blog->save();
42+
if ($saved) {
43+
$this->emit('changed');
44+
session()->flash('message', 'blog updated successfully');
45+
}
46+
}
47+
public function delete()
48+
{
49+
$this->authorize('delete', $this->blog);
50+
$this->blog->delete();
51+
return redirect()->to('/blogs');
52+
}
53+
}

app/Http/Livewire/Blogs/Stats.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Http\Livewire\Blogs;
4+
5+
use Livewire\Component;
6+
7+
class Stats extends Component
8+
{
9+
public $tab="stats";
10+
public $blog;
11+
public function mount($blog)
12+
{
13+
$this->blog=$blog;
14+
}
15+
public function render()
16+
{
17+
return view('livewire.blogs.stats');
18+
}
19+
}

app/Http/Livewire/Notifications.php

+28-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,25 @@ class Notifications extends Component
1818
use WithPagination;
1919

2020
public $notificationCount = 0;
21-
public $tab='all';
21+
public $tab = 'all';
22+
23+
protected $queryString = [
24+
'tab' => ['except' => 'all']
25+
];
2226
public function render(): View
2327
{
28+
if ($this->validSort($this->tab)&&$this->tab!='all') {
29+
30+
$unreadNotifications=Auth::user()->unreadNotifications()->get();
31+
$notifications=Auth::user()->readNotifications()->get();
32+
} else {
33+
$this->tab = 'all';
34+
$unreadNotifications=Auth::user()->unreadNotifications()->get();
35+
$notifications=Auth::user()->readNotifications()->get();
36+
}
2437
return view('livewire.notifications', [
25-
'unreadNotifications' => Auth::user()->unreadNotifications()->get(),
26-
'notifications' => Auth::user()->readNotifications()->get(),
38+
'unreadNotifications' => $unreadNotifications,
39+
'notifications' => $notifications,
2740
]);
2841
}
2942

@@ -34,6 +47,18 @@ public function mount(): void
3447
$this->notificationCount = Auth::user()->unreadNotifications()->count();
3548
}
3649

50+
public function sortBy($sort): void
51+
{
52+
$this->tab = $this->validSort($sort) ? $sort : 'all';
53+
}
54+
public function validSort($sort): bool
55+
{
56+
return in_array($sort, [
57+
'all',
58+
'new_blog',
59+
'new_user'
60+
]);
61+
}
3762
public function markAsRead(string $notificationId): void
3863
{
3964
$notification = DatabaseNotification::findOrFail($notificationId);

resources/views/blogs/manage.blade.php

+3-319
Large diffs are not rendered by default.

resources/views/blogs/show.blade.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,17 @@ class="font-black text-skin-600 ml-2">learn more</a></p>
3535
<x-slot name="content">
3636
<ul>
3737
<li>
38-
<x-dropdown-link
39-
href="/blogs/edit/{{ $blog->slug}}"
40-
class="flex ">
38+
<x-dropdown-link href="/blogs/edit/{{ $blog->slug }}" class="flex ">
4139
{{ __(' Edit') }}
4240
</x-dropdown-link>
4341
</li>
4442
<li>
45-
<x-dropdown-link
46-
href="/blogs/manage/{{ $blog->slug}}"
47-
class="flex ">
43+
<x-dropdown-link href="/blogs/manage/{{ $blog->slug }}" class="flex ">
4844
{{ __('Manage') }}
4945
</x-dropdown-link>
5046
</li>
5147
<li>
52-
<x-dropdown-link
53-
href="/blogs/stats/{{ $blog->slug}}"
54-
class="flex ">
48+
<x-dropdown-link href="/blogs/stats/{{ $blog->slug }}" class="flex ">
5549
{{ __('Stats') }}
5650
</x-dropdown-link>
5751
</li>
@@ -161,9 +155,10 @@ class="follow_button_{{ $blog->user_id }} my-4 w-full inline-flex justify-center
161155
</svg>
162156
</h2>
163157

158+
<div class="not-prose">
164159
@foreach ($related as $sblog)
165-
<x-cards.blog-card :blog=$sblog class="not-prose" />
166-
@endforeach
160+
<x-cards.blog-card :blog="$sblog" />
161+
@endforeach</div>
167162
</div>
168163
@endif
169164
</div>
@@ -174,7 +169,7 @@ class="follow_button_{{ $blog->user_id }} my-4 w-full inline-flex justify-center
174169
<div class="grid grid-cols-4 gap-4 justify-between">
175170
<livewire:like-blog :blog_id="$blog->id" :likes_count="$blog->bloglikes->where('status', 1)->count()" :wire:key="$blog->id" />
176171
<div>
177-
<x-share :share="$shareBlog"/>
172+
<x-share :share="$shareBlog" />
178173

179174
</div>
180175
<livewire:bookmark :blog_id="$blog->id" :wire:key="$blog->id" />
@@ -215,6 +210,11 @@ class="h-10 w-10 bg-gray-50 rounded-full cursor-pointer" provider="gravatar" />
215210
</div>
216211
</div>
217212
</x-cards.primary-card>
213+
<div class="badge-base LI-profile-badge my-4" data-locale="en_US" data-size="medium" data-theme="light"
214+
data-type="VERTICAL" data-vanity="tanmaya-arora" data-version="v1"><a
215+
class="badge-base__link LI-simple-link"
216+
href="https://www.linkedin.com/tanmaya-arora?trk=profile-badge"></a>
217+
</div>
218218
<x-cards.primary-card :default=false>
219219
<header class="px-4 py-3 text-2xl font-semibold text-gray-700 dark:text-white">
220220
<span class="modern-badge modern-badge-danger">#Advertisment</span>

resources/views/blogs/stats.blade.php

+3-68
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,8 @@
1-
<x-app-layout>
2-
<?php
3-
$tab = 'all';
4-
?>
5-
<x-slot name="sidebar">
6-
<x-sidebar :topTags="false" :topUsers="false">
7-
<div id="sticky-sidebar" class="hidden py-4 overflow-y-auto rounded lg:block">
8-
<ul class="space-y-2">
9-
<li>
10-
<a href="#general"
11-
class="flex items-center p-2 text-base font-normal text-gray-900 dark:text-white }} hover:bg-gray-100 dark:hover:bg-gray-700">
12-
<span class="ml-3">General</span>
13-
</a>
14-
</li>
15-
<li>
16-
<a href="/blogs/edit/{{ $blog->slug}}"
17-
class="flex items-center p-2 text-base font-normal text-gray-900 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
18-
<span class="flex-1 ml-3 whitespace-nowrap">Edit</span>
19-
</a>
20-
</li>
21-
<li>
22-
<a href="/blogs/manage/{{ $blog->slug}}"
23-
class="flex items-center p-2 text-base font-normal text-gray-900 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
24-
<span class="flex-1 ml-3 whitespace-nowrap">Manage</span>
25-
</a>
26-
</li>
27-
28-
<li>
29-
<a href="#seo-settings"
30-
class="flex items-center p-2 text-base font-normal text-gray-900 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
31-
<span class="flex-1 ml-3 whitespace-nowrap">Seo Settings</span>
32-
</a>
33-
</li>
34-
</ul>
35-
<ul class="pt-4 mt-4 space-y-2 border-t border-gray-200 dark:border-gray-700">
36-
<li>
37-
<a href="#delete"
38-
class="flex items-center p-2 text-base font-normal transition duration-75 text-rose-600 hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white group">
39-
<span class="ml-4">Delete Blog</span>
40-
</a>
41-
</li>
42-
43-
</ul>
44-
</div>
45-
</x-sidebar>
46-
</x-slot>
1+
<x-base-layout>
472
<div class="w-full px-2 md:px-12 my-4 relative">
483
<section>
494
<x-cards.blog-card :blog=$blog class="not-prose sm:border-gray-200" />
505
</section>
51-
<div class="relative w-full mt-3">
52-
<section id="delete">
53-
<x-cards.primary-card :default=false>
54-
<header class="px-5 py-4 text-2xl font-semibold text-gray-700 dark:text-white">
55-
<h3>Blog Stats</h3>
56-
</header>
57-
<div class="px-5 py-4 border-t border-gray-200 last:rounded-b-xl">
58-
<div role="status" class="max-w-sm animate-pulse">
59-
<div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"></div>
60-
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px] mb-2.5"></div>
61-
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5"></div>
62-
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[330px] mb-2.5"></div>
63-
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[300px] mb-2.5"></div>
64-
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px]"></div>
65-
<span class="sr-only">coming soon ......</span>
66-
</div>
67-
</div>
68-
</x-cards.primary-card>
69-
</section>
70-
</div>
6+
<livewire:blogs.stats :blog="$blog" />
717
</div>
72-
73-
</x-base-layout>
8+
</x-base-layout>

resources/views/layouts/base.blade.php

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
@livewireScripts
5151
@stack('scripts')
52+
<script src="https://platform.linkedin.com/badges/js/profile.js" async defer type="text/javascript"></script>
5253
</body>
5354

5455
</html>

resources/views/livewire/blogs/create.blade.php

+28-40
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ class="relative my-10 prose max-w-none lg:max-w-full xl:max-w-none prose-img:rou
5555
<div>
5656
<x-buttons.primary class="mr-2 md:mr-4" wire:click="draft">
5757
<span class="hidden md:block">{{ __('Save as draft') }}</span>
58-
<span
59-
class="hover:text-skin-600 md:hidden">{{ svg('iconsax-bul-book-saved', 'h-6 w-6') }}</span>
58+
<span class="hover:text-skin-600 md:hidden">{{ svg('iconsax-bul-book-saved', 'h-6 w-6') }}</span>
6059
</x-buttons.primary>
6160
</div>
6261
<div>
@@ -69,46 +68,34 @@ class="hover:text-skin-600 md:hidden">{{ svg('iconsax-bul-book-saved', 'h-6 w-6'
6968
{{ svg('iconsax-bul-setting-2', 'h-6 w-6') }}
7069
</x-buttons.primary>
7170
</x-slot:title>
72-
<div class=" my-6">
73-
<label class="text-xl font-bold line-clamp-3 tracking-wide block mb-2 text-gray-700"
74-
for="name">Add a cover image</label>
75-
@if ($coverImage)
76-
coverImage Preview:
77-
<div class="relative pt-[60%] rounded-xl sm:pt-[50%] md:pt-[42%] ">
78-
<img class="absolute top-0 bottom-0 left-0 right-0 w-full h-full m-0 bg-skin-base shadow-md object-fit rounded-xl drop-shadow-md dark:bg-gray-800"
79-
src="{{ $coverImage->temporaryUrl() }}" alt="" />
71+
<div class="mb-4">
72+
<label class="text-xl font-bold line-clamp-3 tracking-wide block mb-2 text-gray-700">Add a
73+
cover image</label>
74+
<div class="flex flex-row mb-8 items-center">
75+
<div class="">
76+
@if ($coverImage)
77+
<img src="{{ $coverImage->temporaryUrl() }}"
78+
class="max-h-56 max-w-[224px] bg-gray-50 mr-8"
79+
alt="" />
80+
@endif
8081
</div>
81-
@endif
82-
<div x-data="{ isUploading: false, progress: 0 }" x-on:livewire-upload-start="isUploading = true"
83-
x-on:livewire-upload-finish="isUploading = false"
84-
x-on:livewire-upload-error="isUploading = false"
85-
x-on:livewire-upload-progress="progress = $event.detail.progress">
86-
87-
<!-- File Input -->
88-
89-
<input type="file" wire:model="coverImage"
90-
class="text-sm my-4 py-4 px-2 text-grey-500
91-
file:mr-5 file:py-3 file:px-10
92-
file:rounded-lg
93-
file:border file:border-solid
94-
file:shadow-sm
95-
hover:file:shadow-md
96-
file:text-md file:font-semibold
97-
file:bg-skin-base
98-
hover:file:cursor-pointer hover:file:opacity-80
99-
">
100-
<!-- Progress Bar -->
101-
102-
<div x-show="isUploading">
103-
104-
<progress max="100" x-bind:value="progress"></progress>
105-
82+
<div x-data="{ isUploading: false, progress: 0 }" x-on:livewire-upload-start="isUploading = true"
83+
x-on:livewire-upload-finish="isUploading = false"
84+
x-on:livewire-upload-error="isUploading = false"
85+
x-on:livewire-upload-progress="progress = $event.detail.progress" class="flex-1">
86+
<!-- File Input -->
87+
<input type="file" wire:model="coverImage" id="cover_image" class="sr-only" />
88+
<label
89+
class="bg-skin-base capatalize py-2 px-4 leading-6 border inline-flex flex-row justify-center items-center no-underline rounded-md font-semibold cursor-pointer transition duration-200 ease-in-out shadow-sm shadow-gray-100"
90+
for="cover_image">
91+
change
92+
</label>
93+
<div x-show="isUploading" class="mb-2">
94+
<progress max="100" x-bind:value="progress"></progress>
95+
</div>
96+
<x-error class="text-red-500" field="coverImage" />
10697
</div>
107-
10898
</div>
109-
@error('coverImage')
110-
<span class="error">{{ $message }}</span>
111-
@enderror
11299
</div>
113100
<div class="my-4">
114101
<label class="text-xl font-bold line-clamp-3 tracking-wide block mb-2 text-gray-700"
@@ -180,7 +167,8 @@ class="inline-flex py-1 px-2 mb-2 mx-[5px] text-[10px] leading-4 first:ml-0 font
180167
<div class=" mt-2 text-gray-700 px-6 sm:mt-6 md:px-20">
181168
<h1 class="text-3xl font-extrabold line-clamp-3 tracking-wide text-gray-700 mb-4">Create Blog</h1>
182169
<div class="my-4">
183-
<label class="text-xl font-bold line-clamp-3 tracking-wide block mb-2 text-gray-700" for="title">Title
170+
<label class="text-xl font-bold line-clamp-3 tracking-wide block mb-2 text-gray-700"
171+
for="title">Title
184172
of blog</label>
185173
<x-form.input-field type="text" id="title" wire:model="title" placeholder="Tittle . . . ." />
186174
<x-error field="title" class="text-rose-500" />

0 commit comments

Comments
 (0)