mardi 1 novembre 2016

Passing String value from a controller

I want to pass the arguments as String type. But it shows me an error and i can see that it was not passed as a string. Is there a way to pass by string. Following is my function in the controller. (Look on to tag's onclick method from there i need to pass this as a string)

public function show(Request $request)
{
    $output="";

    if ($request->ajax()){
        $models=DB::table('models')->where ('modelName','LIKE','%'.$request->search.'%')
            ->orWhere('brandName','LIKE','%'.$request->search.'%')->get();
        if($models){
            foreach ($models as $key=>$model){
                $Mid=$model->modelName;
                $output.='<tr>'.


                    '<td>'.$model->countryMade.'</td>'.
                    '<td>

                                <a class=" btn btn-success btn-sm" onclick="EditModel('.$model->id.','.$model->modelName.')" >Edit </a>

                                <a onclick="DeleteModel('.$model->id.')"  class=" btn btn-danger btn-sm"  >Delete </a>

                    </td>'.
                '</tr>';
            }

        }

    }
    return response($output);

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire