laravel

Not able to connect Laravel application on App Engine to Cloud SQL database

元气小坏坏 提交于 2021-02-10 16:44:33
问题 I have a Laravel application running on Google App Engine and I want to connect it to the Google Cloud SQL database I have. I have tried many solutions none of them fixed the problem. Everytime it does a request to the database, it throws SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from sessions where id = CQZwtQFAm5RCYcP4ZSqf5mtxTnebGUigQQKVluJa limit 1) . I do have the sessions table, and I also get this error while trying to log in but with the users table then. I've

Convert json String into Object of custom class instead of stdClass.

大憨熊 提交于 2021-02-10 16:18:42
问题 my order.php file has /** * Encode the cart items from json to object * @param $value * @return mixed */ public function getCartItemsAttribute($value){ return json_decode($value); } And in my controller i fetch cartItems as follows public function orderDetails(Order $order){ $address = implode(',',array_slice((array)$order->address,2,4)); foreach ($order->cartItems as $item){ dd($item); } return view('/admin/pages/productOrders/orderDetails',compact('order','address')); } And in above code dd

Getting an error when associating role to a user for one to many relationship

有些话、适合烂在心里 提交于 2021-02-10 16:17:34
问题 I have a one to many relationship between users and roles . I am unable to associate a role to a user while saving or updating a user, as its throwing me an error while saving the model. Please spare some time to have a look below. SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '[3]' for column management . users . role_id at row 1 (SQL: update users set role_id = [3], users . updated_at = 2021-01-29 04:44:19 where id = 3) Database Structure Users ---------- * id *

Convert json String into Object of custom class instead of stdClass.

心已入冬 提交于 2021-02-10 16:16:12
问题 my order.php file has /** * Encode the cart items from json to object * @param $value * @return mixed */ public function getCartItemsAttribute($value){ return json_decode($value); } And in my controller i fetch cartItems as follows public function orderDetails(Order $order){ $address = implode(',',array_slice((array)$order->address,2,4)); foreach ($order->cartItems as $item){ dd($item); } return view('/admin/pages/productOrders/orderDetails',compact('order','address')); } And in above code dd

Getting an error when associating role to a user for one to many relationship

帅比萌擦擦* 提交于 2021-02-10 16:14:55
问题 I have a one to many relationship between users and roles . I am unable to associate a role to a user while saving or updating a user, as its throwing me an error while saving the model. Please spare some time to have a look below. SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '[3]' for column management . users . role_id at row 1 (SQL: update users set role_id = [3], users . updated_at = 2021-01-29 04:44:19 where id = 3) Database Structure Users ---------- * id *

Laravel - One CMS / multiple sites

霸气de小男生 提交于 2021-02-10 15:53:40
问题 Laravel Folder Structure I developed a CMS with laravel which I want to use for multiple websites. My goal is to have a single place to develop my CMS further and don't have old "CMS code" in older websites. The problem is that I dont know how to structure my laravel folder structure. This is what I have in mind: --cms --website-1 --website-2 --website-3 each website must have it's own - public folder - .env file (or config for database and other website specific settings) - routes -

File Not Found Exception in Laravel 7

天涯浪子 提交于 2021-02-10 15:46:44
问题 I am working on a laravel application where I want to download a file by clicking a button. I have stored the file in /storage/app/public/1.pdf and have created a symbolic link to the public folder. Now I tried many ways to download the file but every time, I receive error File Not Fount Exception at path . I have tried the following ways for downloading the file: 1 - $name = "file.pdf"; $file = storage_path(). "/app/public/1.pdf"; $headers = array( 'Content-Type: application/pdf'); return

Get {“message”:“Unauthenticated.”} when sending POST request to laravel server

独自空忆成欢 提交于 2021-02-10 14:48:22
问题 I have a problem with sending POST request from Vue axios to laravel server with sanctum. Firstly I'm getting token. My route of api.php Route::post('/get_token', function (Request $request) { $request->validate([ 'email' => 'required|email', 'password' => 'required', 'device_name' => 'required' ]); $user = User::where('email', $request->email)->first(); if (! $user || ! Hash::check($request->password, $user->password)) { throw ValidationException::withMessages([ 'email' => ['The provided

Get {“message”:“Unauthenticated.”} when sending POST request to laravel server

試著忘記壹切 提交于 2021-02-10 14:47:22
问题 I have a problem with sending POST request from Vue axios to laravel server with sanctum. Firstly I'm getting token. My route of api.php Route::post('/get_token', function (Request $request) { $request->validate([ 'email' => 'required|email', 'password' => 'required', 'device_name' => 'required' ]); $user = User::where('email', $request->email)->first(); if (! $user || ! Hash::check($request->password, $user->password)) { throw ValidationException::withMessages([ 'email' => ['The provided

Laravel Show Resource searching wrong column [closed]

醉酒当歌 提交于 2021-02-10 14:27:52
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 1 year ago . Improve this question I have created a model and controller for my spaces (properties) which has the database structure of; space_id , space_address , space_owner , space_price etc... However when I visit localhost:8000/project/space/1 I am getting this error: Column not found: 1054