zeyadsaleh / Laravel_BlogApp

0 stars 0 forks source link

use request->only() or validated, instead of writing request attributes one by one #1

Open mhmodmonim opened 4 years ago

mhmodmonim commented 4 years ago

check this issue https://github.com/AhmedGalaldev/laravellabes/issues/3

https://github.com/zeyadsaleh/Laravel_BlogApp/blob/a83f4cd4e56020ce84954bf6840354884fbfdb5c/app/Http/Controllers/PostController.php#L57-L62

zeyadsaleh commented 4 years ago

i dont understand the issue well, would you please clarify it more?

mhmodmonim commented 4 years ago

@zeyadsaleh you don't have to write every single attribute in create function, if you used request()->only(['title', 'desc', ....]) or request()->validated() it would save you time if the attributes number increases

of course your solution is working fine, but this is a best practice and also make your lines always less

hope you got it,