I'm trying to retrieve last record id of my subscriptions table in laravel 6
Following is my function
public function activateApp($id)
{
$app = App::where('appId','=',$id)->firstOrFail();
if($app->payment_option == 'monthly')
{
$renewDate = date('Y-m-d', strtotime(date("Y-m-d", strtotime("+30 day"))));
}
else
{
$renewDate = date('Y-m-d', strtotime(date("Y-m-d", strtotime("+365 day"))));
}
$lastdata = DB::table('subscriptions')->orderBy('id', 'desc')->first();
//dd($lastdata);
//die();
//update app table records
DB::table('apps')
->where('appId', $id)
->update([
'status' => $lastdata,
'renewDate' => $renewDate
]);
return redirect()->route('home');
}
I have used
$lastdata = DB::table('subscriptions')->orderBy('id', 'desc')->first();
to get the id, but when it seem to be not working as when i try to update my app table ststus column from that value, it's not updating and not even giving an error..even the 'dd' is not working as well.
(Whole function seem to be stopped working after that last record fetching )
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire