Little Addition to Seeder #2147
cbka
started this conversation in
Show and tell
Replies: 2 comments
-
What about -
instead of
I am not sure but you may also use upsert also. It will do everything single query.. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi, tbo I have never heard of that method ... But it really does what it should . Your solution is definitely better 😃
Mit freundlichen Grüßen
Christian Becker
mct GmbH
Mühlstr.8, 76229 Karlsruhe
Vertreten durch Christian Becker
Tel. +49 (721) 464712 - 0<tel:+497214647120>
***@***.******@***.***>
www.mct-datensysteme.de<http://www.mct-datensysteme.de/>
…------------------------
ACHTUNG: Dies ist eine vertrauliche Nachricht und nur für den Adressaten bestimmt. Es ist nicht erlaubt, diese Nachricht zu kopieren oder Dritten zugänglich zu machen. Sollten Sie diese Nachricht irrtümlich erhalten haben, bitte ich um Ihre Mitteilung per E-Mail oder unter der oben angegebenen Telefonnummer.
------------------------
________________________________
From: Anwar ***@***.***>
Sent: Thursday, August 4, 2022 7:41:52 AM
To: spatie/laravel-permission ***@***.***>
Cc: cbka ***@***.***>; Author ***@***.***>
Subject: Re: [spatie/laravel-permission] Little Addition to Seeder (Discussion #2147)
What about -
Permission:: updateOrCreate(['name' => $permission]);
instead of
if (!Permission::whereName($permission)->first()) { Permission::create(['name' => $permission]); }
I am not sure but you may also use upsert also. It will do everything single query..
—
Reply to this email directly, view it on GitHub<#2147 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEUJPUBQZILQ7LPDOO4HP6TVXNJ2BANCNFSM55N5XSLQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
this part
if (!Permission::whereName($permission)->first()){
helps the seeder to work even if other values are already seeded.. simple but not in the tutorials i found...
Beta Was this translation helpful? Give feedback.
All reactions