mgsmus hocam kodlar şu şekildeydi
generalController
public function getIndex(Request $request)
{
$language = $this->currentLanguage($request->header('language'));
$count = $request->header('count');
$category_general_key = $request->header('category_general_key');
$topStories = $this->generalRepository->getIndexTopStories($language,$count);
$video = $this->generalRepository->getIndexVideo($language,$count);
$recentPost = $this->generalRepository->getIndexRecentPost($language,$count);
$podcast = $this->generalRepository->getIndexPodcast($language,$count);
$categoryPost = $this->generalRepository->getIndexCategoryPost($language,$count,$category_general_key);
$settings = $this->generalRepository->getIndexSettings($language,$count);
return [
'topStories' => GeneralResource::collection($topStories),
'video' => GeneralResource::collection($video),
'recentPost' => GeneralResource::collection($recentPost),
'podcast' => GeneralResource::collection($podcast),
'categoryPost' => GeneralResource::collection($categoryPost),
'settingsPost' => GeneralResource::collection($settingsPost),
];
}
GeneralRepository
public function getIndexTopStories($lang,$count)
{
try {
$topStories = DB::table('posts')
->where([['posts.lang_id',$lang],['posts.status','1'],['posts.publish_date','<',Carbon::now()]])
->select('posts.*','categories.title as category_name')
->leftJoin('categories', 'categories.id', '=', 'posts.category_id')
->orderBy('view','DESC')->limit($count)->get();
return $topStories;
} catch (\Exception $e) {
return response()->json([
'status' => 'error',
'message' => $e->getMessage()
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function getIndexVideo($lang,$count)
{
try {
$video = DB::table('posts')
->where([['posts.lang_id',$lang],['posts.status','1'],['posts.post_type',1]])
->select('posts.*','categories.title as category_name')
->leftJoin('categories', 'categories.id', '=', 'posts.category_id')
->orderBy('id','DESC')->limit($count)->get();
return $video;
} catch (\Exception $e) {
return response()->json([
'status' => 'error',
'message' => $e->getMessage()
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function getIndexRecentPost($lang,$count)
{
try {
$recentPost = DB::table('posts')
->where([['posts.lang_id',$lang],['posts.status','1'],['posts.publish_date','<',Carbon::now()],['posts.post_type','0']])
->select('posts.*','categories.title as category_name')
->leftJoin('categories', 'categories.id', '=', 'posts.category_id')
->orderBy('publish_date', 'DESC')->limit($count)->get();
return $recentPost;
} catch (\Exception $e) {
return response()->json([
'status' => 'error',
'message' => $e->getMessage()
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function getIndexCategoryPost($lang,$count,$category_general_key)
{
try {
$categoryPost = DB::table('posts')
->where([['posts.lang_id',$lang],['posts.status','1'],['posts.publish_date','<',Carbon::now()],['posts.category_general_key',$category_general_key]])
->select('posts.*','categories.title as category_name')
->leftJoin('categories', 'categories.id', '=', 'posts.category_id')
->where('categories.lang_id',$lang)
->orderBy('publish_date', 'DESC')->limit($count)->get();
return $categoryPost;
} catch (\Exception $e) {
return response()->json([
'status' => 'error',
'message' => $e->getMessage()
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function getIndexPodcast($lang,$count)
{
try {
$podcast = DB::table('posts')
->where([['posts.lang_id',$lang],['posts.status','1'],['posts.publish_date','<',Carbon::now()],['posts.post_type','2']])
->select('posts.*','categories.title as category_name')
->leftJoin('categories', 'categories.id', '=', 'posts.category_id')
->orderBy('publish_date', 'DESC')->limit($count)->get();
return $podcast;
} catch (\Exception $e) {
return response()->json([
'status' => 'error',
'message' => $e->getMessage()
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function getSetting($lang)
{
try {
$setting = DB::table('settings')->where('lang_id',$lang)->first();
return $setting;
} catch (\Exception $e) {
return response()->json([
'status' => 'error',
'message' => $e->getMessage()
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function getLanguages()
{
return DB::table("languages")->get();
}
public function getPrivacy()
{
return DB::table('privacy')->where('id', '1')->get();
}
https://prnt.sc/pDqOQp0ov-lf
https://prnt.sc/yDE8bOUxc5Iw
https://prnt.sc/IO1yXRsxLgjt
https://prnt.sc/OyuS6gmHelXd
https://prnt.sc/qkTR-6toCZtt
get-indexte previewde u kadar şey var hepsi anasayfaya geliyor