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?
]);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire