Initial commit
This commit is contained in:
35
resources/js/store/modules/blog/guides.js
vendored
Normal file
35
resources/js/store/modules/blog/guides.js
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
export const namespaced = true
|
||||
|
||||
// state
|
||||
export const state = {
|
||||
content: []
|
||||
}
|
||||
|
||||
// getters
|
||||
export const getters = {
|
||||
getById: (state) => (id) => {
|
||||
if (state.content.length === 0) return null
|
||||
return state.content.find(item => item.id === id)
|
||||
}
|
||||
}
|
||||
|
||||
// mutations
|
||||
export const mutations = {
|
||||
set (state, items) {
|
||||
state.content = items
|
||||
},
|
||||
addOrUpdate (state, item) {
|
||||
state.content = state.content.filter((val) => val.id !== item.id)
|
||||
state.content.push(item)
|
||||
},
|
||||
remove (state, item) {
|
||||
state.content = state.content.filter((val) => val.id !== item.id)
|
||||
}
|
||||
}
|
||||
|
||||
// actions
|
||||
export const actions = {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user