Support the ongoing development of Laravel.io →
Eloquent Architecture
Last updated 2 years ago.
0

As long as it's readable to you and you're not going against any coding styles already set by anyone you're working with then it's fine.

I generally follow PSR-2 and use a beautiy formatter for old code I work with.

Last updated 2 years ago.
0

You can shorten your controller by using one return with a dynamic array or using ternary.

Ternary

return Response::json(array('result' => $sql ? 'success' : 'fail'));

Array

$response = ['result' => 'fail'];

if ($sql)
    $response = ['result' => 'success'];

return Response::json($response);
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

root root Joined 2 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.