Can i know why?

|
flyingdragons 2021-06-11 20:09:45
I want to query all the payments made by logged in user and with status success

$payments = Payment::where([
‘user_id’ => $user->id,
‘status’ => ‘success’
])
->get();

But I need all the relationship records too like the following

$payments = Payment::with([‘courses’, ‘courses.course_categories])
->where([
‘user_id’ => $user->id,
‘status’ => ‘success’
])
->get();

How can I achieve it. If I do as [‘payable’] then it returns the respective records. But I need payables courses or course_category

payments
———
id, user_id, payable_id, payable_type, status

Payable can be of type User Subscription / Courses Registered

courses
——-
id, name, price, course_category_id

course_categories
—————
id, name, slug

Mani 2021-06-11 20:15:27
laravel_discuss-84917.jpg
What’s the purpose of this time zone in database config? Can someone please explain it….?
flyingdragons 2021-06-11 20:17:38
Mani 2021-06-11 20:15:27
What’s the purpose of this time zone in database config? Can someone please explain it….?

In database table I have seen. For example if you want to invite an user from America to Indian event then the TimeZone will vary to that of India. So while sending the invite you can send the link to him with his local time instead of GMT:5.30

flyingdragons 2021-06-11 20:18:28
flyingdragons 2021-06-11 20:17:38
In database table I have seen. For example if you want to invite an user from America to Indian event then the TimeZone will vary to that of India. So while sending the invite you can send the link to him with his local time instead of GMT:5.30

Just a overview example. But not sure whats the need at Database Level.

flyingdragons 2021-06-11 20:18:39
They could have set the Timezone in config/app.php file like ‘timezone’ => ‘Asia/Kolkata’,
irhamir 2021-06-11 20:19:41
Mani 2021-06-11 20:15:27
What’s the purpose of this time zone in database config? Can someone please explain it….?

Timezone by country and city.

flyingdragons 2021-06-11 20:28:13
flyingdragons 2021-06-11 20:09:45
I want to query all the payments made by logged in user and with status success

$payments = Payment::where([
‘user_id’ => $user->id,
‘status’ => ‘success’
])
->get();

But I need all the relationship records too like the following

$payments = Payment::with([‘courses’, ‘courses.course_categories])
->where([
‘user_id’ => $user->id,
‘status’ => ‘success’
])
->get();

How can I achieve it. If I do as [‘payable’] then it returns the respective records. But I need payables courses or course_category

payments
———
id, user_id, payable_id, payable_type, status

Payable can be of type User Subscription / Courses Registered

courses
——-
id, name, price, course_category_id

course_categories
—————
id, name, slug

Any help or guidance on this please?

Lalit Rana 2021-06-11 20:37:01
2021-06-11 19:53:02
i’m sorry before, how to check error on ajax? thanks

In Ajax You can check jquery or js error in console and php/laravel error in Network

Mani 2021-06-11 20:37:22
flyingdragons 2021-06-11 20:18:39
They could have set the Timezone in config/app.php file like ‘timezone’ => ‘Asia/Kolkata’,

Yes app timezone is EST, but what’s the role of this timezone. I tried changing it but it is saving some funky times in created_at in the db. I hope getting better explanation on it.

flyingdragons 2021-06-11 21:05:12
flyingdragons 2021-06-11 20:09:45
I want to query all the payments made by logged in user and with status success

$payments = Payment::where([
‘user_id’ => $user->id,
‘status’ => ‘success’
])
->get();

But I need all the relationship records too like the following

$payments = Payment::with([‘courses’, ‘courses.course_categories])
->where([
‘user_id’ => $user->id,
‘status’ => ‘success’
])
->get();

How can I achieve it. If I do as [‘payable’] then it returns the respective records. But I need payables courses or course_category

payments
———
id, user_id, payable_id, payable_type, status

Payable can be of type User Subscription / Courses Registered

courses
——-
id, name, price, course_category_id

course_categories
—————
id, name, slug

Got it working. Thank you everyone

Billygotclout 2021-06-11 21:09:08
Any tutorials between creating a relationship between the user and 2 different models?then can only view the lists created with the user accounts
Billygotclout 2021-06-11 21:13:22
Billygotclout 2021-06-11 21:09:08
Any tutorials between creating a relationship between the user and 2 different models?then can only view the lists created with the user accounts

Anyone?

imkb 2021-06-11 21:46:22
Anyone knowing about laravel filter eloquent queries
alessandro 2021-06-12 01:28:08
Hi, i’m trying http test but when i post request i get error 500 for method not allowed. In the route list there is the post method. Have Anyone same problem?
YgmiLawliet 2021-06-12 01:54:29
laravel_discuss-84937.jpg
I’m having a problem $justi->id_permohonan_msa =$id. the $id does not insert into id_permohonana_msa column in database.
DesolatorMagno 2021-06-12 01:58:27
did you try saving?
natghi2010 2021-06-12 01:59:16
YgmiLawliet 2021-06-12 01:54:29
I’m having a problem $justi->id_permohonan_msa =$id. the $id does not insert into id_permohonana_msa column in database.

does create return the variable

YgmiLawliet 2021-06-12 02:04:15
DesolatorMagno 2021-06-12 01:58:27
did you try saving?

thanks sir , it works right now. Sir, since I’m new in laravel . I wanna ask ,if without create the object (Justifikasi::create($value);) will it save automatically? cause before include the $justi->id_permohonan_msa = $id; it save automatically after submit the form

YgmiLawliet 2021-06-12 02:04:54
natghi2010 2021-06-12 01:59:16
does create return the variable

no, but thanks for help me.

natghi2010 2021-06-12 02:05:36
YgmiLawliet 2021-06-12 02:04:54
no, but thanks for help me.

use firstOrCreate instead of create

DesolatorMagno 2021-06-12 02:05:37
It should save, maybe you didn’t update the $fillable or $guarded.
YgmiLawliet 2021-06-12 02:06:24
natghi2010 2021-06-12 02:05:36
use firstOrCreate instead of create

oh what the differece .can i know?

natghi2010 2021-06-12 02:06:44
YgmiLawliet 2021-06-12 02:06:24
oh what the differece .can i know?

it will bring back the record

YgmiLawliet 2021-06-12 02:07:13
DesolatorMagno 2021-06-12 02:05:37
It should save, maybe you didn’t update the $fillable or $guarded.

ok sir i understand

YgmiLawliet 2021-06-12 02:07:32
natghi2010 2021-06-12 02:06:44
it will bring back the record

oh, new knowledge for me. Thanks

DesolatorMagno 2021-06-12 02:08:29
That id is inside $value?
YgmiLawliet 2021-06-12 02:08:43
laravel_discuss-84950.jpg
I’m getting this symbol after submit the form. can i know why? it on my browser
natghi2010 2021-06-12 02:08:43
$justi = Justifkasi::firstOrCreate($value)->update([‘id_permonhan_msa’=>$id]);
YgmiLawliet 2021-06-12 02:11:43
DesolatorMagno 2021-06-12 02:08:29
That id is inside $value?

no sir, since the value is the Dynamically Add or Remove Multiple Input. The id is for refer to which form is submit.

DesolatorMagno 2021-06-12 02:12:55
You can add Dymacally inputs and put a extra hidden input with id_phermona_msa
DesolatorMagno 2021-06-12 02:14:49
$values[‘id_permohonan_msa’] = $id;
Justifikasi::create($values);

Or do it manually inside the foreach.

YgmiLawliet 2021-06-12 02:18:37
DesolatorMagno 2021-06-12 02:14:49
$values[‘id_permohonan_msa’] = $id;
Justifikasi::create($values);

Or do it manually inside the foreach.

sir, can you explain how this code works, cause i can’t understand 🙏

DesolatorMagno 2021-06-12 02:19:44
you take id 👉🏽 from here $id
and put it inside the array of values
DesolatorMagno 2021-06-12 02:20:18
laravel_discuss-84956.jpg
Just before the create, yo add the id to the array $value
YgmiLawliet 2021-06-12 02:26:48
ok sir, i did it.
|