php - How To seperate Requests from controller for making code cleaner
in some cases in my controller i have to recive like 12 params from my client side and i have to like below for each of variables :
$something = $request->get('something');
this makes like 100 line of code extra in my controller for like 10 methods and i want to make my controller short and readable so i want to know if there is any way to seperate this code form my controller and recive them in my controller and use them in my method so my code will become cleaner and more readble
Answer
Solution:
Create Service classes to put logic in it:
Then you use it in your controller like below:
Answer
Solution:
You can get your table column and then check if the request has that column name and if so add the data to database. The first step is putting this in your model
Model
And then in the controller method where you save the data:
Controller