Both ID and Name of the record is supported with GET URL
public function showUpcomingProject($id){
if (intval($id)) {
$item = UpcomingProject::with('projectBlockchain')->findOrFail($id);
} else {
$item = UpcomingProject::with('projectBlockchain')->where('token_name', $id)->first();
}
if (!$item) {
return abort(404);
}
$blockchains = Blockchain::all();
return view(strtolower($this->title).'.home.upcoming_project', compact('item', 'blockchains'))->with('svg_renderer', SvgHelper::getBlockchainSvgs($blockchains));
}
If number is passed to the function as the record ID then
if statement
will run.
If the
token_name
is passed then
else
will run.
If the record is not found, then
404
error is thrown to the client
Route Code for the feature:
Route::get('/upcoming-projects/{id}', [ExternalController::class, 'showUpcomingProject']);