Generally you would not pass the user id in the route, unless there was some sort of authentication in the controller. eg. Admin is updating the user. Instead use the Auth::user()
object in the controller.
With regard to your question, there are many options and it is entirely up to you, but a possible way of doing it would be to use a resource route\controller for this.
Route::resource('user/subscription', 'User\SubscriptionController');
Then the controller would look something like this:
<?php
namespace App\Http\Controllers\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class SubscriptionController extends Controller
{
public function index()
{
// get user
$user = Auth::user();
// list all user subscriptions
}
public function store(Request $request)
{
// get user
$user = Auth::user();
if(empty($user)) {
// create user
}
// create and process subscription for the user
// possibly using a plan id in the $request
}
public function show($id)
{
// get user
$user = Auth::user();
// return user subscription details for $id
}
public function update(Request $request, $id)
{
// get user
$user = Auth::user();
// update or change user subscription
// possibly using a plan id in the $request
}
public function destroy($id)
{
// get user
$user = Auth::user();
// cancel user subscription with $id
}
}
And your routes would be like this:
GET
user/subscription
list all user subscriptions index()
POST
user/subscription
create a user subscription store(Request $request)
GET
user/subscription/{subscription_id}
show a user subscription show($id)
PUT/PATCH
user/subscription/{subscription_id}
update a user subscription update($id)
DELETE
user/subscription/{subscription_id}
cancel a user subscription destroy($id)