Notice: Undefined index: & Fatal error: Uncaught PDOException: SQLSTATE[42S22]: - inventory-management

Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'expirationDate' in 'field list' in C:\xampp\htdocs\webapps-project-main\model\item\insertItem.php:76 Stack trace: #0 C:\xampp\htdocs\webapps-project-main\model\item\insertItem.php(76): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\webapps-project-main\model\item\insertItem.php on line 76
also this..
Notice: Undefined index: itemDetailsexpirationDate in C:\xampp\htdocs\webapps-project-main\model\item\insertItem.php on line 18
$insertItemStatement->execute(['itemNumber' => $itemNumber, 'itemName' => $itemName, 'discount' => $discount, 'stock' => $quantity, 'unitPrice' => $unitPrice, 'status' => $status, 'description' => $description, 'expirationDate' => $expirationDate]);
also this..
$expirationDate = htmlentities($_POST['itemDetailsexpirationDate']);

Related

How do I get a value of another table on Laravel?

I'm trying to get just value of id column on a table but it returns
SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '[{"id":1}]' for column 'id_jenis' at row 1 (SQL: insert into `pesanan` (`name`, `telpon`, `alamat`, `id_jenis`, `jenis`, `do`, `updated_at`, `created_at`) values (Pradita Candrani, 0813, Jalan Sunan Ampel Kasin, [{"id":1}], Cuci Basah Standar, None, 2019-11-27 12:18:35, 2019-11-27 12:18:35))
Here it is my code on Controller
public function pesan(Request $request){
$harga = Harga::select('id')->where('nama',$request->jenis)->get();
Pesanan::create([
'name' => $request->nama,
'telpon' => $request->telpon,
'alamat' => $request->alamat,
'id_jenis' => $harga,
'jenis' => $request->jenis,
'do'=>$request->do
]);
return redirect('/pesanan');
}
how can I fix this? Please help
You're getting object now and passing it to id_jenis directly. use first() instead of get(). and pass the $harga->id in id_jenis.
$harga = Harga::select('id')->where('nama',$request->jenis)->first();
Pesanan::create([
'name' => $request->nama,
'telpon' => $request->telpon,
'alamat' => $request->alamat,
'id_jenis' => $harga->id,
'jenis' => $request->jenis,
'do'=>$request->do
]);
If you want to store multiple ids in id_jenis then use pluck.
$harga = Harga::where('nama',$request->jenis)->pluck('id')->toArray();
Here you'll get multiple ids in array. so use json_encode to store JSON in db as below.
Pesanan::create([
'name' => $request->nama,
'telpon' => $request->telpon,
'alamat' => $request->alamat,
'id_jenis' => json_encode($harga),
'jenis' => $request->jenis,
'do'=>$request->do
]);
$harga = Harga::select('id')->where('nama',$request->jenis)->get();
After this line, write
\Log::info(['Harga', $harga]);
and check the latest file and error in /storage/logs/laravel.log
Welcome to the wonderful world of debugging

I'm having trouble with "AXIOS PATCH" method

