= ref({
+ id: "",
+ created_at: "",
+ updated_at: "",
title: "",
+ slug: "",
+ user_id: "",
user: { display_name: "" },
+ content: "",
+ publish_at: "",
+ hero: {},
+ gallery: [],
+ attachments: [],
});
/**
diff --git a/resources/js/views/Blog.vue b/resources/js/views/Blog.vue
index becb96a..128cbf0 100644
--- a/resources/js/views/Blog.vue
+++ b/resources/js/views/Blog.vue
@@ -137,7 +137,7 @@ watch(
() => articlesPage.value,
() => {
handleLoad();
- }
+ },
);
handleLoad();
diff --git a/resources/js/views/dashboard/ArticleEdit.vue b/resources/js/views/dashboard/ArticleEdit.vue
index b12f0f3..81586f5 100644
--- a/resources/js/views/dashboard/ArticleEdit.vue
+++ b/resources/js/views/dashboard/ArticleEdit.vue
@@ -38,6 +38,15 @@
class="mb-8"
v-model:model-value="form.controls.content.value" />
+
+
Gallery
+
+ {{ gallery.length }} image{{
+ gallery.length != 1 ? "s" : ""
+ }}
+
+
+
{
@@ -164,8 +175,10 @@ const loadData = async () => {
attachments.value = (data.article.attachments || []).map(
function (attachment) {
return attachment.id.toString();
- }
+ },
);
+
+ gallery.value = data.article.gallery;
} else {
pageError.value = 404;
}
@@ -183,11 +196,12 @@ const handleSubmit = async () => {
title: form.controls.title.value,
slug: form.controls.slug.value,
publish_at: new SMDate(
- form.controls.publish_at.value as string
+ form.controls.publish_at.value as string,
).format("yyyy/MM/dd HH:mm:ss", { utc: true }),
user_id: form.controls.user_id.value,
content: form.controls.content.value,
hero: form.controls.hero.value.id,
+ gallery: gallery.value.map((item) => item.id),
};
let article_id = "";
@@ -280,7 +294,7 @@ const attachmentAdd = async (event) => {
},
progress: (progressEvent) =>
event.attachment.setUploadProgress(
- (progressEvent.loaded * progressEvent.total) / 100
+ (progressEvent.loaded * progressEvent.total) / 100,
),
});
@@ -292,7 +306,7 @@ const attachmentAdd = async (event) => {
event.preventDefault();
alert(
err.response?.data?.message ||
- "An unexpected server error occurred"
+ "An unexpected server error occurred",
);
}
}
diff --git a/routes/api.php b/routes/api.php
index fff3675..81fd40c 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -44,10 +44,10 @@ Route::apiResource('media', MediaController::class);
Route::get('media/{medium}/download', [MediaController::class, 'download']);
Route::apiResource('articles', ArticleController::class);
-Route::apiAddendumResource('attachment', 'articles', ArticleController::class);
+Route::apiAddendumResource('attachments', 'articles', ArticleController::class);
Route::apiResource('events', EventController::class);
-Route::apiAddendumResource('attachment', 'events', EventController::class);
+Route::apiAddendumResource('attachments', 'events', EventController::class);
Route::get('/events/{event}/users', [EventController::class, 'userList']);
Route::post('/events/{event}/users', [EventController::class, 'userAdd']);