app/Http/Controllers/ReviewController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $getVitals ="";
        $registration = Registration::with('patient')
            ->where('vitals',1)
            ->where('review',0)
            ->where('type','Review')
            ->whereDate('created_at', Carbon::today())
            ->limit(1)
            ->get();
        $last_visit =[];
        if (count($registration) != 0){
            $getVitals = Vital::where('patient_id',$registration[0]->patient_id)
                ->whereDate('created_at', Carbon::today())->get();
            $last_visit = Registration::with('consultation','medications.drugs','diagnosis.diagnoses')
                ->where('patient_id',$registration[0]->patient_id)
                ->get();
        }
        $diagnosis = Diagnose::all();
        $drugs = Drug::where('qty_in_stock','>',0)
            ->where('retail_price','>',0)->get();
        $charges = Charge::all();
        return view('pages.reviews.review')
            ->with('registration',$registration)
            ->with('getVitals',$getVitals)
            ->with('diagnosis',$diagnosis)
            ->with('drugs',$drugs)
            ->with('charges',$charges)
            ->with('last_visit',$last_visit);
    }
public function index ( ) { $ getVitals = " " ; $ registration = Registration :: with ( 'patient' ) -> where ( 'vitals' , 1 ) -> where ( 'review' , 0 ) -> where ( 'type' , 'Review' ) -> whereDate ( 'created_at' , Carbon :: today ( ) ) -> limit ( 1 ) -> get ( ) ; $ last_visit = [ ] ; if ( count ( $ registration ) != 0 ) { $ getVitals = Vital :: where ( 'patient_id' , $ registration [ 0 ] -> patient_id ) -> whereDate ( 'created_at' , Carbon :: today ( ) ) -> get ( ) ; $ last_visit = Registration :: with ( 'consultation' , 'medications.drugs' , 'diagnosis.diagnoses' ) -> where ( 'patient_id' , $ registration [ 0 ] -> patient_id ) -> get ( ) ; } $ diagnosis = Diagnose :: all ( ) ; $ drugs = Drug :: where ( 'qty_in_stock' , '>' , 0 ) -> where ( 'retail_price' , '>' , 0 ) -> get ( ) ; $ charges = Charge :: all ( ) ; return view ( 'pages.reviews.review' ) -> with ( 'registration' , $ registration ) -> with ( 'getVitals' , $ getVitals ) -> with ( 'diagnosis' , $ diagnosis ) -> with ( 'drugs' , $ drugs ) -> with ( 'charges' , $ charges ) -> with ( 'last_visit' , $ last_visit ) ; }
Display a listing of the resource.
Display a listing of the resource .
//            ->orderBy('created_at','asc') //        return  $last_visit;