javascript - Laravel "MethodNotAllowedHttpException in RouteCollection.php line 219" -
i'm wondering right why particular table interacting database returns error above subject in fact using same mechanism other table. refering table "inventory". store method returns error stated in subject above , have checked parameters in controller , in model , seems there no error. can me spot error here. please help. here codes.
inventorycontroller.php public function store( request $request ){ $prod_ids = $request['product_ids']; $purchase_order_ids = $request['purchase_order_ids']; $purchase_ids = $request['purchase_ids']; $quantity = $request['purchasequantity']; for($i = 0; $i < count($prod_ids); $i++){ inventory::create([ 'product_id' => $prod_ids[$i], 'purchase_order_id' => $purchase_order_ids[$i], 'purchase_id' => $purchase_ids[$i], 'quantity' => $quantity[$i] ]); } return json_encode(array('notify' => "success")); }
my model => inventory.php
<?php namespace app\inventory; use illuminate\database\eloquent\model; class inventory extends model { protected $fillable = ['product_id','purchase_order_id','purchase_id','quantity']; }
my javascript:
$("#purchase_toinventoryid").click(function(e){ e.preventdefault(); var array_prodid = <?php echo json_encode(isset($array_prodid) ? $array_prodid : 0); ?>; var array_poid = <?php echo json_encode(isset($array_poid) ? $array_poid : 0); ?>; var array_purchaseid = <?php echo json_encode(isset($array_purchaseid) ? $array_purchaseid : 0); ?>; var array_purchasequantity = <?php echo json_encode(isset($array_purchasequantity) ? $array_purchasequantity : 0); ?>; $.post("{{ url('savetoinventory') }}", { 'product_ids': array_prodid, 'purchase_order_ids': array_poid, 'purchase_ids':array_purchaseid, 'purchasequantity': array_purchasequantity }, function(data){ if(data.notify == "success"){ console.log(data.notify); }else{ console.log(data.notify); } }, 'json'); });
my routes.php
route::post('savetoinventory', 'inventory\inventorycontroller@store');
Comments
Post a Comment