title: Call to a member function getClientOriginalName() on array laravel
body: <p>I'm trying to post an image from a one to many relationship while also doing the CRUD (create part), but I am having some trouble doing it. I keep on getting this error<code>,Call to a member function getClientOriginalName() on array</code>, whenever I try to use associate to define the relationship together with user_info with user_image table. So what should I do?</p>
  
  <p>Here are my codes:
  createController:</p>
  
  <pre><code>public function create1(){
  
      return view('create1');
  }
  
  public function store1(Request $request){
       $this-&gt;validate($request, [
          'input_img' =&gt; 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
      ]);
  
   $user_info = Session::get('data');
        $UserImage = new UserImage($request-&gt;input()) ;
  
  
       if($file = $request-&gt;hasFile('input_img')) {
        $file = array();
  
  
  
          $fileName = $file-&gt;getClientOriginalName() ;
          $destinationPath = public_path().'/images' ;
          $file-&gt;move($destinationPath,$fileName);
          $UserImage-&gt;userImage = $fileName ;
          $UserImage = UserImage::create(['file' =&gt; $request-&gt;file('input_img')]);
          $UserImage-&gt;user_infos()-&gt;associate($user_info);
      }
  
      $UserImage-&gt;save() ;
  
      return redirect('/home');
  }
  </code></pre>
  
  <p>HomeController(this is where I print out my information)</p>
  
  <pre><code>public function getInfo($id) {
  
    $data = personal_info::where('id',$id)-&gt;get();
        $data3=UserImage::where('user_id',$id)-&gt;get();
   return view('test',compact('data','data3'));
  </code></pre>
  
  <p>blade.php (how I show the image in view)</p>
  
  <pre><code> @foreach ($data3 as $object9)
   &lt;img width="100" height="100" src="{!! $object9-&gt;signature !!}"&gt;
      @endforeach
  </code></pre>
  
  <p>UserImage model(in table I used binary format to store in DB)</p>
  
  <pre><code>    class UserImage extends Eloquent
      {
              protected $fillable = array('userImage','user_id');
          public function user_infos() {
              return $this-&gt;belongsTo('App\user_info', 'user_id', 'id');
          }
  
  class user_info extends Eloquent
  {
      protected $fillable = array('Email', 'Name');
      protected $table = user_infos';
      protected $primaryKey = 'id';
          public function UserImages() {
          return $this-&gt;hasOne('App\UserImage','user_id');
      }
  }
  </code></pre>
  
  <p>create1.blade.php(this is how I upload the image)</p>
  
  <pre><code>     &lt;form class="form-horizontal" method="post" action="{{ url('/userUpload')}}" enctype="multipart/form-data"&gt;
  
                          {{  csrf_field()  }}
  
  
  &lt;div class="form-group"&gt;
      &lt;label for="imageInput" class="control-label col-sm-3"&gt;Upload Image&lt;/label&gt;
              &lt;div class="col-sm-9"&gt;
              &lt;input data-preview="#preview" name="input_img" type="file" id="imageInput"&gt;
              &lt;img class="col-sm-6" id="preview"  src="" &gt;&lt;/img&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
   &lt;div class="form-group"&gt;
              &lt;div class="col-md-6-offset-2"&gt;
                &lt;input type="submit" class="btn btn-primary" value="Save"&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            &lt;/form&gt;
  </code></pre>