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
keep up the good work , you are a big help
very nice tip. Less code is more readable.
Hi, thank you so much for this videos
Glad you like them!. Thank you for watching
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?
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
I ve changed it to content and its now working.keep up the good work.thanks@@yelocode
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