?php
namespace App\Http\Controllers\Admin; //注意命名空间
use App\Http\Controllers\Controller;
use app\privilegeModel;
function index(){
$model=new \App\PrivilegeModel(); //实例化model
$data = $model -> getlist(); //调用model层中方法
}
Model层
?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use DB;
class privilegeModel extends Model
{
/**
* 查询友情链接
*/
public function getlist()
{
return DB::table('tablename')->get();
}
}