您的位置 >>> 星想互联 >>> 编程技术 >>> PHP高级编程
laravel框架中控制器入门
点击数:90  发布时间2018-10-25 22:44:12


namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\model\news;
use DB;


class index extends Controller
{
    //
    public function index(){
        $rs=DB::table('news')->get();
        foreach($rs as $v){
            echo $v->id."<a href='".url('newsview',['id'=>$v->id])."'>".$v->title."</a>[".$v->hit."]<br>";
        }
    }

    public function newsview($id){
        $rs=DB::table('news')->where('id',$id)->first();
        echo $rs->title."<br>";
        echo $rs->fdate."<br>";
        echo $rs->content."<br>";

    }
}

来源:咸宁网站建设