How to Define Relationships in FilamentPHP - FilamentPHP for Beginners

Поделиться
HTML-код
  • Опубликовано: 10 июл 2024
  • Special thanks to Hostinger for sponsoring this video. Hostinger is an incredible web hosting provider where you can set up shared hosting, cloud hosting, VPS hosting, email hosting, and SSL certificates. Hostinger has made a name for itself due to its fast load times, simplicity, free domains, and powerful servers. Here’s my affiliate link for 10% off: www.hostinger.com/codewithdary
    In this tutorial, we will explore how to define relationships in FilamentPHP. We'll start by looking at the BrandResource and Brand model, and how to create a one-to-many relationship between products and brands. Then, we'll move on to the ProductResource and Product model, and learn how to create a many-to-one relationship with brands and a many-to-many relationship with categories. Next, we'll cover the OrderResource and Order model, and how to handle a situation where a form field's value depends on another field's value. Finally, we'll wrap up by examining the CategoryResource and Category model, and how to create a many-to-many relationship with products.
    📚 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
    00:41 - Products Relationship (BelongsToMany)
    05:00 - Brands Relationships (HasMany)
    16:00 - Orders Relationship (BelongsTo & HasMany)
    24:24 - Categories Relationship (BelongsToMany)
    26:56 - Outro
    #laravel #filamentphp #hostinger #codewithdary

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

  • @MG-wx8yx
    @MG-wx8yx 6 дней назад

    This video has tones of useful information. Thanks so much for your effort, you are helping so much to us juniors. I have one request though so I had to edit this comment, if you can make a video and provide the link show me where it's done like this: I want to add additional information in the pivot table of the many-to-many relationship (the table which contains the FK of for example students and guardians since a student can have multiple guardians and a guardian can have multiple students as his/her dependants. This additional info/column can be anything, in my case it is the actual relationship between them, for example; "Father", "Mother" etc so that at any time when displaying the student info, users can instantly know how the student is related to the guardian and vice versa.
    Thanks in advance.

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

    but where the products inserted to an order are saved ?

  • @tommytreats
    @tommytreats 3 месяца назад

    Would love to see a video on tracking inventory of the products based on the sales.

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

    Thanks

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

    Respect

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

    thank pro

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

    Thank you Dary, Would you please focus on website pages as well, I mean template and some simple pages like products, Cart, ...

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

      Thank you for your suggestions!

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

    Nice video.. Thank you.
    I am getting an error: 1364 Field 'unit_price' doesn't have a default value
    Below is the code in the form as you have added:
    Forms\Components\TextInput::make('unit_price')
    ->label('Unit Price')
    ->required()
    ->dehydrated()
    ->numeric()
    ->disabled(),
    Its because of disabled (which doesnt submit the value to database) : you quoted this but please let us know how to fix as well.
    Great videos..

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

      Thank you. I haven't made any changes I guess, here is the source code: github.com/codewithdary/hostinger-filament

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

    Thanks boss Can You Make filamentphp page video

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

      What do you mean?

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

      filamentphp custom page Boss @@codewithdary

  • @ryanm.122
    @ryanm.122 2 месяца назад

    @codewithdary Is there a way to customize the name/title that is displayed for a relationship? For example, @1:40 Select::make('brand_id')->relationship('brand', 'name'), I want to do something for Select::make('user_id')->relationship('user', 'full_name') where full name is an accessor that concatenates first name and last name... In nova, they have a title() function you can use to override the displayed value
    /**
    * Get the value that should be displayed to represent the resource.
    *
    * @return string
    */
    public function title()
    {
    return $this->first_name . " " . $this->last_name;
    }