Showing
3 changed files
with
48 additions
and
0 deletions
interfaces/movieComment.ts
0 → 100644
models/movieComment.ts
0 → 100644
1 | +import { Model } from "pinia-orm"; | ||
2 | +import { Movie } from "~/models/movie"; | ||
3 | + | ||
4 | +export class MovieComment extends Model { | ||
5 | + /** | ||
6 | + * | ||
7 | + * @return {string} | ||
8 | + */ | ||
9 | + static get entity() { | ||
10 | + return "MovieComment"; | ||
11 | + } | ||
12 | + | ||
13 | + /** | ||
14 | + * | ||
15 | + * @return {string} | ||
16 | + */ | ||
17 | + static get primaryKey() { | ||
18 | + return "id"; | ||
19 | + } | ||
20 | + | ||
21 | + static fields() { | ||
22 | + return { | ||
23 | + // Attributs. | ||
24 | + id: this.number(null), | ||
25 | + username: this.string(''), | ||
26 | + message: this.string(''), | ||
27 | + rating: this.string(''), | ||
28 | + // Relations. | ||
29 | + movie_id: this.attr(null), | ||
30 | + movie: this.belongsTo(Movie, "movie_id", "id"), | ||
31 | + }; | ||
32 | + } | ||
33 | + | ||
34 | + static piniaOptions = { | ||
35 | + persist: true, | ||
36 | + }; | ||
37 | +} |
@@ -105,6 +105,7 @@ async function fetchCredits(id: number | string) { | @@ -105,6 +105,7 @@ async function fetchCredits(id: number | string) { | ||
105 | } | 105 | } |
106 | 106 | ||
107 | function handleSubmitEvent(event: Comment) { | 107 | function handleSubmitEvent(event: Comment) { |
108 | + //todo : faire la gestion des commentaire avec un nouveau model + liaison. | ||
108 | console.log('submitted', event) | 109 | console.log('submitted', event) |
109 | } | 110 | } |
110 | 111 | ||
@@ -183,6 +184,7 @@ onMounted(() => { | @@ -183,6 +184,7 @@ onMounted(() => { | ||
183 | </div> | 184 | </div> |
184 | </div> | 185 | </div> |
185 | <!-- Comments form. --> | 186 | <!-- Comments form. --> |
187 | + <h3 class="text-xl font-bold mt-8 mb-4">Ajouter un commentaire</h3> | ||
186 | <form-movie-comment-form @event:submit="handleSubmitEvent" /> | 188 | <form-movie-comment-form @event:submit="handleSubmitEvent" /> |
187 | </section> | 189 | </section> |
188 | </div> | 190 | </div> |
-
Please register or login to post a comment