Laravel 8 E-Commerce - Admin Adding Validation to the Form

Поделиться
HTML-код
  • Опубликовано: 16 ноя 2024
  • НаукаНаука

Комментарии • 50

  • @shadrachdameteye
    @shadrachdameteye 3 года назад +4

    best tutorials ever. keep up the good work, God bless you.

  • @two-zero
    @two-zero 3 года назад

    Thanks Surfside Media.

  • @kitky
    @kitky 3 года назад +2

    Hello Sir,
    When I try to update the product by clicking the update button without changing any info of the product, showing the error message below the 'slug' input field:
    "The slug has already been taken."
    Is it suitable to use the below validation code for updating a product?
    'slug' => "required|unique:products"

    • @kitky
      @kitky 3 года назад +3

      I got the idea from a user comment in lesson 38 (i.e. Admin Add Coupons Expiry Date)
      and applied the idea to AdminEditCategoryComponent.php and AdminEditProductComponent.php.
      They work well.
      I share the partial code of the AdminEditProductComponent.php file as below:
      use Illuminate\Validation\Rule;
      protected function category_rules()
      {
      return [
      'name' => 'required',
      'slug' => [
      'required',
      Rule::unique('categories')->ignore($this->category_id)
      ]
      ];
      }
      public function updated($fields)
      {
      $this->validateOnly($fields, $this->category_rules());
      }
      public function updateCategory()
      {
      $this->validate($this->category_rules());
      $category = Category::find($this->category_id);
      $category->name = $this->name;
      $category->slug = $this->slug;
      $category->save();
      session()->flash('message', 'Category has been updated successfullly!');
      }

    • @dadomultimediamusic
      @dadomultimediamusic 3 года назад +1

      @@kitky Thank you so much for sharing!! An excellent way to "abbreviate" those lines.

    • @АлександрБ-в7я
      @АлександрБ-в7я 3 года назад

      ​@@kitky thanks very much

  • @kvkumar9686
    @kvkumar9686 2 года назад

    When I try to update the product by clicking the update button without changing any info of the product, showing the error message below the 'slug' input field:
    "The slug has already been taken."
    Is it suitable to use the below validation code for updating a product?
    'slug' => "required|unique:products"

    • @jorgeluiscch1576
      @jorgeluiscch1576 2 года назад

      'slug' => ['required', Rule::unique('products')->ignore($this->product_id)],

  • @mohammadshahabuddin6944
    @mohammadshahabuddin6944 3 года назад

    when the category is select it just appears for a second and then gone. Can you give me a solution for it?

  • @mdmahmudulislam1849
    @mdmahmudulislam1849 2 года назад

    there is a problem of showing "The slug has already been taken" if I want to edit product details then I have to edit the slug. otherwise the problem is arising each time. anybody please help..........

  • @olegpupkin6892
    @olegpupkin6892 3 года назад

    Respect!!! The best content ever!!!

  • @Xlrb102
    @Xlrb102 3 года назад

    Hi i have some problems in video 6-create product details. in details-component.blade.php i get this error. " Trying to get property 'image' of non-object (View: C:\xampp\htdocs\laravel8ecommerce
    esources\views\livewire\details-component.blade.php) " when i add {{$product->image}}" it occurs. Can anyone help me. Or can anyone give me the details-component.blade.php file code so that i can check the error... Please help!

  • @safayethossain3553
    @safayethossain3553 3 года назад +1

    When I am trying to update category then it shows slug has already been taken? how to solve this problem? pls help me.

    • @АлександрБ-в7я
      @АлександрБ-в7я 3 года назад

      Surfside Media, notice this comment!!! It's important.

    • @webtuts7548
      @webtuts7548 3 года назад +1

      @SafayetHossain.. might be you solve the issue but for others. i am suggesting the following code for validation.
      'slug' => ['required', Rule::unique('products')->ignore($this->product_id,'id')],
      then conditionally pass the value in DB like below.
      $product->sell_price = (!$this->sell_price ? null : $this->sell_price);
      Hope it'll help to solve the issue.

  • @mbali-sahaubenerisse641
    @mbali-sahaubenerisse641 3 года назад

    It gives me great pleasure.
    thank you very much

  • @rastacodbandkoolandthecat4174
    @rastacodbandkoolandthecat4174 3 года назад

    if we just want to update the price or any input exept the newimage it doesnt work ...it just work if we change the image then we can update all others input ...why ???

    • @SurfsideMedia
      @SurfsideMedia  3 года назад +1

      Please remove required validation for newimage

    • @rastacodbandkoolandthecat4174
      @rastacodbandkoolandthecat4174 3 года назад

      @@SurfsideMedia i did it already ,i put "sometimes" instead of "required"...anyway it should be something else , i will find .....thanks for your reply

    • @rastacodbandkoolandthecat4174
      @rastacodbandkoolandthecat4174 3 года назад

      @@SurfsideMedia ok no validation at all for the image in the edit product and it works now..thank you sir

  • @muhammaddanial5075
    @muhammaddanial5075 2 года назад

    |unique:products in edit validation on slug does not work Suggestions

  • @codingdigital4323
    @codingdigital4323 3 года назад

    Sir, Add to cart button not working , I check all the code twice. Please mention places where I can do mistakes and I think something missed in here .wire:click.prevant="store({{$product->id}},'{{$product->name}}',{{$product->regular_price}}).
    Please help me sir!

    • @SurfsideMedia
      @SurfsideMedia  3 года назад +1

      Spelling mistake in prevent, write like this, wire:click.prevent=""

    • @whykk
      @whykk 3 года назад

      I had the same problem, please anyone help me.

    • @codingdigital4323
      @codingdigital4323 3 года назад

      @@SurfsideMedia Sir, Spelling sahi krne ke bad bhi koi ferk nhi pda h. Mention places whee I can do mistakes.

    • @nayeemuzamanhridoy5878
      @nayeemuzamanhridoy5878 3 года назад

      try use style tag after main section, if you use it before main section

  • @muhammaddanial5075
    @muhammaddanial5075 2 года назад

    Very interesting

  • @muhammadsaharhussain4656
    @muhammadsaharhussain4656 3 года назад

    thanks alot sir was looking for that.

  • @justapasserby445
    @justapasserby445 3 года назад

    SQLSTATE[42S22]: Column not found: 1054 Unknown column 'newimage' in 'field list' (SQL: update `products` set `slug` = dafvab, `newimage` = 1618200388.jpg, `products`.`updated_at` = 2021-04-12 04:06:28 where `id` = 4)
    I dont know why I facing this problem........

    • @SurfsideMedia
      @SurfsideMedia  3 года назад

      newimage is not a column name inside the products table, so please recheck your code. Watch my video again and match the code.

  • @justapasserby445
    @justapasserby445 3 года назад

    Creating default object from empty value

  • @parvezhabib4562
    @parvezhabib4562 3 года назад

    why you are not using required="required"?

  • @aviwemusa6109
    @aviwemusa6109 3 года назад

    Thank you!

  • @gadgetkh9408
    @gadgetkh9408 3 года назад +1

    Thank you! I'm the first here! hahha

  • @fatemen3764
    @fatemen3764 3 года назад +1

    tnx

  • @mhmdfaiz5151
    @mhmdfaiz5151 3 года назад

    please make a verible products
    and muti vender system

  • @codingdigital4323
    @codingdigital4323 3 года назад

    Sir , pagination CSS ka code bhi post kr dijiye please

    • @SurfsideMedia
      @SurfsideMedia  3 года назад

      github.com/surfsidemedia/Laravel-8-E-Commerce-Pages

  • @jorgeluiscch1576
    @jorgeluiscch1576 2 года назад

    solution for slug error: The slug has already taken
    'slug' => ['required', Rule::unique('products')->ignore($this->product_id)],

    • @bcsenior162
      @bcsenior162 2 года назад

      don't work

    • @jorgeluiscch1576
      @jorgeluiscch1576 2 года назад

      @@bcsenior162 laravel 9

    • @bcsenior162
      @bcsenior162 2 года назад

      @@jorgeluiscch1576 I use laravel 9, tried of everything and nothing, in the crud categories is the same mistake

  • @devlaravel8871
    @devlaravel8871 3 года назад

    Duplicate code :) D.R.Y : Don't Repeat Yourself !