What is $fillable & $guarded | Laravel 10 Tutorial #19

Поделиться
HTML-код
  • Опубликовано: 22 июл 2023
  • Laravel 10 Tutorial
    On this episode we cover what $fillable is, why we need it and what is the reason behind using it. We also cover potential security risk we may have in our applications.
    Documentation mentioned in the video :
    laravel.com/docs/10.x/control...
    Playlist of Laravel 10 Tutorial Course :
    • Laravel 10 Beginners C...
    What is Laravel :
    Laravel is a free and open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model-view-controller architectural pattern and based on Symfony.
    en.wikipedia.org/wiki/Laravel
    If you have any questions or problems please leave a comment.
    Laravel Blade
    Laravel crash course
    Laravel Database and crud tutorial
    Laravel crud tutorial
    Laravel fillable and guarded explained

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

  • @ousssika5359
    @ousssika5359 9 месяцев назад +3

    keep up the good work , you are a big help

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

    very nice tip. Less code is more readable.

  • @amirirani1097
    @amirirani1097 11 месяцев назад +1

    Hi, thank you so much for this videos

    • @yelocode
      @yelocode  11 месяцев назад +1

      Glad you like them!. Thank you for watching

  • @jaylylz1921
    @jaylylz1921 8 месяцев назад

    in the store function, i ve used the idea::create(request()->all()),data is being inserted into the database but its blank ,below is my code in the ideacontroller
    public function store(){
    request()->validate([
    'idea'=>'required|min:5|max:300'
    ]);
    //dd(request()->all());
    $idea= idea::create(request()->all());

    return redirect()->route('dashboard')->with('success','idea was created successfully');

    }.
    what could be the problem?

    • @yelocode
      @yelocode  8 месяцев назад

      Is your table using "idea" or "content" as the name of the column? in the video I'm using content.
      if it's content, then you need the validation code to be like this :
      request()->validate([
      'content'=>'required|min:5|max:300'
      ]);
      also make sure you set fillable on your Idea.php model file
      protected $fillable = [
      'content',
      ];
      The full code for this episode is also available on github, if you like to compare your code with mine.
      github.com/yelocode/ideas/tree/d062d99ad7aa1b30653ce01c88819634aa5da568

    • @jaylylz1921
      @jaylylz1921 8 месяцев назад

      I ve changed it to content and its now working.keep up the good work.thanks@@yelocode

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

      My previous code was working fine until I used the $validated variable.It doesn't create a new card when I share(it doesn't give an error too). I used 'idea' for my column. I don't know what the issue and chatgpt isn't helping