質問編集履歴
2
webpack.mix.jsの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -159,3 +159,25 @@
|
|
159
159
|
```
|
160
160
|
|
161
161
|
ここのコードの、ボタンの場所、ボタンの色を変更しました。
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
webpack.mix.js
|
168
|
+
|
169
|
+
```
|
170
|
+
|
171
|
+
const mix = require('laravel-mix');
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
mix.js('resources/js/app.js', 'public/js')
|
178
|
+
|
179
|
+
.sass('resources/sass/app.scss', 'public/css');
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
```
|
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,3 +25,137 @@
|
|
25
25
|
Mysql5.6
|
26
26
|
|
27
27
|
PHP 7.1
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
### フォロー機能のソースコード
|
32
|
+
|
33
|
+
```php
|
34
|
+
|
35
|
+
@if($post->user->id!=Auth::user()->id)
|
36
|
+
|
37
|
+
<follow
|
38
|
+
|
39
|
+
:follow-user="{{json_encode($post->user)}}"
|
40
|
+
|
41
|
+
:auth-user="{{json_encode($userAuth)}}"
|
42
|
+
|
43
|
+
:default-followed="{{json_encode($defaultFollowed)}}"
|
44
|
+
|
45
|
+
></follow>
|
46
|
+
|
47
|
+
@endif
|
48
|
+
|
49
|
+
```
|
50
|
+
|
51
|
+
```Vue
|
52
|
+
|
53
|
+
<template>
|
54
|
+
|
55
|
+
<span style="margin-left:-10px;">
|
56
|
+
|
57
|
+
<button v-if="!followed" type="button" class="btn btn-primary btn-sm " style="border-radius: 30px;" @click="postFollow()">フォローする</button>
|
58
|
+
|
59
|
+
<button v-else type="button" class="btn btn-primary btn-sm" style="border-radius: 30px;" @click="postUnFollow()">フォロー解除</button>
|
60
|
+
|
61
|
+
</span>
|
62
|
+
|
63
|
+
</template>
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
<script>
|
68
|
+
|
69
|
+
export default {
|
70
|
+
|
71
|
+
props: ['followUser', 'authUser', 'defaultFollowed'],
|
72
|
+
|
73
|
+
data() {
|
74
|
+
|
75
|
+
return {
|
76
|
+
|
77
|
+
followed: false
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
},
|
82
|
+
|
83
|
+
created() {
|
84
|
+
|
85
|
+
this.followed = this.defaultFollowed
|
86
|
+
|
87
|
+
},
|
88
|
+
|
89
|
+
methods: {
|
90
|
+
|
91
|
+
postFollow(){
|
92
|
+
|
93
|
+
let url = `/api/users/${this.followUser.id}/follow`
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
axios.post(url,{
|
98
|
+
|
99
|
+
authUser: this.authUser
|
100
|
+
|
101
|
+
})
|
102
|
+
|
103
|
+
.then(res => {
|
104
|
+
|
105
|
+
this.followed = true
|
106
|
+
|
107
|
+
})
|
108
|
+
|
109
|
+
.catch(err => {})
|
110
|
+
|
111
|
+
},
|
112
|
+
|
113
|
+
postUnFollow(){
|
114
|
+
|
115
|
+
let url = `/api/users/${this.followUser.id}/unfollow`
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
axios.post(url,{
|
120
|
+
|
121
|
+
authUser: this.authUser
|
122
|
+
|
123
|
+
})
|
124
|
+
|
125
|
+
.then(res => {
|
126
|
+
|
127
|
+
this.followed = false
|
128
|
+
|
129
|
+
})
|
130
|
+
|
131
|
+
.catch(err => {})
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
</script>
|
140
|
+
|
141
|
+
```
|
142
|
+
|
143
|
+
### 修正部分
|
144
|
+
|
145
|
+
```ここに言語を入力
|
146
|
+
|
147
|
+
<template>
|
148
|
+
|
149
|
+
<span style="margin-left:-10px;">
|
150
|
+
|
151
|
+
<button v-if="!followed" type="button" class="btn btn-primary btn-sm " style="border-radius: 30px;" @click="postFollow()">フォローする</button>
|
152
|
+
|
153
|
+
<button v-else type="button" class="btn btn-primary btn-sm" style="border-radius: 30px;" @click="postUnFollow()">フォロー解除</button>
|
154
|
+
|
155
|
+
</span>
|
156
|
+
|
157
|
+
</template>
|
158
|
+
|
159
|
+
```
|
160
|
+
|
161
|
+
ここのコードの、ボタンの場所、ボタンの色を変更しました。
|