I want to passing person_id value from function search() to function view_application() to return view data to detail page with this person_id. here my controller code is
<?php
namespace App\Http\Controllers;
use Faker\Provider\ar_JO\Person;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Application;
use App\Personal;
class CandidatesApplyController extends Controller
{
public function index(){
return view('admin.candidates-apply')
->with('application', Application::all());
}
public function search(Request $request)
{
if ($request->ajax())
{
$output="";
$application = DB::table('application')->where('person_id', 'LIKE', '%' .$request->search.'%')
->orWhere('name_khmer', 'LIKE', '%' .$request->search.'%')
->orWhere('name_latin', 'LIKE', '%' .$request->search.'%')
->get();
if ($application) {
foreach ($application as $key => $applications) {
$output .= '<tr>'.
'<td>'.$applications->person_id.'</td>'.
'<td>'.$applications->name_khmer.'</td>'.
'<td>'.$applications->name_latin.'</td>'.
'<td>'.$applications->app_sex.'</td>'.
'<td>'.$applications->app_dob.'</td>'.
'<td>'.$applications->app_nat.'</td>'.
'<td>'.$applications->app_pob.'</td>'.
'<td>'.$applications->app_current.'</td>'.
'<td>'.$applications->e_mail.'</td>' .
'<td>'.$applications->telephone.'</td>'.
'<td>'.$applications->app_no.'</td>'.
'<td>'.$applications->app_title.'</td>'.
'<td>'.$applications->created_at.'</td>'.
'<td>'."
<div class='btn btn-md btn-info' style='margin-left: 15px; padding: 10px 15px 0px 15px;'>
<a href='#' style='color: #fff;'><p>ពិនិត្យ</p></a>
</div>".'</td>'.
'<td>'."
<div class='btn btn-md btn-info' style='margin-left: 15px; padding: 10px 15px 0px 15px;'>
<a href='./candidate-application' target='_blank' style='color: #fff;'><p>ពិនិត្យ</p></a>
</div>".'</td>'.
'</tr>';
}
return response()->json($output);
}
}
return view('admin.candidates-apply', compact('application'));
}
public function view_application($id){
$app = DB::table('application')->wherePersonId($id)->get();
return view('admin.candidate-application', compact('app'));
}
}
and here my route is
Route::get('/candidates-apply', 'CandidatesApplyController@search')->middleware('auth');
/* Candidate Application Detail View Route*/
Route::get('/candidate-application', 'CandidatesApplyController@view_application', function (){
return view('admin.candidate-application');
})->middleware('auth');
How to do this. Thanks and Regards,
via user3418777