Why the continue?

|
rebory 2019-08-13 07:17:52
laravel_discuss-10862.jpg

rebory 2019-08-13 07:18:01
This is controller code
rebory 2019-08-13 07:18:19
I try to save this form data in two tables
rebory 2019-08-13 07:18:35
laravel_discuss-10865.jpg

rebory 2019-08-13 07:23:04
laravel_discuss-10866.jpg

rebory 2019-08-13 07:23:18
This is my controller code
skys215 2019-08-13 07:34:34
I assume that $cityId is an array or object
rebory 2019-08-13 07:35:08
laravel_discuss-10869.jpg

skys215 2019-08-13 07:35:47
show what does saveMultiple function do
rebory 2019-08-13 07:37:50
Wait
rebory 2019-08-13 07:39:11
laravel_discuss-10872.jpg

rebory 2019-08-13 07:40:08
When id dd($cityId)
rebory 2019-08-13 07:41:16
laravel_discuss-10874.jpg

skys215 2019-08-13 07:41:59
ok
rebory 2019-08-13 07:42:01
I trying to save one form data in two different tables
rebory 2019-08-13 07:42:20
Proposal name in city_propsal
skys215 2019-08-13 07:42:21
rebory 2019-08-13 07:39:11

is this base on Model or Eloquent?

rebory 2019-08-13 07:42:32
Yes
skys215 2019-08-13 07:43:11
since your $room_type and $quantity is an array, you can’t save it to a row
skys215 2019-08-13 07:43:27
transform it to a string and save it
rebory 2019-08-13 07:43:48
Pls tell my how i convert it string
skys215 2019-08-13 07:44:20
implode/json_encode
it depends on your requirements
skys215 2019-08-13 07:44:24
if you are willing to save as multiple records, try saveMany function
GauravGohil 2019-08-13 10:03:05
i want unique names of saved template for a particular user
GauravGohil 2019-08-13 10:03:07
$this->validate($request,[
‘name’ => ‘required|string|unique:saved_templates,name,’.$savedtemplates->id
]);
GauravGohil 2019-08-13 10:03:17
this is what validation looks like
GauravGohil 2019-08-13 10:04:01
it gives error when a user uses a name used by another user
praneet81 2019-08-13 10:08:01
I think it’s a better idea to have email as unique rather than name
GauravGohil 2019-08-13 10:11:49
its project table
GauravGohil 2019-08-13 10:12:18
so i want unique project names for uniques users
rebory 2019-08-13 11:28:28
skys215 2019-08-13 07:44:20
implode/json_encode
it depends on your requirements

laravel_discuss-10894.jpg

oxbir 2019-08-13 13:49:29
I want to make a condition to show if there is anyone in the database. Show sweet alert if not available

My Controller.php

public function document(Request $request)
{
$keyword = $request->input(‘code’);
$documents = Document::document($keyword)->latest()->get();
if (!isset($documents)) {
alert()->error(‘Information with this number has not been disclosed to the system.’, ‘ok’)->persistent(‘ok’);
}
return view(‘Home.content.documents’, compact(‘documents’));
}

oxbir 2019-08-13 14:04:22
Hey I replace it. But i did not work.
oxbir 2019-08-13 14:05:32
؟
skys215 2019-08-13 14:11:33
oxbir 2019-08-13 14:04:22
Hey I replace it. But i did not work.

Dump $documents

gmaciel 2019-08-13 22:58:57
PHP job in Toronto – Canada

https://secure.collage.co/jobs/acto/12335

We’re Hiringsecure.collage.co
ACTO is hiring a PHP Developer
Satish Tigga 2019-08-13 23:55:25
How we can store value of foreach loop
DesolatorMagno 2019-08-13 23:55:53
Storing it, maybe you could be more specific.
Satish Tigga 2019-08-13 23:56:51
In my view controller is returning value and I want to store each value while I run foreach loop
DesolatorMagno 2019-08-13 23:59:58
Your view should be a file and your controller another, if you “want to store each value in foreach” just store it
for each $vars as var
$thing = new Thing()
$thing->name = $var->name
$thing->save()
endforeach
Satish Tigga 2019-08-14 00:04:23
DesolatorMagno 2019-08-13 23:59:58
Your view should be a file and your controller another, if you “want to store each value in foreach” just store it
for each $vars as var
$thing = new Thing()
$thing->name = $var->name
$thing->save()
endforeach

Suppose if I have to store 2 or more values then

for each $vars as var
$thing = new Thing()
$thing->name = $var->name
continue
$thing->name1= $var->name
$thing->save()
endforeach

Is this correct

DesolatorMagno 2019-08-14 00:04:50
why the continue?
DesolatorMagno 2019-08-14 00:05:46
$thing->name
$thing->phone
$thing->email
….
you can store in memory all that data and at the end you just do a
$thing->save()
DesolatorMagno 2019-08-14 00:06:05
The documentation don’t bite.
DesolatorMagno 2019-08-14 00:06:55
https://laravel.com/docs/5.8/eloquent#inserting-and-updating-models

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.
Satish Tigga 2019-08-14 00:07:24
Suppose if I have to store 2 or more values then

for each $vars as var
$thing = new Thing()
If condition
$thing->name = $var->name
$thing->name1= $var->name
$thing->save()
endforeach

Is this correct

DesolatorMagno 2019-08-14 00:07:45
laravel_discuss-10919.jpg
You can even create the object and store it in 1 steep.
DesolatorMagno 2019-08-14 00:08:49
Yes.
Satish Tigga 2019-08-14 00:10:28
for each $vars as var
$thing = new Thing()
If condition
$thing->name = $var->name
$thing->name1= $var->name
$thing->save()
endforeach

BUT FOR $name1 I think loop will not iterate and I may be wrong

DesolatorMagno 2019-08-14 00:13:05
If you dont trust your own code, nobody else will XD.
I am not sure what you are trying to do, but there is the documentation, maybe it will help you.
|