public function index(Request $request) { $language = $request->header('Accept-Language', 'en'); $news = News::orderBy('created_at', 'desc')->get()->map(function($newss) use ($language) { $newss->title = $language === 'mr' && $newss->title_marathi ? $newss->title_marathi : $newss->title; $newss->description = $language === 'mr' && $newss->description_marathi ? $newss->description_marathi : $newss->description; return [ 'id' => $newss->id, 'type' => $newss->type, 'title' => $newss->title, 'description' => $newss->description, 'image' => url('storage/' . $newss->image), 'title_marathi' => $newss->title_marathi, 'description_marathi' => $newss->description_marathi, 'share_url' => $newss->share_url, 'link' => $newss->link, 'is_favourite' => (int)$newss->is_favourite ]; }); return response()->json([ 'status' => 'success', 'data' => $news, ], 200); }