Skip to content

Commit 0d1948f

Browse files
committed
show categories, delete categories functionality done!
1 parent 26ede96 commit 0d1948f

File tree

13 files changed

+27516
-46440
lines changed

13 files changed

+27516
-46440
lines changed

app/Http/Controllers/PostController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function show(Post $post)
5151
*/
5252
public function update(Request $request, Post $post)
5353
{
54+
$post = $request->all();
5455
$post->update($request->all());
5556
return response('updated','200');
5657
}

package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"vue-template-compiler": "^2.6.10"
2525
},
2626
"dependencies": {
27+
"@ckeditor/ckeditor5-build-classic": "^12.1.0",
28+
"@ckeditor/ckeditor5-vue": "^1.0.0-beta.2",
29+
"highlight.js": "^9.15.6",
2730
"vue-router": "^3.0.6",
2831
"vue-simplemde": "^0.5.2",
2932
"vuex": "^3.1.1"

public/js/app.js

Lines changed: 27348 additions & 46417 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/app.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ Vue.component('App', require('./App.vue').default);
2424
import router from './router.js';
2525
import store from './store';
2626

27-
import VueSimplemde from 'vue-simplemde'
28-
import 'simplemde/dist/simplemde.min.css'
29-
30-
Vue.use(VueSimplemde)
27+
import CKEditor from '@ckeditor/ckeditor5-vue';
28+
Vue.use( CKEditor );
3129

3230
/**
3331
* Next, we will create a fresh Vue application instance and attach it to

resources/js/components/CreatePost.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</select>
1616
</div>
1717
<div class="form-group">
18-
<markdown-editor v-model="body" ref="markdownEditor"></markdown-editor>
18+
<ckeditor :editor="editor" v-model="body" :config="editorConfig"></ckeditor>
1919
</div>
2020
<div class="form-group">
2121
<input @click="CreatePost" type="submit" class="btn btn-primary">
@@ -27,12 +27,17 @@
2727
</template>
2828
<script type="text/javascript">
2929
import { mapGetters } from 'vuex'
30+
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
3031
export default {
3132
data(){
3233
return {
3334
title:'',
3435
category:'',
35-
body:'',
36+
editor: ClassicEditor,
37+
body: '<p>Content of the editor.</p>',
38+
editorConfig: {
39+
// The configuration of the editor.
40+
}
3641
}
3742
},
3843
mounted(){
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<div class="container">
3+
<div class="row justify-content-center">
4+
<div class="col-md-8">
5+
<h1>Categories</h1>
6+
<hr>
7+
<table class="table table-striped table-inverse table-hover">
8+
<thead>
9+
<tr>
10+
<th>#</th>
11+
<th>Category</th>
12+
<th>Edit</th>
13+
<th>Delete</th>
14+
</tr>
15+
</thead>
16+
<tbody>
17+
<tr v-for="category in categories">
18+
<td>{{category.id}}</td>
19+
<td>{{category.category}}</td>
20+
<td><router-link class="btn btn-primary" :to="{name: 'CategoryEdit', params: {id: category.id}}"> Edit</router-link></td>
21+
<td><button @click="DeleteCategory(category.id)" type="button" class="btn btn-danger">Delete</button></td>
22+
</tr>
23+
</tbody>
24+
</table>
25+
</div>
26+
</div>
27+
</div>
28+
</template>
29+
<script type="text/javascript">
30+
import { mapGetters } from 'vuex'
31+
export default{
32+
data(){
33+
return{
34+
35+
}
36+
},
37+
computed:{
38+
...mapGetters([
39+
'categories'
40+
])
41+
},
42+
mounted(){
43+
this.$store.dispatch('get_Categories');
44+
},
45+
methods:{
46+
DeleteCategory(category_id){
47+
console.log(category_id)
48+
this.$store.dispatch('Delete_Category',category_id)
49+
}
50+
}
51+
}
52+
</script>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<div>
3+
<h1>Category Edit</h1>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
10+
name: 'categoryEdit',
11+
12+
data () {
13+
return {
14+
15+
}
16+
}
17+
}
18+
</script>
19+
20+
<style lang="css" scoped>
21+
</style>

resources/js/components/editPost.vue

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,62 @@
22
<div>
33
<div class="container">
44
<div class="row">
5-
<div class="col-md-8">
5+
<div class="col-md-8" v-if="single_post">
66
<h1>Edit Post:</h1>
77
<div class="form-group">
88
<label>Title:</label>
9-
<input v-model="title" class="form-control" type="text" placeholder="Enter the Title">
9+
<input :value="single_post.title" @input="single_post.title = $event.target.value" class="form-control" type="text" placeholder="Enter the Title">
1010
</div>
1111
<div class="form-group">
1212
<label>Category:</label>
13-
<select v-model="category" class="custom-select" >
13+
<select :value="single_post.category" @input="single_post.category =$event.target.value" class="custom-select" >
1414
<option v-for="category in categories" :value="category.id">{{category.category}}</option>
1515
</select>
1616
</div>
1717
<div class="form-group">
1818
<label>Body:</label>
19-
<markdown-editor v-model="body" ref="markdownEditor"></markdown-editor>
19+
<ckeditor :editor="editor" v-model="single_post.body" :config="editorConfig"></ckeditor>
2020
</div>
2121
<div class="form-group">
22-
<input @click="CreatePost" type="submit" class="btn btn-primary">
22+
<input @click="UpdatePost" type="submit" class="btn btn-primary">
2323
</div>
2424
</div>
2525
</div>
2626
</div>
2727
</div>
2828
</template>
2929
<script type="text/javascript">
30+
import { mapGetters } from 'vuex'
31+
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
3032
export default{
3133
data(){
3234
return{
33-
message: 'I am in',
35+
body:'',
36+
editor: ClassicEditor,
37+
editorConfig: {
38+
// The configuration of the editor.
39+
}
40+
}
41+
},
42+
mounted(){
43+
const slug = this.$route.params.slug;
44+
this.$store.dispatch('get_single_post',slug)
45+
this.$store.dispatch('get_Categories')
46+
},
47+
computed:{
48+
...mapGetters([
49+
'single_post',
50+
'categories'
51+
])
52+
},
53+
methods:{
54+
UpdatePost(){
55+
console.log('update post');
56+
const slug = this.$route.params.slug;
57+
const UpdateData = [this.single_post.title, this.single_post.category, this.single_post.body];
58+
console.log(UpdateData);
59+
60+
this.$store.dispatch('Edit_Post',UpdateData,slug)
3461
}
3562
}
3663
}

resources/js/components/navbar.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
33
<nav class="navbar navbar-expand-lg navbar-light bg-light mb-5">
4-
<a class="navbar-brand" href="#">Navbar</a>
4+
<a class="navbar-brand" href="#">VueBlog</a>
55
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
66
<span class="navbar-toggler-icon"></span>
77
</button>
@@ -14,7 +14,7 @@
1414
<router-link to="/create_post" class="nav-link">Create Post</router-link>
1515
</li>
1616
<li class="nav-item">
17-
<router-link to="/create_post" class="nav-link">Categories</router-link>
17+
<router-link to="/category" class="nav-link">Categories</router-link>
1818
</li>
1919
<li class="nav-item">
2020
<a class="nav-link disabled" href="#">Disabled</a>

0 commit comments

Comments
 (0)