I'm working on creating code with a nice balance between concise and readable. How would you improve this Laravel code block to make it more compact and readable?
public function canEdit(Request $request)
{
$canEdit = Permission::canEdit(
$request->user(),
$request->siteModel
);
$statusCode = ($canEdit) ? 200 : 403;
return Response()
->json([
'can-edit' => $canEdit
], $statusCode);
}
Really looking forward for some comments / suggestions.
$payload['can-edit'] = ...
and removing the parentheses from$statusCode
, I don't think there is anything to change. I mean, even$payload['can-edit']
is a subject decision to declutter the->json()
parameters -- which I probably wouldn't do personally. \$\endgroup\$