Esempio n. 1
0
 /**
  * Remove the news.
  *
  * @param Request $request
  * @param Model   $news
  *
  * @return json
  */
 public function destroy(NewsUserApiRequest $request, News $news)
 {
     try {
         $t = $news->delete();
         return response()->json(['message' => trans('messages.success.delete', ['Module' => trans('news::news.name')]), 'code' => 2006])->setStatusCode(202, 'DESTROY_SUCCESS');
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 4006])->setStatusCode(400, 'DESTROY_ERROR');
     }
 }
Esempio n. 2
0
 public function transform(\Litecms\News\Models\News $news)
 {
     return ['id' => $news->getRouteKey(), 'title' => $news->title, 'description' => $news->description, 'image' => $news->image, 'images' => $news->images, 'published_on' => $news->published_on, 'status' => $news->status, 'published' => $news->published];
 }
Esempio n. 3
0
 public function transform(\Litecms\News\Models\News $news)
 {
     return ['id' => $news->getRouteKey(), 'title' => ucfirst($news->title), 'description' => ucfirst($news->description), 'image' => $news->image, 'images' => $news->images, 'published_on' => format_date($news->published_on), 'status' => $news->status, 'published' => $news->published == 'Yes' ? 'Published' : '-'];
 }
Esempio n. 4
0
 /**
  * Remove the news.
  *
  * @param Model   $news
  *
  * @return Response
  */
 public function destroy(NewsAdminRequest $request, News $news)
 {
     try {
         $t = $news->delete();
         return response()->json(['message' => trans('messages.success.deleted', ['Module' => trans('news::news.name')]), 'code' => 202, 'redirect' => trans_url('/admin/news/news/0')], 202);
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/news/news/' . $news->getRouteKey())], 400);
     }
 }
Esempio n. 5
0
 /**
  * Remove the specified resource.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy(NewsUserRequest $request, News $news)
 {
     try {
         $this->repository->delete($news->getRouteKey());
         return response()->json(['message' => trans('messages.success.deleted', ['Module' => trans('news::news.name')]), 'code' => 202, 'redirect' => trans_url('/user/news/news')], 202);
     } catch (Exception $e) {
         redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400);
     }
 }