Wednesday, March 15, 2017

Storing the data sent from android device and displaying it in view blade in laravel

I need to get data sent from android device.Those sent data should be stored in my table called 'leave' where there are three fields they are 'id','reason' and 'description'. What i am able to do till now is i have set up my route as:

    Route::any('jsontest','JsonController@JsonFunction');

And in my controller:

    <?php

    namespace App\Http\Controllers;

    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\Input;

   class JsonController extends Controller
    {
   public function jsonFunction(request $request){
   $requestObj=Input::all();
   if(count($requestObj) > 0)
   {
   return response()->json(['success'=>true,'request_param'=>$requestObj]);
   }
   else
   {
  return response()->json(['success'=>false,'error'=>'send some data']);

   }
   }

   }

now when I hit this in browser : http://rentma.net/attendance/public/jsontest then this comes:

    {"success":false,"error":"send some data"}

which is the message from else part.And when I pass parameters from url like this: http://rentma.net/attendance/public/jsontest?name=suzan then this comes:

    {"success":true,"request_param":{"name":"suzan"}}

you can try it also since it is already in server. but what i want is i want datas to be passed from android device and show that data in view. How can I do that? can anyone help?



via Suz Aann shrestha

Advertisement