Should I Move the Entire Query to Product Model?

|
Anand Tujare 2022-09-30 18:34:24
web design 2022-09-30 18:31:24
But it doesn’t save in database

Any error whole storing ???

web design 2022-09-30 18:35:06
Anand Tujare 2022-09-30 18:34:24
Any error whole storing ???

It doesn’t error

Anand Tujare 2022-09-30 18:35:25
Blank screen???
web design 2022-09-30 18:35:42
Anand Tujare 2022-09-30 18:35:25
Blank screen???

No

web design 2022-09-30 18:36:00
I don’t know what is it
Anand Tujare 2022-09-30 18:36:34
Screenshot??
web design 2022-09-30 18:36:47
laravel_discuss-140168.jpg

web design 2022-09-30 18:37:11
Anand Tujare 2022-09-30 18:36:34
Screenshot??

Pv?

web design 2022-09-30 18:39:24
Anand Tujare 2022-09-30 18:36:34
Screenshot??

Well

web design 2022-09-30 18:39:53
Anand Tujare 2022-09-30 18:36:34
Screenshot??

Can you help me

Anand Tujare 2022-09-30 18:40:27
Ok looks like there 2 tables … one is Parties and other is reals something
web design 2022-09-30 18:40:57
Anand Tujare 2022-09-30 18:40:27
Ok looks like there 2 tables … one is Parties and other is reals something

Ok

Phansivang168 2022-09-30 19:29:22
i’m new to laravel please help me fine the solution I try to post something with specific user how can I do that ?
Anand Tujare 2022-09-30 19:43:40
Phansivang168 2022-09-30 19:29:22
i’m new to laravel please help me fine the solution I try to post something with specific user how can I do that ?

Specific user as in??

Phansivang168 2022-09-30 19:48:34
Anand Tujare 2022-09-30 19:43:40
Specific user as in??

I create model post and when I post I want that post relate to the user auth too

suuwhooop 2022-09-30 21:15:35
Phansivang168 2022-09-30 19:48:34
I create model post and when I post I want that post relate to the user auth too

Suppose you have a $user_id column in the post tables, and your user is logged in. Then you would want something like this in your store() method
$post[‘user_id’] = Auth::user()->id();

kshamamishra 2022-09-30 21:27:38
hello is there any one how know good source of learning php 8
Phansivang168 2022-09-30 21:39:38
suuwhooop 2022-09-30 21:15:35
Suppose you have a $user_id column in the post tables, and your user is logged in. Then you would want something like this in your store() method
$post[‘user_id’] = Auth::user()->id();

it’s don’t have id() methods brother

Shohbozbek_Turgunov 2022-09-30 21:42:44
laravel_discuss-140186.jpg
Migration is not happening, I made a mistake
walex0080 2022-09-30 21:43:50
Shohbozbek_Turgunov 2022-09-30 21:42:44
laravel_discuss-140186.jpg
Migration is not happening, I made a mistake

The reason is right in front of you. “Users table already exist”

walex0080 2022-09-30 21:45:06
Shohbozbek_Turgunov 2022-09-30 21:42:44
laravel_discuss-140186.jpg
Migration is not happening, I made a mistake

It’s either you refresh your migration or you use another table name

T K 2022-09-30 22:21:47
laravel_discuss-140192.jpg
This is my code:

function wipe_data() {
     DB::beginTransaction();
     $adminData = User::where(‘role’, ‘admin’)->first(); 
    try {
        User::truncate();
        User_details::truncate();
        User_kyc::truncate();
        Token::truncate();`enter code here`
        $auto_id = date(‘Y’);
        DB::statement(“ALTER TABLE ls_users AUTO_INCREMENT = $auto_id”);
        $admin = new User();
        $admin->username = $adminData->username;
        $admin->email = $adminData->email;
        $admin->password = $adminData->password;
        $admin->role = $adminData->role;
        $admin->save();
        $user_id = User::where(‘role’, ‘admin’)->value(‘id’);
        DB::commit();
    } catch (Exception $ex) {
    dd($ex);
        DB::rollback();
        return false;
    }
    return true;
}

