@s4muel Thanks for Your reply.
I got solution using Cache mechanism to filter the second Array elements
for that I include
use Illuminate\Support\Facades\Cache;
in LoginController and my function is as below
public function dashboard(Request $request)
{
$user = $request->email;
if (!Cache::has('user_' . $user)) {
Cache::put('user_' . $user, true, 10);
$keySecret = '6Ld63_wft2s5';
$check = array(
'secret' => $keySecret,
'response' => $_POST['g-recaptcha-response']
);
$startProcess = curl_init();
curl_setopt($startProcess, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
curl_setopt($startProcess, CURLOPT_POST, true);
curl_setopt($startProcess, CURLOPT_POSTFIELDS, http_build_query($check));
curl_setopt($startProcess, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($startProcess, CURLOPT_RETURNTRANSFER, true);
$receiveData = curl_exec($startProcess);
$finalResponse = json_decode($receiveData, true);
if($finalResponse['success'])
{
$input = $request->all();
$email = $request->email;
$password = base64_encode($request->password);
$adminData = AdminUserModel::where('email', $email)->where('password',MD5(base64_decode($password)))->where('status','1')->where('role','=','admin')->get()->count();
$operator = AdminUserModel::where('email', $email)->where('password',MD5(base64_decode($password)))->where('status','1')->where('role','=','operator')->get()->count();
if($adminData > 0 || $operator > 0)
{
$email = AdminUserModel::where('email', $email)->value('email');
$role = AdminUserModel::where('email', $email)->value('role');
$loginId = AdminUserModel::where('email', $email)->value('id');
Session::put('email', $email);
Session::put('role', $role);
Session::put('login_id', $loginId);
Session::put('isAdminLoggedIn', 1);
$totalapp = ApplicationModel::where('active','1')->count();
$notificationYear = NotificationsModel::select('notification_year')
->where('notification_status','1')
->orderBy('notification_year','desc')->groupBy('notification_year')->get()->toArray();
foreach($notificationYear as $key => $year)
{
$notifiData = NotificationsModel::where('notification_year',$year['notification_year'])->where('notification_status','1')->orderBy('created_at','desc')->get()->toArray();
$notificationYear[$key]['notfn'] = $notifiData;
foreach($notificationYear[$key]['notfn'] as $k => $nsp)
{
$p = DB::table('ksrtc_post')->select('post_name','id')
->whereIn('id', json_decode($nsp['notification_post_id']))
->get()->toArray();
foreach($p as $pn)
{
$post_count = ApplicationModel::where('notification_id',$nsp['id'])->where('active','1')->where('post_id',$pn->id)->orderBy('created_at','desc')->get()->count();
$pn->appln_count = $post_count;
}
$notificationYear[$key]['notfn'][$k]['posts'] = $p;
}
}
$currentYear = date("Y");
return view('admin/Dashboard',['current_year' => $currentYear, 'total_app_count' => $totalapp, 'notifications' => $notificationYear, 'role' => $role, 'refresh' => true]);
}
}
else
{
return redirect()->back()->with(['failed' => 'Login Failed.']);
}
}
header("Refresh: 0"); // To Refresh the page
}
My Special thanks goes to Nandini .
Thanks
Anes P A