Monday, April 10, 2017

how to change status in laravel

its in same table which i share before, again i have column call status in visit table. in this column i have default value 'padding', so i want to change this status in finish as update in database when i click in this prescription button and it should go out of from HTML table not from database.

code are below i used:

$this->addaction[] = ['label'=>'Set Active','url'=>CRUDBooster::mainpath('set-status/active/[id]'),'icon'=>'fa fa-check','color'=>'success','showIf'=>"[status] == 'pending'"];

$this->addaction[] = ['label'=>'Set Pending','url'=>CRUDBooster::mainpath('set-status/pending/[id]'),'icon'=>'fa fa-ban','color'=>'warning','showIf'=>"[status] == 'active'"];

public function getSetStatus($status,$id) {
   DB::table('products')->where('id',$id)->update(['status'=>$status]);

   //This will redirect back and gives a message
   CRUDBooster::redirect($_SERVER['HTTP_REFERER'],"The status product has been updated !","info");
}

enter image description here



via kinzang

Advertisement