lundi 8 avril 2019

How to fetch value from objects in laravel?

I m making an app in which I want to get value of an object and also I want to get id while creating new user.

I was using drop down menu, and want to get id which was selected in previous dropdown.

 @php

  use Illuminate\Support\Facades\DB;

                                 $uid=DB::table('users')->where('role_id','4')->get();
                                 $counter=0;

                                 $cid=DB::table('classses')->get();
                                 $counterr=0;

                                 $sec=DB::table('sections')->where('class_id',array('class_id' => $cid->id('class_id')))->get();
                             $counterrr=0;
                             @endphp

                             <select user="" name="parent_id">
                                 <option value="null">User</option>
                                 @foreach($uid as $user)
                                     @if($counter==0)
                                         <option selected="selected" value=""></option>
                                         
                                     @else

                                         <option value=""></option>
                                     @endif
                                 @endforeach
                             </select>
                             <div class="col-md-6">



                                 <select class="" name="class_id">
                                     <option value="null">Class</option>
                                     @foreach($cid as $cc)
                                         @if($counterr==0)
                                             <option selected="selected" value=""></option>
                                             
                                         @else

                                             <option value=""></option>
                                         @endif
                                     @endforeach
                                 </select>

                                 <select section="" name="section_id">
                                     <option value="null">Section</option>
                                     @foreach($sec as $sc)
                                         @if($counterrr==0)
                                             <option selected="selected" value=""></option>
                                             
                                         @else

                                             <option value=""></option>
                                         @endif
                                     @endforeach
                                 </select>

As now I want that the object shows the value of selected id in class-dropdown menu and I want to put it in selected list of section

$sec=DB::table('sections')->where('class_id',$cid)->get();

I' m having issues in writing syntax over here.('class_id',$cid)

Also I want that a id on which this new user is going to be created , how to get that?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire