//控制器上面的代码
<?php
namespace app\index\controller;
use think\Controller;
use app\index\model\cate;
class Modeltest extends Controller
{
public function gain()
{
$res= cate::all(function($suiyi){
$suiyi->where('id','=',30);
});
dump($res);
echo $res->cant_find;
}
}
//模型上的代码
<?php
namespace app\index\model;
use think\Model;
use think\model\concern\SoftDelete;
class Cate extends Model
{
protected function getCantFindAttr($value,$data)
{
return $data['catename'].'这个是虚拟的';
}
}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
请将代码放在代码块中,并格式化发布
请把出错信息一并附上,这样才能帮你分析解答