Lets assume I have a helper
called engine
.
if( ! function_exists('engine') )
{
function engine($user_id_1, $user_id_2, $league, $log = true)
{
/*
* variables
*/
$questionsLevel = 1;
$user1 = \App\User::where('id', $user_id_1)->first();
$user2 = \App\User::where('id', $user_id_2)->first();
$league = \App\Models\League::where('id', $league)->first();
$users = $league->all_users;
/*
* check if users joined to league correctly
*/
$user1_ok = $user2_ok = false;
foreach($users as $user)
{
if( $user->id == $user_id_1 )
{
$user1_ok = true;
}
if( $user->id == $user_id_2)
{
$user2_ok = true;
}
$check_users = [
$user1_ok,
$user2_ok
];
}
if( in_array(false, $check_users) )
{
return [
'errcode' => 404,
'errmessage' => 'one ro both user/s did not joined to league'
];
}
//DO SOME STUFF
}//function engine
}
As you know, I can write a controller
to do same.
Does anyone know Which is faster based on Laravel architecture? and how can I test performance in both cases?
I'm using laravel 5.7.*
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Vr1Crv
via IFTTT
Aucun commentaire:
Enregistrer un commentaire