Laravel eager loading Postgres - laravel

I'm using postgres DB and I don't know how to eager loading a model with Laravel, maybe is not supported with postgres??
SQLSTATE[42883]: Undefined function: 7 ERROR: X does not exist
$company->operators
Illuminate\Database\QueryException: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: character varying = integer
LINE 1: ...elect * from "operator" where "operator"."companyid" in (76)
Laravel uses Where IN

Related

changing CRS in GeoPandas

I'm trying to change the CRS of a geopandas dataframe. The current CRS is:
Name: unknown
Axis Info [ellipsoidal]:
- lon[east]: Longitude (degree)
- lat[north]: Latitude (degree)
Area of Use:
- undefined
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
When I try dfTrans.to_crs('epsg:4326') I get the following error:
pyproj.exceptions.CRSError: Invalid projection: epsg:4326: (Internal Proj Error: proj_create: cannot build geodeticCRS 4326: SQLite error on SELECT name, ellipsoid_auth_name, ellipsoid_code, prime_meridian_auth_name, prime_meridian_code, area_of_use_auth_name, area_of_use_code, publication_date, deprecated FROM geodetic_datum WHERE auth_name = ? AND code = ?: no such column: publication_date)
For a simple command in pyproj, pyproj.CRS.from_epsg(4326), I get the same error:
File "pyproj/_crs.pyx", line 1738, in pyproj._crs._CRS.__init__
pyproj.exceptions.CRSError: Invalid projection: epsg:4326: (Internal Proj Error: proj_create: cannot build geodeticCRS 4326: SQLite error on SELECT name, ellipsoid_auth_name, ellipsoid_code, prime_meridian_auth_name, prime_meridian_code, area_of_use_auth_name, area_of_use_code, publication_date, deprecated FROM geodetic_datum WHERE auth_name = ? AND code = ?: no such column: publication_date)
I don't know enough to know what's going on, but it seems like there's an underlying function that calls a column that doesn't exist. Any ideas how to fix this or work around it?
I got that same error when using Proj-5.x. It seems that the 'publication_date' column is a Proj-6 or Proj-7 item (which both require SQLite.)

Laravel postgresql join error. "Operator does not exist"

My laravel query code
$query = \DB::table('sample_point_mission')
->rightJoin('sample_point_record', 'sample_point_mission._id', '=','sample_point_record._pid')
->leftJoin('animal_name', 'sample_point_record.animal_name_id', '=','animal_name.tid::VARCHAR)')
->leftJoin('geographic_unit', 'sample_point_record.geography_unit_id', '=','geographic_unit.tid::VARCHAR');
$query->get();
error message ==>
SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: character varying = integer
So I try to add the character it needs
$query = \DB::table('sample_point_mission')
->rightJoin('sample_point_record', 'sample_point_mission._id', '=','sample_point_record._pid')
->leftJoin('animal_name', 'sample_point_record.animal_name_id', '=','animal_name.tid::VARCHAR')
->leftJoin('geographic_unit', 'sample_point_record.geography_unit_id', '=','geographic_unit.tid::VARCHAR');
$query->get();
error message :
SQLSTATE[42703]: Undefined column: 7 ERROR: column animal_name.tid::VARCHAR does not exist
I don't think you can use raw Postgres SQL inside the a regular Laravel join function. But, you can (and probably have to) use raw SQL with DB::raw. Try this version:
$query = \DB::table('sample_point_mission')
->rightJoin('sample_point_record', 'sample_point_mission._id', '=','sample_point_record._pid')
->leftJoin('animal_name a', function($join) {
$join->on(DB::raw("a.tid::VARCHAR"), DB::raw("="), DB::raw("sample_point_record.animal_name_i")) })
->leftJoin('geographic_unit g', function($join) {
$join->on(DB::raw("g.tid::VARCHAR"), DB::raw("="), DB::raw("sample_point_record.geography_unit_id")) })
$query->get();

Uncaught SyntaxError: Unexpected identifier at eval anonymous

I create a test project in MVC with kendo grid with popup edit. In
this scenario I have 3 relational tables. but when I add the third
table, I getting this Error:
> VM1362:1 Uncaught SyntaxError: Unexpected identifier
> at eval (<anonymous>)
at (https://kendo.cdn.telerik.com/2017.3.1018/js/jquery.min.js:2:2651)
at `Function.globalEval` (https://kendo.cdn.telerik.com/2017.3.1018/js/jquery.min.js:2:2662)
at Ha (https://kendo.cdn.telerik.com/2017.3.1018/js/jquery.min.js:3:21262)
at `n.fn.init.append` (https://kendo.cdn.telerik.com/2017.3.1018/js/jquery.min.js:3:22791)
at `I.fn.init.n.fn.(anonymous function) [as appendTo]` (https://kendo.cdn.telerik.com/2017.3.1018/js/jquery.min.js:3:24510)
at `init._createPopupEditor` (https://kendo.cdn.telerik.com/2017.3.1018/js/kendo.all.min.js:52:4953)
at `init.editRow` (https://kendo.cdn.telerik.com/2017.3.1018/js/kendo.all.min.js:52:2129)
at `HTMLAnchorElement.<anonymous>`
if I comment bellow line, project run correctly:
#{Html.RenderAction("AgreementExpertsIndex", new { xAgreementID = Model.xID });}
Can anyone say what is the problem?
The source code is here:
source file
thanks
Try a lowercase M in Model:
#{Html.RenderAction("AgreementExpertsIndex", new { xAgreementID = model.xID });}

Call to undefined function Illuminate\Support\random_bytes()

I receive this error message:
FatalErrorException in Str.php line 243: Call to undefined function Illuminate\Support\random_bytes()
public static function randomBytes($length = 16) {
return random_bytes($length);
}
line 243: return random_bytes($length);
I do not understand what's wrong since a working version Laravel offline that extract online.
It does not work online though. I wonder why?
random_bytes is a PHP 7 function.
I'm assuming that your offline/development stack has PHP 7 installed but not online/production.
Confirm your hosting for PHP 7 installed.

Magento Import - Fatal error: Call to a member function prepareAttributesForSave() on a non-object in Product.php

When attempting to import a csv product file into magento it keeps staying at "please wait". After using firebug I found I was getting this error:
Fatal error: Call to a member function prepareAttributesForSave() on a non-object in /magento/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php on line 1259
Here's line 1259 in product.php:
$rowData = $this->_productTypeModels[$productType]->prepareAttributesForSave($rowData);
$product = Mage::getModel('importexport/import_proxy_product', $rowData);
I am a complete newbie to PHP and am not sure how to fix this. I tried searching google, but didn't find anything related to this specific function.

Resources