I have three tables and migrations are listed below. Everything is working fine. It is listing the applicant name and details by a join I have below. My question is I have a view button that I want to click and select from the tables by applicant name. How do I do that?
Select statement for listing the applicant names
public function getSponsorDashboard() {
$sponsor = DB::table('users')
->join('sponsor_application', 'sponsor_application.user_id', 'users.id')
->leftJoin('profiles', 'profiles.user_id', 'users.id')
->where('profiles.user_id', '=' ,Auth::user()->id)
->get();
return view('sponsor.dashboard', compact('sponsor'))->with('data', Auth::user()->profile);
}
Users Migration
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
Profile Migration
public function up()
{
Schema::create('profiles', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('address')->nullable;
$table->string('apt')->nullable;
$table->string('city')->nullable;
$table->string('state')->nullable;
$table->string('zipcode')->nullable;
$table->string('homephone')->nullable;
$table->string('cellphone')->nullable;
$table->boolean('baptized')->nullable;
$table->string('lastweekendserved')->nullable;
$table->timestamps();
});
}
Sponsor Application Migration
public function up()
{
Schema::create('sponsor_application', function (Blueprint $table) {
$table->id();
$table->integer('user_id');
$table->integer('profile_id');
$table->string('besttime');
$table->string('applicantname');
$table->boolean('applicantbaptized');
$table->boolean('spousediscuss');
$table->boolean('bothspouseattend');
$table->string('ifnospouseattend')->nullable;
$table->text('whygoodcandidate');
$table->text('applicantattitude');
$table->text('leadershipexpectations');
$table->text('sponsorsupport');
$table->text('otherinfo');
$table->string('sponsorsignature');
$table->date('datesigned');
$table->timestamps();
});
}