I would like to load the user, which has the appropriate url in the table invites stored. Unfortunately, I do not get the query written. How can I switch to the table "invites" and still load the right user to the page?
Relation:
One to one
Route
Route::get('/invite/{url}', 'Auth\RegisterController@show')->name('invite.show');
Table invites:
Schema::create('invites', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->text('greeting')->nullable();
$table->string('url')->unique();
$table->timestamps();
});
function
public function show($url)
{
$user = User::where(function ($query) use ($url) {
$query->where('invites.url', '=', $url);
})->first();
return view('invite_user', compact('user'));
}