Μέσα σε ένα πακέτο Laravel έκανα, θέλω να ανακατευθύνει τον χρήστη σε έναν ελεγκτή ενέργεια που απαιτεί μια παράμετρο (μέσα στο ίδιο πακέτο).
Ελεγκτής:
public function postMatchItem(Request $request, $id)
{
$this->validate($request, [
'item_match' => 'required|numeric|exists:item,id',
]);
$spot_buy_item = SpotBuyItem::find($id);
$item = Item::find($request->input('item_match'));
$price = $item->getPrice();
$spot_buy_item_response = new SpotBuyItemResponse();
$spot_buy_item_response->spot_buy_item_id = $id;
$spot_buy_item_response->spot_buy_id = $spot_buy_item->spot_buy_id;
$spot_buy_item_response->item_id = $item->id;
$spot_buy_item_response->user_id = $spot_buy_item->user_id;
$spot_buy_item_response->spot_buy_price = $price;
$spot_buy_item_response->created_ts = Carbon::now();
$spot_buy_item_response->save();
return redirect()->action('Ariel\SpotBuy\Http\Controllers\Admin\[email protected]', [$id]);
}
Η δράση της ανακατεύθυνσης είναι το ίδιο μονοπάτι που χρησιμοποιώ κατά τη γνώμη μου routes.php
το αρχείο για να κατευθύνει το χρήστη σε αυτήν την ενέργεια ελεγκτή
Διαδρομή:
Route::get('/part/{id}', 'Ariel\SpotBuy\Http\Controllers\Admin\[email protected]')->where('id', '[0-9]+');
Έχω δοκιμάσει παραλλαγές αυτής της διαδρομής, χωρίς επιτυχία, συμπεριλαμβανομένων [email protected]
, όπως προτείνει η τεκμηρίωση ( https://laravel.com/docs/5.1/responses#redirects )
Σημείωση : Πήρα αυτό το έργο με την ονομασία διαδρομή μου στο routes.php
και χρήση return redirect()->route('route_name', [$id]);
, αλλά θα εξακολουθούν να θέλουν να ξέρουν πώς να περάσει μια δράση ελεγκτή πακέτο για τη ->action()
λειτουργία του.