fetch data from database and display the values in database in laravel -
i want fetch values database , display in view, didn't correct result.
this controller:
class hrrequestcontroller extends controller { /** * create new controller instance. * * @return void */ public function __construct() { $this->middleware('auth'); } /** * display listing of resource. * * @return \illuminate\http\response */ public function index() { $hr_request = hrrequest::all(); return array( 'status' => 'success', 'pages' => $hr_request->toarray()); } }
and model:
<?php namespace app; use illuminate\database\eloquent\model; class hrrequest extends model { /** * table associated model. * * @var string */ protected $table = 'hr_request'; public $timestamps = false; /** * fields. * * @var array */ protected $fillable = [ 'profile_role_id', 'hr_id', 'vacancy', 'experience', 'job_description', 'status', 'viewed', ]; } view name:view-requests.blade.php
i have no idea n how in view. can me?
thanks in advance.
controller:
public function index() { $hr_request = hrrequest::all(); return view('view-requests')->with('hr_request', $hr_request); }
view:
@foreach($hr_request $row) <tr> <td>{{$row->profile_role_id}}</td> <td>{{$row->vacancy}}</td> <td>{{$row->experience}}</td> <td>{{$row->job_description}}</td> <td> <button type="button" class="btn btn-primary">view</button> <button type="button" class="btn btn-success">edit</button> <button type="button" class="btn btn-danger">delete</button> </td> </tr> @endforeach
route: route::get('/view-hr-requests', 'hrrequestcontroller@index');
it's working..
Comments
Post a Comment