doukeyong3746487 2019-01-07 09:19
浏览 22

crudbooster,在admincontroller before_add函数中使用我的查询插入数据

I just made a module and menu about user data. In the controller, i made a laravel query to insert into my database table inside hook_before_add function. The problem is, after I hit the save button, the controller insert 2 records. Is it possible to use only my query to insert? Because All I need to do is to use my own laravel query to insert into my table because I need encrypt the password field with my custom encryption function(my company's standard password encryption) there. Can anyone help me, please?

 public function hook_before_add(&$postdata) {        
        //Your code here

        $password = Request::get('password');

        DB::table('user_personal')->insert([
            'email'=> Request::get('email'),
            'password'=> '',//$this->myencryptionfunction($password),
            'fullname'=> Request::get('fullname'),
            'phone'=> Request::get('phone'),
            'company'=> Request::get('company'),
            'status'=> Request::get('status'),
            'created_at'=> now()
        ]);

        //return Route::get('/admin/users');
        return Route::redirect('/admin/users', true);

    }
  • 写回答

1条回答 默认 最新

  • dpjjmo3079 2019-01-07 09:34
    关注

    why you don't use:

    public function hook_before_add(&$postdata) {        
    
        $password = Request::get('password');
    
        DB::table('user_personal')->insert([
            'email'=> Request::get('email'),
            'password'=> $this->myencryptionfunction($password);
            'fullname'=> Request::get('fullname'),
            'phone'=> Request::get('phone'),
            'company'=> Request::get('company'),
            'status'=> Request::get('status'),
            'created_at'=> now()
        ]);
    
        //return Route::get('/admin/users');
        return Route::redirect('/admin/users', true);
    
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序