Support the ongoing development of Laravel.io →
Configuration Forms
Last updated 2 years ago.
0
City::find($id);

returns an object.

Try this code.

public static function deleteCity()
	{
		$id = $_GET['id'];
		$dd = City::find($id);
		if($id == $dd->id)
		{
		return var_dump('cool');
			//return array(True, array('message'=>'This has now been updated'));
		}else
		{
		return var_dump('not');
			//return array(False, array('message'=>'This has now been updated'));
		}
	}
Last updated 2 years ago.
0

Hi, No its still returning false. The string is '67' so it should be true

array(1) { [0]=> array(3) { ["query"]=> string(54) "select * from cities where cities.id = ? limit 1" ["bindings"]=> array(1) { [0]=> string(2) "67" } ["time"]=> float(1.15) } }

Last updated 2 years ago.
0

First of all, why would you want to do that validation? In my opinion

$id = $_GET['id'];
$dd = City::find($id);

is useless.

It's simpler to delete an object using:

City::destroy($id);

Second, where is this output from?

array(1) { [0]=> array(3) { ["query"]=> string(54) "select * from cities where cities.id = ? limit 1" ["bindings"]=> array(1) { [0]=> string(2) "67" } ["time"]=> float(1.15) } }

Third, if you have an id field in your City model, you can get it using

$city = City::find($id); $city->id;

Last updated 2 years ago.
0

I am only learning Laravel. No, there is not much point to it. But I wanted to get the value from the form and make sure it matched the value from the database and if it matched return the result to a confirmation page, otherwise send it to an error page.

Seeing that it will be a post request the value should always be true but I wanted to see how I can set conditions and return pages

Last updated 2 years ago.
0

Oh, ok then.

Which fields do you get when you execute:

var_dump($dd);

?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ottz0 ottz0 Joined 15 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.