I have status const in the model and I am storing the status as integer in the table.
CONST STATUS_DONE = 0;
CONST STATUS_NEW = 1;
CONST STATUS_PROCESSING = 2;
When user make an API request,they pass in the string status instead of integer. Example Request Class:
public function rules()
{
return [
'name' => 'required',
'status' => 'required|in:done,new,processing',
];
}
Problem is I am trying to figure out what the good approach to convert string status to int to be stored in table, eg:
Task::create([
'name' => $request->name,
'status' => // convert to int?
]);
'status' => 'required|integer|in:done,new,processing'(int)$request->namecreate()method need to be converted to int.they pass in the string status instead of integerdo you mean '0', '1', '2' OR 'Done', 'New', 'Processing'?