add videos file list

This commit is contained in:
2024-05-01 20:27:23 +10:00
parent 1e1df33711
commit 629ae22b78
3 changed files with 12 additions and 4 deletions

View File

@@ -81,6 +81,7 @@ class PostController extends Controller
$post = Post::create($postData); $post = Post::create($postData);
$post->updateFiles($request->input('files')); $post->updateFiles($request->input('files'));
$post->updateFiles($request->input('gallery'), 'gallery'); $post->updateFiles($request->input('gallery'), 'gallery');
$post->updateFiles($request->input('videos'), 'videos');
session()->flash('message', 'Post has been created'); session()->flash('message', 'Post has been created');
session()->flash('message-title', 'Post created'); session()->flash('message-title', 'Post created');
@@ -101,9 +102,6 @@ class PostController extends Controller
*/ */
public function admin_edit(Post $post) public function admin_edit(Post $post)
{ {
$fileNameList = $post->files->pluck('name')->toArray();
$post->files = $fileNameList;
return view('admin.post.edit', ['post' => $post]); return view('admin.post.edit', ['post' => $post]);
} }
@@ -126,6 +124,7 @@ class PostController extends Controller
$post->update($postData); $post->update($postData);
$post->updateFiles($request->input('files')); $post->updateFiles($request->input('files'));
$post->updateFiles($request->input('gallery'), 'gallery'); $post->updateFiles($request->input('gallery'), 'gallery');
$post->updateFiles($request->input('videos'), 'videos');
session()->flash('message', 'Post has been updated'); session()->flash('message', 'Post has been updated');
session()->flash('message-title', 'Post updated'); session()->flash('message-title', 'Post updated');

View File

@@ -42,7 +42,15 @@
></x-ui.gallery> ></x-ui.gallery>
</div> </div>
<p class="text-red-500"> <div class="mb-4">
<x-ui.filelist
label="Videos"
name="videos"
value="{!! isset($post) ? $post->files('videos')->orderBy('name')->get() : '' !!}"
editor="true"
></x-ui.filelist>
</div>
<div class="mb-4"> <div class="mb-4">
<x-ui.filelist <x-ui.filelist
label="Files" label="Files"

View File

@@ -10,6 +10,7 @@
</div> </div>
<article class="content mb-4">{!! $post->content !!}</article> <article class="content mb-4">{!! $post->content !!}</article>
<x-ui.gallery class="mt-16" value="{{ \App\Helpers::arrayToString($post->files('gallery')->pluck('name')->toArray()) }}" /> <x-ui.gallery class="mt-16" value="{{ \App\Helpers::arrayToString($post->files('gallery')->pluck('name')->toArray()) }}" />
<x-ui.filelist class="mt-16" label="Videos" value="{!! $post->files('videos')->orderBy('name')->get() !!}" />
<x-ui.filelist class="mt-16" value="{!! $post->files()->orderBy('name')->get() !!}" /> <x-ui.filelist class="mt-16" value="{!! $post->files()->orderBy('name')->get() !!}" />
</x-container> </x-container>
</x-layout> </x-layout>