laravelフレームワークが初めてです。私は私のアプリで重要な仕事を完了したい。 そのアプリには、請求書、相場、支払い、顧客などのモジュールがあります。特定の顧客には、送金され、部分的に支払われた状態の複数の請求書があります。ここでlaravelでajaxを使用するオートコンプリートと複数の関数
は、それが顧客テーブルから自己暗示を取得する顧客名のタイプに、領収ページです。 cutomer nameのOnclickは、顧客IDに基づいて(請求書テーブル)から請求書の詳細を取得し、その顧客名のテキストボックス、テーブル請求書のonclickを表示する必要があります。これは、特定の顧客が必要な未払いの請求書支払いを記録するには、通常の領収書登録を続行します。
私はこのようなコードを試してみますが、適切な出力が得られていないので、誰もこの問題を解決するのを助けてください。
<input type="text" name="customername" required="required" id="cust" placeholder="Customer Name" class="form-control col-md-7 col-xs-12 typeahead"/>
$(function() {
$("#cust").autocomplete({
//source: "http://www.duminex.com/client/search",
source: "{{route('search.client')}}",
select: function(event, ui) {
get_invoices(ui.item.id);
$('#id').val(ui.item.id);
$('#clientAddress').val(ui.item.address);
}
});
});
function get_invoices(client_id)
{
$.ajax({
method: 'GET',
url: "{{route('client.details')}}"
}).done(function(data){
alert(data);
});
}
ルート
Route::get('/client/search',[
'uses'=>'[email protected]',
'as'=>'search.client'
]);
Route::get('/client/search2', '[email protected]')->name('client.details');
コントローラー事前に
public function search(Request $request)
{
$s= Input::get('term');
$clients = Client::select("id" ,"user_id", "companyname", "companyaddress" , "billingAddress")->where('companyname','like','%'.$s.'%')->where('user_id',Auth::user()->id)->get();
if(count($clients) == 0){
$searchResult[] = "No Item found";
}
else{
foreach ($clients as $key => $value) {
$searchResult[] = ['id' => $value->id, 'value' => $value->companyname , 'email' => $value->companyaddress , 'address' => $value->billingAddress];
}
}
return $searchResult;
}
public function search2(Request $request)
{
$clients = Invoice::select("invoiceNo")->where('status',['sent,Partially paid'])->where('client_id',$request->client_id)->get();
if(count($clients) == 0){
$searchResult[] = "No Item found";
}
else{
foreach ($clients as $key => $value) {
$searchResult[] = ['invoiceNo' => $value->invoiceNo];
}
}
return $searchResult;
}
感謝。私はこの問題を解決するために誰も助けてください。
あなたはどこにいますか? –
その値を返さない.. –
レスポンス、検索、または検索2関数を返さないものはどれですか? –