I am trying to update my database record using "axios patch" method.
This is my code:
editClient(client) {
let data = new FormData();
data.append("name", this.client.name);
data.append("email", this.client.email);
data.append("phone", this.client.phone);
data.append("_method", "PATCH");
axios
.post(`/api/clients/${client.id}`, data)
.then(res => {
resolve(res.data.client);
})
.catch(err => console.log(err.response.data));
},
I tried this code:
axios
.patch(`/api/clients/${client.id}`, {
name: this.client.name,
phone: this.client.phone,
email: this.client.email
})
.then(res => {
resolve(res.data.client);
})
.catch(err => console.log(err.response.data));
But it also dosn't work.
The error i get is
POST http://localhost:8000/api/clients/27 500 (Internal Server Error)
{message: "SQLSTATE[42S22]: Column not found: 1054 Unknown co…4 02:12:57"` = updated_at:"2019-05-24 02:12:57"})", exception: "Illuminate\Database\QueryException", file: "C:\xampp\htdocs\prs3\vendor\laravel\framework\src\Illuminate\Database\Connection.php", line: 664, trace: Array(60)}
exception: "Illuminate\Database\QueryException"
file: "C:\xampp\htdocs\prs3\vendor\laravel\framework\src\Illuminate\Database\Connection.php"
line: 664
message: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'name:"2011"' in 'where clause'
And when I tried this code:
axios
.patch(`/api/clients/${client.id}`, {
data: this.client
})
.then(res => {
resolve(res.data.client);
})
.catch(err => console.log(err.response.data));
The error i get is
app.js:285 PATCH http://localhost:8000/api/clients/27 422 (Unprocessable Entity)
{message: "The given data was invalid.", errors: {…}}
errors:
email: ["The email field is required."]
name: ["The name field is required."]
phone: ["The phone field is required."]
__proto__: Object
message: "The given data was invalid."
Im new in axios and vue. Im trying to learn on how to build and CRUD api using axios.
I tried to find other ways and i can't find any.
This is my controller:
public function update(Client $client) {
$val = $client ? ','.$client : '';
$client->update($this->_val($val));
return back();
}
public function _val($val) {
return request()->validate([
'name' => ['required', 'min:2', 'unique:clients,name'.$val],
'email' => ['required', 'email', 'unique:clients,email'.$val],
'phone' => ['required', 'alpha_num'],
]);
}
Your axios post code is fine. It's working fine. The error you get in the post field is larvel error column not found.
I guess you made a typo in some column name while saving data or you entered unknown column by mistake which is not in the table.
Please provide laravel side code, so we can see where you facing an error.
By the way from your question => Your axios.post code is correct

No hint path defined for [notifications]?

No hint path defined for [notifications]? When I reset the password I get this error. I have any templates in view directory, but if auth in view - mail sending, but if auth in view/Template/ directory I get the error:
in FileViewFinder.php (line 112)
at FileViewFinder->parseNamespaceSegments('notifications::email')in FileViewFinder.php (line 90)
at FileViewFinder->findNamespacedView('notifications::email')in FileViewFinder.php (line 76)
at FileViewFinder->find('notifications::email')in Factory.php (line 129)
at Factory->make('notifications::email', array('level' => 'info', 'subject' => null, 'greeting' => null, 'salutation' => null, 'introLines' => array('You are receiving this email because we received a password reset request for your account.'), 'outroLines' => array('If you did not request a password reset, no further action is required.'), 'actionText' => 'Reset Password', 'actionUrl' => 'http://laravel.******.pw/password/reset?4d8a6e1cd764c6c7638fb7eee784cd3394432622b296493f5ee5b39a56712182'))in Markdown.php (line 62)

Error during assigning product image through soap api Magento

HI i have just start learning soap api in magento . In this i have create a product through soap and now i want to assign product images through it.
for that i am using below code
<?php $client = new SoapClient('http://localhost/magento1.9/index.php/api/v2_soap/?wsdl');
$session = $client->login('111111', '111111');
$newImage = array(
'file' => array(
'name' => 'file_name',
'content' => base64_encode(file_get_contents('heart_circle.png')),
'mime' => 'image/jpeg'
),
'label' => 'Cool Image Through Soap',
'position' => 2,
'types' => array('small_image'),
'exclude' => 0
);
$imageFilename = $client->call($session, 'product_media.create', array('product_sku', $newImage));
var_dump($imageFilename);
?>
but i am getting below error Fatal error: Uncaught SoapFault
exception: [Client] Function ("call") is not a valid method for this
service in /var/www/soap.php:19 Stack trace: #0 /var/www/soap.php(19):
SoapClient->__call('call', Array) #1 /var/www/soap.php(19):
SoapClient->call('92b56ed9ed1c9b5...', 'product_media.c...', Array) #2
{main} thrown in /var/www/soap.php on line 19
Please suggest me where i am doing mistake. thanks
Hi i have found the issue it was the wrong soap version mention in the url
http://localhost/magento1.9/index.php/api/v2_soap/?wsdl //previous
http://localhost/magento1.9/index.php/api/soap/?wsdl // new
thanks

Unable to create image in magento api if product SKU contains slash(/)

I'm trying to create an image via magento image api by following the same code in this magento doc.
And its working fine except the SKU contains slash(/) character.
SKU: SPA-1XCHOC12/DS0
Here is the Error shows in httpd/error_log:
[Fri Feb 21 07:35:33 2014] [error] [client 8.35.201.40] PHP Fatal error: Uncaught SoapFault exception: [104] Cannot create image. in /var/www/html/product_api/image.php:22\nStack trace:\n#0 /var/www/html/product_api/image.php(22): SoapClient->__call('call', Array)\n#1 /var/www/html/product_api/image.php(22): SoapClient->call('67da4ad39466d6e...', 'product_media.c...', Array)\n#2 {main}\n thrown in /var/www/html/product_api/image.php on line 22
To identify the exact issue, i have added this code
$this->_fault('not_created', $e->getMessage()); in app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api.php
And this is the error:
[Fri Feb 21 07:41:56 2014] [error] [client 8.35.201.42] PHP Fatal error: Uncaught SoapFault exception: [104] Folder 'SPA-1XCHOC12' isn't writeable in /var/www/html/product_api/image.php:22\nStack trace:\n#0 /var/www/html/product_api/image.php(22): SoapClient->__call('call', Array)\n#1 /var/www/html/product_api/image.php(22): SoapClient->call('7f82eac2c509869...', 'product_media.c...', Array)\n#2 {main}\n thrown in /var/www/html/product_api/image.php on line 22
And media/catalog/product folder permission is 777. Still showing the same error.
Here is my Code:
Post Values are sku = 'SPA-1XCHOC12/DS0' and image_url='http://example.com/11233.jpg'
$sessionId = $proxy->login($api_user, $api_pwd);
$newImage = array(
'file' => array(
'name' => $_POST['sku'],
'content' => base64_encode(file_get_contents($_POST['img_url'])),
'mime' => 'image/jpeg'
),
'position' => 0,
'types' => array('small_image', 'image', 'thumbnail'),
'exclude' => 0
);
$imageFilename = $proxy->call($sessionId, 'product_media.create', array($_POST['sku'], $newImage));
Since your image is being generated by the sku, which you are sending to the routine manually, then why not clean it up there. It won't affect anything else.
Post Values are sku = 'SPA-1XCHOC12/DS0' and image_url='http://example.com/11233.jpg'
$sessionId = $proxy->login($api_user, $api_pwd);
// Replace slashes like waldek_c suggested
$sku_filename = str_replace("/","_",$_POST['sku']).".jpg";
$newImage = array(
'file' => array(
'name' => $sku_filename, // Put filtered $sku_filename var here from above
'content' => base64_encode(file_get_contents($_POST['img_url'])),
'mime' => 'image/jpeg'
),
'position' => 0,
'types' => array('small_image', 'image', 'thumbnail'),
'exclude' => 0
);
$imageFilename = $proxy->call($sessionId, 'product_media.create', array($_POST['sku'], $newImage));
The image filename will be SPA-1XCHOC12_DS0.jpg instead of SPA-1XCHOC12/DS0.

Resources