I want to fetch values from database and display it in the view, but I didn't get a correct result.
This is my controller:
class HrRequestController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$hr_request = HrRequest::all();
return array(
'status' => 'success',
'pages' => $hr_request->toArray());
}
}
and this is my Model:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class HrRequest extends Model
{
/**
* The table associated with the 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 to do this in view. Can anyone help me?