Retrieve all database records contributed by an individual
P粉716228245
P粉716228245 2023-09-08 16:10:51
0
1
589

How to get all the rows in the database table inserted by the logged in person? I will provide the code and snippet below

Controller.php file

public function index(){
    $data['user1'] = UserModel::where('seq_id','=',Session::get('loginId'))->first();

    return view ("enrollment-steps.step2", $data,
        [
            'data'=>$data['user1'],
         
        ]);
}

Blade.php file

<label><strong> Honors if any(Secondary level): </strong></label>
 <div class="col-sm-12 col-lg-4">
  <div class="form-group row">
   <label for="step2_honor" class="col-sm-3 text-right control-label col-form-label">Honors</label>
    <div class="col-sm-9">
     <input class="form-control" type="text" id='step2_honor' placeholder="Secondary"  value="{!! $user1?->honors !!}" >
     </div>
    </div>
   </div>

What other methods can I use to get all data inserted by the same person? The first() method will only get the last inserted row, the get() method will throw Property [honors] does not exit on this collection instance.. For example, in the snippet below app_id 2708 has 3 rows inserted, how do I get all the data in the database connected to that person?

P粉716228245
P粉716228245

reply all(1)
P粉914731066

Controller

public function index()
{
    $userData = UserModel::where('app_id', 2708)->get();
    return view('enrollment', compact('userData'));
}

blade

@foreach($userData as $data)
    {{$data->schoolname}}
@endforeach
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template