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'));
}
}
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) } }
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);
Third, if you have an id field in your City model, you can get it using
$city = City::find($id); $city->id;
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
Oh, ok then.
Which fields do you get when you execute:
var_dump($dd);
?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community