Esempio n. 1
0
 /**
  * Return the field values from the model.
  *
  * @param int   $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()->pluck('tag')->all();
     $fields['published_at'] = $post->published_at->format('d/m/Y H:i:s');
     return $fields;
 }
Esempio n. 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id)
 {
     /** @var Post $post */
     $post = Post::findOrFail($id);
     $post->tags()->detach();
     $post->delete();
     Session::set('_delete-post', trans('easel::messages.delete_success', ['entity' => 'Post']));
     return redirect()->route('admin.post.index');
 }