Laravel Error: Call to a member function save() on null - laravel-5

I am using following code
$order = new Order();
$order->cart = serialize($cart);
$order->address = $request->input('address');
$order->name = $request->input('name');
$order->payment_id = $charge->id;
// echo '<pre>';
// var_dump($order->toArray());exit;
Auth::user()->orders()->save($order);
It gives me this error
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to a member function save() on null
If I dump the variable $order I get the data
array(4) {
["cart"]=>
string(6053) "O:8:"App\Cart":3:{s:5:"items";a:2:{i:4;a:3:{s:3:"qty";i:2;s:5:"price";i:40;s:4:"item";O:11:"App\Product":26:{s:13:"*connection";s:5:"mysql";s:8:"*table";N;s:13:"*primaryKey";s:2:"id";s:10:"*keyType";s:3:"int";s:12:"incrementing";b:1;s:7:"*with";a:0:{}s:12:"*withCount";a:0:{}s:10:"*perPage";i:15;s:6:"exists";b:1;s:18:"wasRecentlyCreated";b:0;s:13:"*attributes";a:9:{s:2:"id";i:4;s:4:"name";s:9:"Product 4";s:4:"slug";s:9:"product-4";s:5:"image";s:14:"1526885592.jpg";s:7:"details";s:26:"Sub Heading or Product - 4";s:11:"description";s:63:"This is description of product-1 and related stuff to product-1";s:5:"price";i:20;s:10:"created_at";s:19:"2018-05-16 06:26:26";s:10:"updated_at";s:19:"2018-05-21 06:55:15";}s:11:"*original";a:9:{s:2:"id";i:4;s:4:"name";s:9:"Product 4";s:4:"slug";s:9:"product-4";s:5:"image";s:14:"1526885592.jpg";s:7:"details";s:26:"Sub Heading or Product - 4";s:11:"description";s:63:"This is description of product-1 and related stuff to product-1";s:5:"price";i:20;s:10:"created_at";s:19:"2018-05-16 06:26:26";s:10:"updated_at";s:19:"2018-05-21 06:55:15";}s:10:"*changes";a:0:{}s:8:"*casts";a:0:{}s:8:"*dates";a:0:{}s:13:"*dateFormat";N;s:10:"*appends";a:0:{}s:19:"*dispatchesEvents";a:0:{}s:14:"*observables";a:0:{}s:12:"*relations";a:0:{}s:10:"*touches";a:0:{}s:10:"timestamps";b:1;s:9:"*hidden";a:0:{}s:10:"*visible";a:0:{}s:11:"*fillable";a:0:{}s:10:"*guarded";a:1:{i:0;s:1:"*";}}}i:9;a:3:{s:3:"qty";i:1;s:5:"price";i:1080;s:4:"item";O:11:"App\Product":26:{s:13:"*connection";s:5:"mysql";s:8:"*table";N;s:13:"*primaryKey";s:2:"id";s:10:"*keyType";s:3:"int";s:12:"incrementing";b:1;s:7:"*with";a:0:{}s:12:"*withCount";a:0:{}s:10:"*perPage";i:15;s:6:"exists";b:1;s:18:"wasRecentlyCreated";b:0;s:13:"*attributes";a:9:{s:2:"id";i:9;s:4:"name";s:17:"Samsung Galaxy S9";s:4:"slug";s:26:"samsung-galaxy-s9-plus-128";s:5:"image";s:14:"1526884218.jpg";s:7:"details";s:28:"Samsung Galaxy S9 Plus 128GB";s:11:"description";s:1594:"Samsung fans getting excited about Galaxy S9 but they don't know that Plus version is also coming to make it more excited for the lovers of this brand. S8 was the celebrity of the last year but the upcoming siblings are even better. Samsung Galaxy S9 Plus got aluminum frame on its side while the front and back is covered with solid and thick layer of Corning Gorilla Glass 5 to make it scratch proof and save Samsung's Galaxy S9 Plus from shattering. This device also got an IP68 certificate which means that this smartphone can stay underwater for almost 30 minutes. Samsung Galaxy S9's design is quite alike to this version but there is a difference between the display sizes of both devices. This phone is coming with massive 6.2 inch touchscreen. Galaxy S9 Plus by Samsung got the taste of Super AMOLED display which is exclusively made for the devices of this brand. Infinity screen is key selling point of these devices that's why Samsung S9 Plus is also coming with that kind of setup where the resolution will be 1440 x 2960 and pixel density reached the mark of 531. Always on display is also present on the board of Galaxy S9 Plus that will keep you updated about the notifications. Next generation Snapdragon 845 chipset got the approval to come in these devices while Oreo is decorating the interior of S9 Plus. Dual camera with 12 MP sensor is placed on the back side while for the front you will see the 8 MP selfie snapper in action. 6 GB of RAM is handling Samsung Galaxy's S9 Plus multi-tasking where internal storage of this device is 128 GB to handle all the storage needs.";s:5:"price";i:1080;s:10:"created_at";s:19:"2018-05-21 06:30:18";s:10:"updated_at";s:19:"2018-05-21 06:30:18";}s:11:"*original";a:9:{s:2:"id";i:9;s:4:"name";s:17:"Samsung Galaxy S9";s:4:"slug";s:26:"samsung-galaxy-s9-plus-128";s:5:"image";s:14:"1526884218.jpg";s:7:"details";s:28:"Samsung Galaxy S9 Plus 128GB";s:11:"description";s:1594:"Samsung fans getting excited about Galaxy S9 but they don't know that Plus version is also coming to make it more excited for the lovers of this brand. S8 was the celebrity of the last year but the upcoming siblings are even better. Samsung Galaxy S9 Plus got aluminum frame on its side while the front and back is covered with solid and thick layer of Corning Gorilla Glass 5 to make it scratch proof and save Samsung's Galaxy S9 Plus from shattering. This device also got an IP68 certificate which means that this smartphone can stay underwater for almost 30 minutes. Samsung Galaxy S9's design is quite alike to this version but there is a difference between the display sizes of both devices. This phone is coming with massive 6.2 inch touchscreen. Galaxy S9 Plus by Samsung got the taste of Super AMOLED display which is exclusively made for the devices of this brand. Infinity screen is key selling point of these devices that's why Samsung S9 Plus is also coming with that kind of setup where the resolution will be 1440 x 2960 and pixel density reached the mark of 531. Always on display is also present on the board of Galaxy S9 Plus that will keep you updated about the notifications. Next generation Snapdragon 845 chipset got the approval to come in these devices while Oreo is decorating the interior of S9 Plus. Dual camera with 12 MP sensor is placed on the back side while for the front you will see the 8 MP selfie snapper in action. 6 GB of RAM is handling Samsung Galaxy's S9 Plus multi-tasking where internal storage of this device is 128 GB to handle all the storage needs.";s:5:"price";i:1080;s:10:"created_at";s:19:"2018-05-21 06:30:18";s:10:"updated_at";s:19:"2018-05-21 06:30:18";}s:10:"*changes";a:0:{}s:8:"*casts";a:0:{}s:8:"*dates";a:0:{}s:13:"*dateFormat";N;s:10:"*appends";a:0:{}s:19:"*dispatchesEvents";a:0:{}s:14:"*observables";a:0:{}s:12:"*relations";a:0:{}s:10:"*touches";a:0:{}s:10:"timestamps";b:1;s:9:"*hidden";a:0:{}s:10:"*visible";a:0:{}s:11:"*fillable";a:0:{}s:10:"*guarded";a:1:{i:0;s:1:"*";}}}}s:8:"totalQty";i:3;s:10:"totalPrice";i:1120;}"
["address"]=>
string(10) "china town"
["name"]=>
string(13) "Mudassar Khan"
["payment_id"]=>
string(27) "ch_1CVZkmIqJSaYKfYMeHiZO6oi"
}
I have the relations setup in Users and Order models
What am I missing?

