I've using Laravel DB::connection() for raw query, facing issue while passing parameters to IN clause.
web.php
Route::get("/track","App\Http\Controllers\Track@index");
view track.php
<form action="/track" method="post">
<textarea class="lined" rows="11" cols="60" name="tracking_id[]" id="output" value=""></textarea>
</form>
When html form submitted i am getting this value as a n array Array ( [_token] => JK4lmAZRq4O8Q3g14zy80BECrYEJpLX2vpbkkXvL [tracking_id] => Array ( [0] => UK484532537EE LA270424333EE ) )
Controller
public function index(Request $request){
// prin
$tk = implode(',', $request->tracking_id);
$tracking_id = $request->input("tracking_id");
$data = $request->all();
$finalArray = array();
foreach($data as $key=>$value)
{
array_push($finalArray, array(
'tracking_id'=>$value['tracking_id'])
);
}
print_r($finalArray);
$TrackModel = new TrackModel();
$trackedAllData = $TrackModel->gettrackedAllData($finalArray);
}
i want to pass this finalArray value to modal
Track_Model.php
public static function gettrackedAllData($finalArray){
return DB::connection('mysql')->select('SELECT a.awb_number, a.full_awb_number, a.service_type, b.country_code AS From_country, b.city AS From_city,c.city AS To_city, c.country_code AS To_country,MAX(s.created_at) AS created_at, datediff( max(s.created_at), min(s.created_at)) as Aging FROM customer_shippments a LEFT JOIN addresses b ON a.from_address = b.id LEFT JOIN addresses c ON a.to_address = c.id LEFT JOIN statuses s ON s.awb_number = a.awb_number WHERE a.full_awb_number IN ("'.$finalArray.'") GROUP BY s.awb_number');
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire