title: want to upload a pdf file into mysql using laravel
body: <p>hello i am new in laravel. for my project purpose, i have a feature to upload a pdf file in database. but data not stored in databases. </p>
  
  <p>here is my attempted codes=</p>
  
  <p>controller- </p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use Auth;
  use DB;
  class PostsController extends Controller
  {
      public function index()
      {
          $id = Auth::id();
          $user = DB::table('users')-&gt;find($id);
          return view('posts', ['user' =&gt; $user]);
      }
      public function __construct()
      {
          $this-&gt;middleware('auth');
      }
  
  
      public function store()
      {
          //dd(request()-&gt;all());
          $data = request()-&gt;validate(['pcaption' =&gt; 'required']);
           Auth()-&gt;user()-&gt;posts()-&gt;create($data);
           dd(request()-&gt;all());
  
  }
  }
  </code></pre>
  
  <p>model- </p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class post extends Model
  {
      protected $guarded = [];
  
      public function user()
      {
      return $this-&gt;belongsTo(User::class);
      }
  
  }
  </code></pre>
  
  <p>error from localhost- </p>
  
  <pre><code>Illuminate\Database\QueryException
  SQLSTATE[HY000]: General error: 1364 Field 'post' doesn't have a default value (SQL: insert into `posts` (`pcaption`, `user_id`, `updated_at`, `created_at`) values (bh, 3, 2020-04-17 17:42:53, 2020-04-17 17:42:53))
  </code></pre>
  
  <p>that means the post data didn't save in database. where is my fault</p>