orders() method, which I think you use it to define relation, returns null.
So make sure it returns something like
public function orders(){
return $this->belongsTo('App\User');
}

Related

Vertical takeoff for a DJI Matrice 100

DJI Android SDK version: 4.11
Matrice 100 / Matrice 600
I am trying to take off the drone vertically.
I tried with GoToAction in a timeline, but that failed due to some bug in the SDK, (confirmed by your support team dev#dji.com #29496) I get STARTED for the GoToAction, but no PROGRESSED or FINISHED, and no errors logged at all.
Since I need to continue working, I tried a workaround by sending FlightControlData to the VirtualStick by calling the following function with the requested height 20 times a second:
VerticalControlMode.POSITION
FlightOrientationMode.AIRCRAFT_HEADING
VirtualStickModeEnabled = true
VirtualStickAdvancedModeEnabled = true
void sendHeightCommand(Float requestedAltitude) {
FlightControlData data = new FlightControlData(0f, 0f, 0f, requestedAltitude);
flightController.sendVirtualStickFlightControlData(data, djiError -> {
log.v(djiError.getDescription);
});
}
And it works (with the right amount of timeouts) but if there is wind, the drone drifts away, which is very dangerous for me as there is more than one drone in the field, and I don't want them to collide.
Is there another way to change the altitude of the drone, while maintaining its position?
Or is there a way to measure the wind, and push back against it?
[*] Take off drone vertically:
I always use the TakeOffAction in the timelineMission before the GoToAction to ascend to the desired height. However I'm using a Mavic Pro and the SDK may behave different with a matrice drone.
When using the FlightControlData with the VirtualSticks, I use the startPrecisionTakeoff() method in the FlightController class; after the takeoff, the drone ascends to the desired position when the flight control data is sent continuously.
[*] stable hovering:
For the hovering the only low cost solution I see is to enable the VisionAssistedPositioning in the FlightAssistant class, I don't know if the Matrice supports this feature as the documentation doesn't say anything on the supported aircrafts.
Ok so the solution was to use the function: setVirtualStickAdvancedModeEnabled(true)
The reason I didn't see any results was because in the simulator I was playing with 20.0 North Wind, which apparently is too much.
When I lowered it to 5.0 it works perfectly.

are there any options for using multiple webcams on windows?

i been trying to use via USB HUB "4 ports" 2 web cams and i get this msg on the notification bar telling me to disconnect one unused usb from the port because low driver resources, yet i only have one port on my windows surface pro2 and on that one usb i connected the usb hub and on that is where i plugged the 2 webcams to use in my pc, So whats up with that driver resource ? thats a first i see that
i also plan to run on this power usb hub 2 optical usb mouse so i will appreciate this information.
using Processing IDE i am specifying which cameras to use which i currently do with just one of these USB cams and the internal cam on my tablet and i get dual video feed from both cam using this lines of code
cam1 = new Capture(this, w, h, "USB2.0 Camera", fps);
cam2 = new Capture(this, w, h, "Microsoft LifeCam Front", fps);
cam1.start();
cam2.start();
and this works fine but when i specify
cam1 = new Capture(this, w, h, "USB2.0 Camera", fps);
cam2 = new Capture(this, w, h, "USB2.0 PC CAMERA", fps);
cam1.start();
cam2.start();
which im telling it those two cams are both USB use it the IDE find it just confirming it is there but only uses one and occasionally i get a driver resource pop up telling me to dissconect any usb im not using while i only have those 2 usb in the 4 usb power hub so im not sure what the issue is, further more if i use just one usb cam and a optical usb mouse and usb keyboard and a Arduino using 4 servos I GET NO ERRORS about drive resource pop ups so WHAT DA ##$%!!?
I have had the same issue on my pc runnig win10 with 4 industrial usb cams.
At the moment the first usb device is connected to the pc, operating system allocates a portion of the transferring width to the device according to the firmware data inside the device. So lets say up to 20% of your bandwidth has been occupied by the first webcam of surface. Even if you do not use the cam, the space has been already occupied. Now the second cam comes in the ring and lets say this one occupies 30%, and also the pens you mentioned, consider 10 percent per each of them. Machine has some internal universal elements such as touch, finger print, bluetooth etc, which are all under the universal category. So the wise operating system distinguishes that most of the bandwidth of the usb has been occupied and there exists a danger to insert a new bandwidth consuming device which might cause deficiencies for the previously connected devices, that is why it warn every once in a while.
The harsh condition would be like mine, by inserting 4 HD usb cams and losing the connection with one of the cams after some seconds where the pc suffers from running out of bandwidth. For laptops or surface there is no option to expand the bandwidth, but for pc you could add a usb slot in pcie.
Hope you will find this helpful.

SDL-OpenGL Unable to disable V-Sync on Samsung Galaxy Note 4

Using double buffer and the buffer swap function to end the draw loop, SDL_GL_SwapWindow, when I set the Vsync to Off through:
SDL_GL_SetSwapInterval(0); //returns 0 so the vsync option is set correctly
Looks like the VSync is still on on this device.
I've tested the same code in iOS, other android devices including tablets, pcs and mac with a very simple scene and all of them go from about 60 fps with VSync to +400 without it.
The only device that seems to keep the VSync is the Note 4 because the fps are the same.
This is why I'm asking if there any reason for this. I've looked for the device specifications and checked the display and developer options in case there was some kind of VSync locked option there but I found nothing related to this.
EDIT:
Same behaviour with a Samsung Galaxy S4 (VSync won't turn off)
As clarified in comments and documentation, there are drivers and hardware setups that limit the framerate regardless of the vsync configuration/framerate specific management.
In particular, the framerate is limited in most new Android devices.

Galaxy Note II emulator

I am creating a emulator with options 720 X 1280 px, 5.5 inch size.
When I try my code on my real phone (a Galaxy Note II) the views are correct but when I use the emulator the view is just 2/3 of the screen. As we can say that the real phone shows the correct view, where is the problem with the emulator?
The real Note II has scale value 2 when I connect to it, but when I connect it to emulator it says scale value of 1.5, maybe the problem is this. How can I set the correct scale for the Note II phone in AVD or what am I doing wrong in AVD?
The scale is very important. See this tutorial: http://www.basic4ppc.com/android/forum/threads/17647/#content
You should set the DPI value to 320 (2 * 160).

Why does my app return NaN as the speed in my gps based app

I am writing an app for Windows Phone 7 that uses the GPS to track how far and how fast the user is going. Using the Haversine formula according to Dr. Math. http://mathforum.org/library/drmath/view/51879.html I can figure out how far this device has moved since the GPS was started. I am trying to display the speed that the user is traveling in a textblock in miles per hour by using this code here This code is fired when the position is changed.
tblSpeed.Text == (((watcher.Position.Location.Speed * 60) * 60) / 1609.344).ToString()
When I run the app in the emulator and using the GPS emulator recipe found on the WP7 blog I only get 'NaN' in my speed text block. I have a timer that is timing how long the gps has been tracking and I have tried this code there too with the same result. Any ideas on what I could do to resolve this.
It seems that the GPS Recipe doesn't transmit the speed properly. However, check a comment by Morten Nielsen on the blog page as he explains how to manually calculate the speed.

Resources