error ———————

PDOException
There is no active transaction

——————————-

🙏 help me  
Laravel-8

T K 2022-09-30 22:22:11
Please help me
T K 2022-09-30 22:28:14
Any one…… Please
twitchnyc 2022-09-30 22:51:56
@Abdu081680 where are u bro
#Math 2022-09-30 23:01:39
T K 2022-09-30 22:21:47
laravel_discuss-140192.jpg
This is my code:

function wipe_data() {
     DB::beginTransaction();
     $adminData = User::where(‘role’, ‘admin’)->first(); 
    try {
        User::truncate();
        User_details::truncate();
        User_kyc::truncate();
        Token::truncate();`enter code here`
        $auto_id = date(‘Y’);
        DB::statement(“ALTER TABLE ls_users AUTO_INCREMENT = $auto_id”);
        $admin = new User();
        $admin->username = $adminData->username;
        $admin->email = $adminData->email;
        $admin->password = $adminData->password;
        $admin->role = $adminData->role;
        $admin->save();
        $user_id = User::where(‘role’, ‘admin’)->value(‘id’);
        DB::commit();
    } catch (Exception $ex) {
    dd($ex);
        DB::rollback();
        return false;
    }
    return true;
}

error ———————

PDOException
There is no active transaction

——————————-

🙏 help me  
Laravel-8

https://stackoverflow.com/questions/67198158/there-is-no-active-transaction-when-refreshing-database-in-laravel-8-0-test

“There is no active transaction” when refreshing database in Laravel 8.0 testStack Overflow
Using php 8.0.2 and Laravel 8.37.0, I am running tests where for every test the database data should be refreshed, since there is conflicting data per test (due to unique constraints).
using the in-
Scootwilliams01 2022-09-30 23:18:40
https://www.fiverr.com/s2/04323e116a

Charleston_01: I will do beauty, cosmetics, lashes and spa logo for $15 on fiverr.comFiverr.com
For only $15, Charleston_01 will do beauty, cosmetics, lashes and spa logo. | WELCOME TO MY GIG!!!If you want a distinctive, contemporary and stylish logo for your salon, spa or line of cosmetics that people will remember. You’re | Fiverr
Arif 2022-10-01 00:29:13
If Anyone wants to build standard web application in reasonable price
Then you can knock me
I will do you for you
Amir 2022-10-01 00:37:57
laravel_discuss-140200.jpg
Greetings, I have a question.

Consider that we need to refactor some code.
A large query built with Query Builder and modified with Laravel Collections within a controller (in the show method of ProductController). Finally, it creates an array that is added as an attribute to the output of our REST API (in this case, product features such as color, no matter).

What, in your opinion, should I change about this?

Should I Move the Entire Query to Product Model? or should it be left in the controller here? Do you have any suggestions for improving this piece?

DesolatorMagno 2022-10-01 00:46:33
You can make a class just to return the response in the API, something like the Api Response that Laravel have.
DesolatorMagno 2022-10-01 00:47:44
https://laravel.com/docs/9.x/eloquent-resources

Laravel – The PHP Framework For Web ArtisansLaravel
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Amir 2022-10-01 00:53:21
DesolatorMagno 2022-10-01 00:46:33
laravel_discuss-140192.jpg
You can make a class just to return the response in the API, something like the Api Response that Laravel have.

Something like repository pattern
You right

DesolatorMagno 2022-10-01 00:54:04
Is a class to prepare the output, you can read more about it in the link.
suuwhooop 2022-10-01 01:49:42
Phansivang168 2022-09-30 21:39:38
laravel_discuss-140192.jpg
it’s don’t have id() methods brother

Use it without the parentheses

Laksida 2022-10-01 02:26:34
Who wil sel his course online
|