title: upload image in laravel 8 - API
body: <p>I want to upload image for my posts and have polymorphism relation one to one (because I have other tables and they need image too ) between posts and images</p>
  <p>And when I want to send request and store the image in database , I get this error:</p>
  <p><code>BadMethodCallException: Call to undefined method App\Models\Image::move() </code></p>
  <p>I'm creating an API so :</p>
  <p>My postman :</p>
  <p><a href="https://i.stack.imgur.com/cXRlh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cXRlh.png" alt="enter image description here" /></a></p>
  <p>My relations :</p>
  <p><code>Image model</code> :</p>
  <pre><code>class Image extends Model
  {
      use HasFactory;
  
      protected $fillable = [
          'image'
      ];
  
      public function imageable(){
          return $this-&gt;morphTo();
      }
  
  }
  
  </code></pre>
  <p><code>Post model</code> :</p>
  <pre><code>
  class Post extends Model
  {
      use HasFactory;
      use \Conner\Tagging\Taggable;
  
  
      protected $fillable = [
          'user_id' ,
          'category_id' ,
          'title' ,
          'body' ,
          'study_time',
          'likes',
          'status',
          'tags',
      ];
  
      public function image(){
          return $this-&gt;morphOne(Image::class , 'imageable');
      }
  
  }
  
  </code></pre>
  <p>And the <code>PostController</code> , <code>store()</code> method :</p>
  <pre><code>    public function store(Request $request )
      {
          $data = $request-&gt;all();
  
          $validator = Validator::make($data, [
              'user_id'=&gt;'required',
              'category_id'=&gt;'required',
              'title' =&gt; 'required|max:150|unique:posts',
              'body' =&gt; 'required',
              'study_time'=&gt;'required',
              'tags'=&gt;'nullable|string',
          ]);
  
          if ($validator-&gt;fails()) {
              return response()-&gt;json(['error' =&gt; $validator-&gt;errors(), 'error']);
          }
  
          //separate tags
          $tags = explode(&quot;,&quot;, $request-&gt;tags);
  
  
          $image = new Image;
          $getImage = $request-&gt;file('image');
          $imageName = time().'.'.$getImage-&gt;extension();
          $image-&gt;move(public_path('images'), $imageName);
  
  
  
          $post = Post::create($data);
  
          $post-&gt;image()-&gt;save($image);
  
          //save tags
          $post-&gt;tag($tags);
  
  
          return response()-&gt;json([
          &quot;success&quot; =&gt; true,
          &quot;message&quot; =&gt; &quot;successfull&quot;,
          &quot;data&quot; =&gt; $post
          ]);
      }
  
  
  </code></pre>
  <p>Where is my mistake?</p>