質問編集履歴

1

補足事項の追加

2017/06/27 06:37

投稿

supermaruetsu
supermaruetsu

スコア148

test CHANGED
File without changes
test CHANGED
@@ -85,3 +85,61 @@
85
85
  この2番を行うために必要なCodeがわかりません。
86
86
 
87
87
  初歩的な質問かもしれませんが、どうぞよろしくお願いいたします。
88
+
89
+
90
+
91
+ ※補足になります。
92
+
93
+ 単体であれば、おそらくですが下記のようなCodeでいけるはずです。
94
+
95
+ ```php
96
+
97
+ <?php
98
+
99
+
100
+
101
+ namespace App\Services;
102
+
103
+
104
+
105
+ use App\Models\Article;
106
+
107
+
108
+
109
+ class ArticleService
110
+
111
+ {
112
+
113
+ /**
114
+
115
+ * @param array $data
116
+
117
+ * @return Article
118
+
119
+ */
120
+
121
+ public function store(array $data)
122
+
123
+ {
124
+
125
+ $article = new Article;
126
+
127
+ $article->title = $data['title'];
128
+
129
+ $article->url = $data['url'];
130
+
131
+ $article->img_path = $data['img'];
132
+
133
+ $article->save();
134
+
135
+
136
+
137
+ return $article;
138
+
139
+ }
140
+
141
+
142
+
143
+ }
144
+
145
+ ```