Esempio n. 1
0
 /**
  * Return the field values from the model
  *
  * @param integer $id
  * @param array $fields
  * @return array
  */
 protected function fieldsFromModel($id, array $fields)
 {
     $post = Post::findOrFail($id);
     $fieldNames = array_keys(array_except($fields, ['tags']));
     $fields = ['id' => $id];
     foreach ($fieldNames as $field) {
         $fields[$field] = $post->{$field};
     }
     $fields['tags'] = $post->tags()->lists('tag')->all();
     return $fields;
 }
Esempio n. 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $post = Post::findOrFail($id);
     $post->tags()->detach();
     $post->delete();
     return redirect()->route('admin.post.index')->withSuccess('Post deleted.');
 }