<?php
namespace AppHttpControllers;
use IlluminateSupportFacadesDB;
use AppHttpControllersController;
class hoge extends Controller
{
/**
* WordPress一覧を表示
*
* @return Response
*/
public function index(){
$wpdata = DB::select('select post_title,guid from wp_posts where post_type ='post' AND post_status = 'publish'');
return view("welcome",["wpdata"=>$wpdata]);
}
}
ビュー
<?php
Route::get('/',"hoge@index");
テンプレート
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>テスト</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="row">
@foreach ($wpdata as $key => $val)
<div class="col">{{$key}}::<a href="{{$val->guid}}">{{$val->post_title}}</a></div>
@endforeach
</div>
</div>
</body>
</html>