← prev | next →
cayetanohosma 2020-11-26 11:01:25
Hi guys!
I have a challenge, If you have a try catch inside a controller action to catch a possible error during persisting process and you must to move out there, and do not use a try-catch block, where do you put that to check if the persist was done?
hypernxf 2020-11-26 11:46:05
Sorry I’m abit confuse with the question move out to where?
hypernxf 2020-11-26 11:46:41
@Mishal1803 What’s up?
hypernxf 2020-11-26 11:47:18
Sysome https://github.com/spatie/laravel-permission might be helpful to you or you can simple use Laravel ACL which in itself is quite easy to use
GitHub – spatie/laravel-permission: Associate users with roles and permissions –
GitHubAssociate users with roles and permissions. Contribute to spatie/laravel-permission development by creating an account on GitHub.
Parsa_Aza7 2020-11-26 11:50:14
Hi i have one problem
How to create one form & this form we have one field i can’t insert data to two collumn in database
hypernxf 2020-11-26 11:50:59
Parsa.Az What do you mean by you have one field that you can insert data to two column in database?
Parsa_Aza7 2020-11-26 11:53:31
I have one table, name(serial number)
And this table i have two collumn
This collumn name (serial_number & serial_number_hash)
Parsa_Aza7 2020-11-26 11:54:44
And i want insert data in serial number form insert to serial number and i hashed the serial number insert to serial_number_ hash collumn
Parsa_Aza7 2020-11-26 11:55:15
This form we have one input name is serial number
kevinpita 2020-11-26 11:56:26
Whats the problem? Parsa.Az just insert both
hypernxf 2020-11-26 11:59:20
ok
hypernxf 2020-11-26 12:00:34
so
$serialNumber = request(‘serial_number’);
$serialNumberHash = Hash::(request(‘serial_number’));
Model::create([
‘serial_number’ => $serialNumber,
‘serial_number_hash’ => $serialNumberHash,
]);
hypernxf 2020-11-26 12:00:51
Something like this?
Parsa_Aza7 2020-11-26 12:14:24
hypernxf 2020-11-26 12:00:34
so
$serialNumber = request(‘serial_number’);
$serialNumberHash = Hash::(request(‘serial_number’));
Model::create([
‘serial_number’ => $serialNumber,
‘serial_number_hash’ => $serialNumberHash,
]);
Thanks for your help 😃
hypernxf 2020-11-26 12:14:35
Welcome!
Parsa_Aza7 2020-11-26 12:14:44
I test this code and give you feedback
2020-11-26 12:41:54

i want to pull total number of data and insert into each of this cards
hypernxf 2020-11-26 12:45:31
so what’s your question?
Pro 2020-11-26 12:48:16
2020-11-26 12:41:54
i want to pull total number of data and insert into each of this cards
a count query for each case
hypernxf 2020-11-26 12:57:31
$drivers = Driver::count();
$assignedDrivers = Driver::assigned()->count();
etc etc…
hypernxf 2020-11-26 12:57:42
something like this?
cayetanohosma 2020-11-26 13:10:33
I guess that is the only option, although the other option is keep a counter in a table and update it using the eloquent events
cayetanohosma 2020-11-26 13:15:01
hypernxf 2020-11-26 11:46:05
Sorry I’m abit confuse with the question move out to where?
That is the question, where will you move it?
ricardosawir 2020-11-26 14:46:38
Hi all, I write about 9 PHP functions that help me personally. Might be useful for you who happens to write PHP code https://ricardosawir.medium.com/9-useful-php-tips-and-code-snippets-that-get-the-jobs-done-722a67804b61
9 Useful PHP Tips and Code Snippets That Get The Jobs Done –
MediumHi friends, my name is Ricardo Sawir. Follow and subscribe if you like to get more updates on what I make:
hypernxf 2020-11-26 14:52:49
cayetanohosma 2020-11-26 13:15:01
That is the question, where will you move it?
Sorry I still cant understand. Move what to where? do you have code examples?
2020-11-26 16:00:15
Hello, anyone wanna teach me about mvc?🥺
cayetanohosma 2020-11-26 16:06:25
2020-11-26 16:00:15
Hello, anyone wanna teach me about mvc?🥺
There are a lot of videos in YouTube that could teach you about that, and there are more at Udemy or websites like that
pranavsense 2020-11-26 20:04:35
im getting error
Numeric value out of range: 1264 Out of range value for column ‘price’ at row 1 (SQL: insert into orders (user_id, … price, cost, updated_at, created_at) values (17, … 33, 30, 2020-11-26 22:25:43, 2020-11-26 22:25:43))
my price column is decimal(10,4)
why is it so ?
natghi2010 2020-11-26 20:05:46
pranavsense 2020-11-26 20:04:35
im getting error
Numeric value out of range: 1264 Out of range value for column ‘price’ at row 1 (SQL: insert into orders (user_id, … price, cost, updated_at, created_at) values (17, … 33, 30, 2020-11-26 22:25:43, 2020-11-26 22:25:43))
my price column is decimal(10,4)
why is it so ?
Float
pranavsense 2020-11-26 20:07:03
? i have set 4 precision level and adding value 33 still getting error also tried adding decimal using round
Kamalwebdev 2020-11-26 20:07:31
Ok sorry 😔
natghi2010 2020-11-26 20:11:35
I wanted to see what triggers it
hypernxf 2020-11-26 20:14:34
@bugfro https://stackoverflow.com/questions/33348508/mysql-decimal-type-out-of-range-error
MySQL Decimal Type Out Of Range Error –
Stack OverflowThis code:
DROP DATABASE IF EXISTS `my_db`;
CREATE DATABASE `my_db`;
CREATE TABLE `my_db`.`my_table` (
`id` integer NOT NULL AUTO_INCREMENT,
`multiplier` decimal(18, 10) NOT NULL,
hypernxf 2020-11-26 20:14:47
see if this helps you. I dont really fully understand but you might.
pranavsense 2020-11-26 20:14:56
i just tried using round function on the value it worked but why its not accepting just 33 as input
hypernxf 2020-11-26 20:16:17
i think ,4 is not really a precision
hypernxf 2020-11-26 20:16:31
decimal(18, 10) means 10 digits after decimal and 8 before decimal, not until 18 digits
hypernxf 2020-11-26 20:16:46
this is probably the same case as yours
pranavsense 2020-11-26 20:17:47
im using 33 as input value its definitely following all rules 🙂
← prev | next →