title: Pass json from ajax to laravel controller
body: <p>would you like to help me? I have an ajax like this</p>
  
  <pre><code>var id = {{@$projectid}};
  var datatab = JSON.stringify({data: change})
  $.ajax({
    url: 'save/'+id,
    type: 'POST',
    dataType: 'JSON',
    data: {json:datatab},
    success: function(response, textStatus, jqXHR) {
  });
  </code></pre>
  
  <p>and then, I want to pass the datatab as json to database in json field
  this is my save function in controller</p>
  
  <pre><code> public function save($project_id=0, Request $request)
   {
      $project_id = $request-&gt;project_id;
      $weight = $request-&gt;weight;
  
      TaskPlanning::create([
          'project_id' =&gt; $project_id,
          'weight' =&gt; $weight
      ]);
  
      return response()-&gt;json([]);
  }
  </code></pre>
  
  <p>In database, weight field is json. and I want to save my json file from ajax to weight
  This is my model</p>
  
  <pre><code>class TaskPlanning extends Model
  {
      protected $table = 'p_task_planning';
      protected $fillable = ['project_id','weight'];
  
      public function project()
      {
          return $this-&gt;belongsTo(Project::class,'project_id','id');
      }
  
      public function milestone()
     {
         return $this-&gt;belongsTo(Milestone::class,'milestone_id','id');
     }
  
     protected $casts = [
        'weight' =&gt; 'array'
     ];
   }
  </code></pre>