eloquent

Integrity constraint violation: 1052 Column and in where clause is ambiguous

时光怂恿深爱的人放手 提交于 2019-12-25 15:06:50
问题 I have two table the Tbl_payroll_leave_employeev2 and tbl_payroll_leave_schedulev2 and i want to join them but im getting an error like this SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'payroll_leave_employee_id' in where clause is ambiguous (SQL: select payroll_employee_id from tbl_payroll_leave_employee_v2 inner join tbl_payroll_leave_schedulev2 on tbl_payroll_leave_employee_v2 . payroll_leave_employee_id = tbl_payroll_leave_schedulev2 . payroll_leave_employee_id where

Integrity constraint violation: 1052 Column and in where clause is ambiguous

帅比萌擦擦* 提交于 2019-12-25 15:05:11
问题 I have two table the Tbl_payroll_leave_employeev2 and tbl_payroll_leave_schedulev2 and i want to join them but im getting an error like this SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'payroll_leave_employee_id' in where clause is ambiguous (SQL: select payroll_employee_id from tbl_payroll_leave_employee_v2 inner join tbl_payroll_leave_schedulev2 on tbl_payroll_leave_employee_v2 . payroll_leave_employee_id = tbl_payroll_leave_schedulev2 . payroll_leave_employee_id where

Laravel 5 - update overwriting all data

落花浮王杯 提交于 2019-12-25 11:54:09
问题 I have a Document Model which represents a Document (name, description etc). I then have a DocumentData Model which represents the data of a Document. A Document has One to Many DocumentData, So to create a Document I have a form. Lets say that my form has a text input for Document Owner. Within my DocumentData table, the label documentOwner is set as the key and the inputted data is set as the value. So with multiple form elements, my DocumentData table might look like this document_data id

Laravel 5.3 Eloquent Relationships

懵懂的女人 提交于 2019-12-25 08:50:15
问题 i'm using Laravel 5.3 and i'm trying to select from the database the values for the lang files, i created a file and named it global.php and inside the file i tried to do this: use App\Dictionary; $language_id = 1; $dictionary = array(); $lables = Dictionary::where('language_id',$language_id)->get(); foreach($lables as $label): $dictionary[$label->label] = $label->value; endforeach; return $dictionary; now, this is working but i want to select the rows using the short_name field and not the

Eloquent wherein with join multiple tables

依然范特西╮ 提交于 2019-12-25 08:48:03
问题 I have 4 tables, items, listings, catitem_item, and item_listing. items and listing is many to many relationship. items and catitems is also many to many relationship. catitems contains list of item's categories. listings is like location where items located. example listing shop A can have item chair and item chair have multiple catitem categories. My goal is to get items which under list of categories such as category 1 AND 2 AND 3 ( $cats ) and with listing information where this item

Custom Model and fields with Sentinel / Laravel

删除回忆录丶 提交于 2019-12-25 08:47:43
问题 I', integrating a new system to an existing database. So, my User table doesn't have default fields names. All names are in spanish, so, Sentinel looks for email when he should look for "correo" Also, when executing Sentinel::check(), I get this message error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'administrador.id' in 'where clause' (SQL: select * from `administrador` where `administrador`.`id` = 1 and `administrador`.`deleted_at` is null limit 1) In fact, id doesn't exists,

Laravel - Multiple foreign keys and getting id

拜拜、爱过 提交于 2019-12-25 08:27:17
问题 I tried a bunch of different things first but don't seem to be getting a result. Controller: public function all() { $projects = Project::all(); foreach($projects as $project) { $pid = $project->id; } $am = DB::table('projects') ->join('employees', 'projects.am_id', '=', 'employees.id') ->where('projects.id', '=', $pid) ->select('projects.id', 'projects.am_id', 'employees.name') ->first(); $pm = DB::table('projects') ->join('employees', 'projects.pm_id', '=', 'employees.id') ->where('projects

Get Past 7 Days Data From Model?

三世轮回 提交于 2019-12-25 08:17:17
问题 I am trying to query my model and return an object to feed to chart.js // Configure dates $today = Carbon::today(); Carbon::setTestNow($today->subWeek()); $sunday = new Carbon('this sunday'); $monday = new Carbon('this week'); $tuesday = new Carbon('this tuesday'); $wednesday = new Carbon('this wednesday'); $thursday = new Carbon('this thursday'); $friday = new Carbon('this friday'); $saturday = new Carbon('this saturday'); // Return object for charts.js return response()->json([ 'sunday' =>

Constraining eager loaded relationship

自作多情 提交于 2019-12-25 08:15:10
问题 I found a very bizarre behavior of with function for overloading relationships. I have Product and Deal relationships, such that Product belongsTo() Deal (through product_id in deals table). Now, when I try to get all products on sale: Product::with(['deal' => function($query) { $query->whereDate('ends_at', '>', Carbon::now()->toDateTimeString()); }])->get() this returns a collection of all products, even though there are no records in deals table and all products have deal_id set to NULL .

show related table columns in all select of model laravel

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 07:59:00
问题 I want show related table columns ( customers.name ) in all select of model (User) laravel. I use accessor laravel. user table: id name customer_id 1 hassan 1 customer table: id name 1 customer1 now use $user = Auth::user(); return $user; I want show: id: 1, name: "hassan", customer_id: { id: 1, name: "customer1" } but show this error: Failed calling App\User::jsonSerialize() class User extends Authenticatable { use EntrustUserTrait; /** * Get the user's customer name. * * @param string