如何在 Laravel 中的方法 crudbooster 中添加连接查询
How to add join query in method crudbooster in Laravel
我有方法 code :
public function getAddProfil($id)
{
//Create an Auth
if (!CRUDBooster::isCreate() && $this->global_privilege==FALSE || $this->button_add==FALSE) {
CRUDBooster::redirect(CRUDBooster::adminPath(),trans("crudbooster.denied_access"));
}
$data = [];
$data['page_title'] = 'Add Data Profil';
$data['result'] = DB::table('cms_users')->orderby('id','desc')->where('id','=',$id)->get();
//Please use cbView method instead view method from laravel
$this->cbView('profil_add',$data);
}
任何建议如何添加加入:
$data['result'] = DB::table('cms_users')->orderby('id','desc')->where('id','=',$id)->get();
我试过添加 join :
$data['result'] = DB::table('cms_users')->join('profil')->orderby('id','desc')->where('id','=',$id)->get();
然后我在 crudbooster 中得到 错误。
尝试这样做:
$data['result'] = DB::table('cms_users')->join('profil', 'cms_users.profil_id', '=', 'profil.id')->orderby('cms_users.id','desc')->where('cms_users.id', $id)->get();
希望对您有所帮助。
在 Laravel 查询生成器中 ->Join() 需要 4 个参数,请参见下面的示例:
$users = DB::table('users')
->join('contacts', 'users.id', '=', 'contacts.user_id')
->join('orders', 'users.id', '=', 'orders.user_id')
->select('users.*', 'contacts.phone', 'orders.price')
->get();
希望对您有所帮助,
我找到了答案,并使用了这个源代码,它起作用了:
$data['result'] = DB::table('cms_users')
->join('profil', 'cms_users.profil_id', '=', 'profil.id')
->join('jabatan', 'profil.jabatan_id', '=', 'jabatan.id')
->join('ruang', 'profil.ruang_id', '=', 'ruang.id')
->join('pangkat', 'profil.pangkat_id', '=', 'pangkat.id')
->orderby('cms_users.id','desc')
->where('cms_users.id', $id)
->get();
谢谢大家
我有方法 code :
public function getAddProfil($id)
{
//Create an Auth
if (!CRUDBooster::isCreate() && $this->global_privilege==FALSE || $this->button_add==FALSE) {
CRUDBooster::redirect(CRUDBooster::adminPath(),trans("crudbooster.denied_access"));
}
$data = [];
$data['page_title'] = 'Add Data Profil';
$data['result'] = DB::table('cms_users')->orderby('id','desc')->where('id','=',$id)->get();
//Please use cbView method instead view method from laravel
$this->cbView('profil_add',$data);
}
任何建议如何添加加入:
$data['result'] = DB::table('cms_users')->orderby('id','desc')->where('id','=',$id)->get();
我试过添加 join :
$data['result'] = DB::table('cms_users')->join('profil')->orderby('id','desc')->where('id','=',$id)->get();
然后我在 crudbooster 中得到 错误。
尝试这样做:
$data['result'] = DB::table('cms_users')->join('profil', 'cms_users.profil_id', '=', 'profil.id')->orderby('cms_users.id','desc')->where('cms_users.id', $id)->get();
希望对您有所帮助。
在 Laravel 查询生成器中 ->Join() 需要 4 个参数,请参见下面的示例:
$users = DB::table('users')
->join('contacts', 'users.id', '=', 'contacts.user_id')
->join('orders', 'users.id', '=', 'orders.user_id')
->select('users.*', 'contacts.phone', 'orders.price')
->get();
希望对您有所帮助,
我找到了答案,并使用了这个源代码,它起作用了:
$data['result'] = DB::table('cms_users')
->join('profil', 'cms_users.profil_id', '=', 'profil.id')
->join('jabatan', 'profil.jabatan_id', '=', 'jabatan.id')
->join('ruang', 'profil.ruang_id', '=', 'ruang.id')
->join('pangkat', 'profil.pangkat_id', '=', 'pangkat.id')
->orderby('cms_users.id','desc')
->where('cms_users.id', $id)
->get();
谢谢大家