| 12345678910111213141516171819202122232425262728293031323334353637383940414243 | <?phpnamespace app\api\controller;use app\common\controller\Api;use app\common\model\Feedback;use app\api\validate\Feedback as FeedbackValidate;/** * 首页接口 */class Index extends Api{    protected $noNeedLogin = ['index'];    protected $noNeedRight = ['*'];    /**     * 首页     *     */    public function index()    {        $this->success(__('User Center'));    }    public function feedback()    {        $user = $this->auth->getUser();        $params = $this->request->only(['type', 'content', 'images', 'phone']);        // 使用验证器        $validate = new FeedbackValidate();        if (!$validate->check($params)) {            $this->error($validate->getError());        }                if ($user) {            $params['user_id'] = $user->id;        }        $result = Feedback::create($params);        if ($result) {            $this->success('感谢您的反馈');        }    }}
 |