9 months ago

How can i avoid image required in edit form if image exist in laravel?

Posted 9 months ago by raviawasti

I am adding and editing a user with same function (Store), when ever i add a user it asks me image is required but whenever i edit a user which have image it also ask me image is required and i want if a image is already present it wont ask me

I am saving like this

public function store(Request $request) { $rule=array( 'name' => 'required',

           'image' => 'required',
                $user = User::findOrFail($inputs['id']);
                $user = new User;

    $user_image = $request->file('image');

        $tmpFilePath = 'uploads/candidates/';

        $hardPath =  str_slug($inputs['name'], '-').'-'.md5(time());
        $img = Image::make($user_image);
        $img->fit(300, 300)->save($tmpFilePath.$hardPath.'-b.jpg');
        $user->image = $tmpFilePath.$hardPath.'-b.jpg';

          $user->name = $inputs['name'];


Please sign in or create an account to participate in this conversation.