vendredi 11 janvier 2019

How can i decode json data if i saved in array laravel?

I have 2 two table one is admission and other is class table and i am saving class id in admission class field of admission table by jsonencode method.

My controller
public function store(Request $request)
{
$admission = new Admission;
$admission->school_id = Auth::User()->id;
$admission->admission_classes=json_encode($inputs['admission_classes']);
$admission->save();   

}

My index function
 public function index(Request $request) {

 $school_id= Auth::user()->id;

 $admissions= Admission::where('school_id',$school_id)->orderBy('id','desc')->paginate(10);
          return view('frontend.index',compact('admissions','active_class'));
          
        }
        My view
        
       
  @foreach($admissions as $i => $admission)
  
  
  
  @endforeach
  
 I am getting data in this way:-
 
 ["1","2","4","5","6","7","8","9"]      
 
 But i want to get in this format:
 Nursery,Class 1, Class2, Class3 etc

        


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire