Defining Our Migrations, Models & Relationships for FilamentPHP - FilamentPHP for Beginners

Поделиться
HTML-код
  • Опубликовано: 10 июл 2024
  • In this tutorial, we're going to walk you through the process of building the backend for an ecommerce site using FilamentPHP. The focus of this episode is on migrations and models, and we'll explain how to create them in Laravel before using them in FilamentPHP. The tutorial covers the creation of migrations and models for categories, brands, customers, products, and orders, as well as the relationships between them. We'll also include tips on using the fillable property over the guarded property and the importance of defining relationships between models. By the end of the tutorial, you'll have a solid understanding of how to create the necessary migrations and models for a FilamentPHP ecommerce site.
    📚 New Udemy Course
    If you're looking to level up your Laravel skills? My new course "Mastering Laravel 10 Query Builder, Eloquent & Relationships" is the perfect opportunity. Learn the essential tools and techniques for building robust and scalable web applications with Laravel: www.udemy.com/course/masterin...
    💌 Newsletter
    Sign up for my free weekly email newsletter: newsletter.codewithdary.com/
    🔥 Resources
    - Twitter: / codewithdary
    - Instagram: / codewithdary
    - Blog: blog.codewithdary.com/
    - Patreon: www.patreon.com/user?u=30307830
    - GitHub: github.com/codewithdary
    - TikTok: / codewithdary
    ⌛Timestamps
    00:00 - Introduction
    01:05 - Creating Models & Migrations
    02:16 - Defining our Migrations
    12:59 - Defining the fillable property
    16:03 - Defining Relationships
    24:04 - Outro
    #laravel #filamentphp #hostinger #codewithdary

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

  • @SD-pf4fw
    @SD-pf4fw 10 месяцев назад +1

    This is so well organised and detailed, great tutorial keep it going will watch the whole filament series

  • @yuliarahma1300
    @yuliarahma1300 10 месяцев назад +2

    very nice, keep going please, more about filament v3, love it.

  • @giorgiofranchini77
    @giorgiofranchini77 6 месяцев назад +1

    Dary you are the best! Thanks

  • @kmnurunnabi5849
    @kmnurunnabi5849 10 месяцев назад +2

    You are very talented. Keep going on

    • @codewithdary
      @codewithdary  10 месяцев назад +1

      Thank you so much, I truly appreciate it

  • @HamadAbdulla_7
    @HamadAbdulla_7 10 месяцев назад

    Awesome! Thanks

  • @GergelyCsermely
    @GergelyCsermely 10 месяцев назад +1

    Thanks

  • @wmafendi
    @wmafendi 9 месяцев назад +1

    big thanks

  • @vugarkhalil
    @vugarkhalil 10 месяцев назад +1

    Respect ❤

  • @mounirammi
    @mounirammi Месяц назад

    Hi. Whe i'm getting this error when trying to access the orders page !
    SQLSTATE[42S22]: Column not found: 1054 Unknown column 'orders.deleted_at' in 'where clause' (Connection: mysql, SQL: select count(*) as aggregate from `orders` where `orders`.`deleted_at` is null)

  • @guyrandalf711
    @guyrandalf711 10 месяцев назад

    Great! Please can you add links to the previous tutorials?

    • @codewithdary
      @codewithdary  10 месяцев назад +1

      You just need to click on my channel name and you will find them. But here's a link to the playlist: ruclips.net/p/PLFHz2csJcgk_M6tg-f589Myy-lbLyACKi

  • @theJohnCode
    @theJohnCode 10 месяцев назад +1

  • @user-ru8np7mf1c
    @user-ru8np7mf1c 10 месяцев назад +1

    Hi there,
    Quick question
    Why not to use conventional many-to-many relationship between Order and Product?

    • @codewithdary
      @codewithdary  10 месяцев назад

      What is a convential many-to-many relationship?

    • @user-ru8np7mf1c
      @user-ru8np7mf1c 10 месяцев назад

      @@codewithdary
      Using belongsToMany() on both models and making a pivot table/model I assume.

  • @tintrung3785
    @tintrung3785 4 месяца назад

    "SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'categories' already exists (Connection: mysql, SQL: create table `categories` (`id` bigint unsigned not null auto_increment primary key, `name` varchar(255) not null, `slug` varchar(255) not null, `is_visible` tinyint(1) not null default '0', `description` longtext null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')" Please help me fix this when I use the PHP artisan migrate command !

    • @kenjivafe
      @kenjivafe 4 месяца назад

      php artisan migrate:fresh

  • @peterf983
    @peterf983 10 месяцев назад +1

    Someone might says that storing Product's price in table column as numeric is bad idea. Isn't it better to store Product's price as integer and convert it to decimal in view/controller code?

    • @codewithdary
      @codewithdary  10 месяцев назад

      Honestly, I have never heard that before. Storing a product's price as an integer and converting it to decimal in the view/controller code can work, but it is generally not a good idea. This approach can make it more difficult to perform calculations and comparisons on the price data within the database itself. It is generally recommended to store prices as a decimal data type in the database to ensure accuracy and consistency.

    • @pasizdobrekuce
      @pasizdobrekuce 10 месяцев назад +2

      @@codewithdary we store it in cents at my work, and convert it to human friendly values for frontend. Not a good idea indeed. Hard to maintain and reason about.

  • @nazar87ali
    @nazar87ali 10 месяцев назад +1

    and how can add more Customize in app

  • @sandeepbhambre
    @sandeepbhambre 10 месяцев назад +1

    In this video you deleted $table->timestamps(); from the "create_category_product_table" migration. But, while defining the relationship, you added withTimestamps(). How is it possible?

    • @codewithdary
      @codewithdary  10 месяцев назад

      The withTimestamps() method on a many-to-many relationship in Laravel automatically updates the created_at and updated_at timestamps on the pivot table that joins the two related models. The timestamps on the pivot table will be managed by the withTimestamps() method on the relationship definition :)

  • @foantje5857
    @foantje5857 9 месяцев назад +1

    why u make the pivot tables and models isn't that being made automatically?

    • @codewithdary
      @codewithdary  9 месяцев назад

      Not from my understanding, I've never seen it being generated automatically. Can you explain how?

    • @foantje5857
      @foantje5857 9 месяцев назад

      @@codewithdary well when u define the foreign key and migrate fresh u automatically get the pivot table. I don’t make pivot models don’t see the point

    • @codewithdary
      @codewithdary  9 месяцев назад

      @@foantje5857 how does Laravel knows what relationship it is when you don’t define it in your migration? 😅

    • @foantje5857
      @foantje5857 9 месяцев назад

      @@codewithdary thats not what i said u define it in the migration i just don’t make a pivot model and i don’t make a seperate pivot migration

    • @codewithdary
      @codewithdary  9 месяцев назад

      @@foantje5857 you said why u make the pivot tables my friend :)

  • @GreatCaleb
    @GreatCaleb 10 месяцев назад +2

    I think the relationship in the Brand model should be name products instead of brands

    • @codewithdary
      @codewithdary  10 месяцев назад +1

      You are completely right....

    • @GreatCaleb
      @GreatCaleb 10 месяцев назад +1

      @@codewithdary thank you for all your contents they are very helpful to us junior programmer

  • @nazar87ali
    @nazar87ali 10 месяцев назад +1

    pleas in next video explain how can add another language to app

    • @codewithdary
      @codewithdary  10 месяцев назад +1

      That won't be added in the first FilamentPHP series on my channel. But definitely a topic I will cover in the future :)