Laravel Crud best practices points should be maintained
.use resources
.use route name to form action and anchor tag
.current user data , should take from controller using Auth class
.form must be validated with custom form Request
.we add a Request before submit form data to database because
each Request check data type of input field values are same or not to database field
after passed Request data will go to database to store.
set error messages in blade template which input field not passed in Request's exam.
.After passed Request's exam , we will check user is authorized or not with policy
.we should keep Controller methods thin , and should keep our business logic outside of controller
we will use Service Class to keep Controller methods thin. we can also use Action pattern to keep Controller methods slim.
create app/Services directory inside this folder create Class . let OfferService and declare a public method named store
Service Class methods make code reusable , we can achieve dry principle with Service Class.
Our Controller Class store method recieve $request , but Service Class store method will recieve array , so we must pass a array data to Service Class method.
Validation request $request->validated() method will return passed $request data to array $data
.tom select jquery plugin to select tags , search options etc
.