Skip to content

Instantly share code, notes, and snippets.

@szabomikierno
Last active August 18, 2025 12:10
Show Gist options
  • Select an option

  • Save szabomikierno/52ac2389c0cf527106aa28411f2edfa0 to your computer and use it in GitHub Desktop.

Select an option

Save szabomikierno/52ac2389c0cf527106aa28411f2edfa0 to your computer and use it in GitHub Desktop.
1. How would you structure a large Laravel application? Describe your approach to organizing code
beyond the default MVC structure.
2. Would you keep unused code in the codebase if you know you may need it in the future but not
sure yet?
3. Imagine the site started loading much slower than usual, what would be your first steps to debug
the issue?
4. What are some of the differences between Vue 2 and Vue 3?
5. What are the differences between feature(integration) and Unit tests?
6. What changes / improvements would you do in the following code snippet?
<?php
namespace App\Http\Controllers;
use App\Http\Resources\ArticleResource;
use App\Models\Article;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ArticleController extends Controller
{
/**
* Display the specified resource.
*
* @return \Illuminate\Http\JsonResponse
*/
public function show($id)
{
if (!\Auth::check()) {
return response()->json(['error' => 'Unauthorized']);
}
$ip = request()->getClientIp();
$userLimit = DB::table('view_limits')
->select(['ip', 'usage_count'])
->where('ip', $ip)
->first();
if (!$userLimit) {
// First viewing the article.
DB::table('view_limits')
->insert([
'ip' => $ip,
'created_at' => now(),
]);
} elseif ($userLimit->usage_count >= 3) {
// Out of free usage.
return response()->json(['error' => 'Unauthorized']);
} else {
// Count usage.
DB::table('view_limits')
->select(['ip', 'usage_count'])
->where('ip', $ip)
->increment('usage_count', 1, [
'updated_at' => now()
]);
}
$article = Article::where('id', $id)->first();
$ratings = $article->ratings;
$articleRating = 0;
foreach ($ratings as $rating) {
$rating->load('user');
if (!$rating->user->is_banned) {
$articleRating += $rating->rating;
}
}
$article->avg_rating = $articleRating / count($ratings);
return response()->json($article);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment