TechHire NepalConnecting Talent, Building Careers
Find JobsCompaniesCourses
Find Talents
Sign inGet Started →
Find JobsCompaniesCourses
Find Talents
Sign inGet StartedHire Talent
TechHire Nepal

Nepal's #1 tech job platform. Connecting top talent with the best companies.

For Job Seekers

  • Browse Jobs
  • Companies
  • Tech Salaries
  • Interview Prep
  • Courses
  • Career Advice

For Employers

  • Post a Job
  • Talent Search
  • Pricing
  • Employer Dashboard

Company

  • About
  • Blog
  • Careers
  • Contact

Resources

  • Training Institutes
  • Projects
  • Tutorials
  • Roadmaps
  • Notes
  • Open Sources

Community

  • Discussions
  • Tech Events
  • Hackathons
  • Developer Meetups
  • Tech News

More

  • Help & Support
  • Salary Tax Calculator
  • Company Registration Guide
  • Labour Act

Stay in the loop

A weekly digest of the best tech articles and jobs in Nepal.

© 2026 TechHire Nepal. All rights reserved.

Privacy PolicyTerms of ServiceCookie Policy
HomeInterview PrepQuestion bank
Question bank

Interview Questions, Answered Clearly

Filter by the role you are applying for, open a question, and practise explaining the answer out loud. Mark it practised when you can.

Type
TechnicalCodingHR / BehaviouralAll types
Role
All rolesFrontend DeveloperBackend DeveloperFull-Stack DeveloperMobile Developer
Topic
All topicsJavaScript10React7HTML & CSS7PHP & Laravel9SQL & Databases6HTTP & REST APIs6Git4OOP & Design4Flutter5React Native5Arrays & Hashing4Strings3Searching & Stacks2Logic Basics1HR Basics9Behavioural (STAR)3
Level
AnyEasyMediumHard

7 questions

  • Why they ask this: The starting point for any Laravel interview; it shows you know where code belongs.

    Answer

    MVC (Model–View–Controller) separates an application into three parts:

    • Model: data and business rules. In Laravel these are Eloquent models (app/Models), each mapped to a database table.
    • View: what the user sees. In Laravel these are Blade templates (resources/views), or JSON from API Resources in an API.
    • Controller: receives the request, calls models or services, and returns a response (app/Http/Controllers).

    The flow: route (routes/web.php or routes/api.php) → middleware → controller → model → view or JSON response.

    php
    Route::get('/jobs/{job}', [JobController::class, 'show']);
    
    class JobController extends Controller
    
    
    
    
    
    
    Open full page
  • Why they ask this: The most common Eloquent performance bug; it shows you think about the queries your code runs.

    Answer

    The N+1 problem happens when you load a list (1 query) and then run one more query per item to load a relationship (N queries).

    php
    // 1 query for posts + 1 query per post for its author = N+1
    $posts = Post::all();
    foreach ($posts as $post) {
        echo $post->author->name;
    }

    Fix it with eager loading, which loads the relationship for all rows in one extra query:

    php
    Open full page
  • Why they ask this: Middleware is how cross-cutting concerns like auth are handled; it shows you understand the request lifecycle.

    Answer

    Open full page
  • Why they ask this: Every team project uses migrations; this checks you can work safely with a shared database schema.

    Answer

    Open full page
  • Why they ask this: Shows you understand the core of the framework and can write testable, loosely coupled code.

    Answer

    Open full page
  • Why they ask this: Security basics are non-negotiable for backend roles.

    Answer

    Open full page
  • Why they ask this: Most Nepali startups build an API for a React or mobile frontend, so you must know which auth fits.

    Answer

    Open full page
{
public function show(Job $job) // route model binding
{
return view('jobs.show', ['job' => $job]);
}
}

In bigger apps, keep controllers thin and move business logic into service or action classes.

$posts = Post::with('author')->get();           // 2 queries in total
$posts = Post::with(['author', 'comments'])->get();
$count = Post::withCount('comments')->get();     // comments_count without loading them

Find N+1 problems with Laravel Debugbar or Telescope, or make them fail loudly in development with Model::preventLazyLoading(! app()->isProduction());.

Middleware is a layer that every matching HTTP request passes through before it reaches the controller, and the response passes back through after. Each middleware can let the request continue ($next($request)), change it, or stop it early.

Common uses:

  • Authentication: auth / auth:sanctum reject guests.
  • Authorisation and roles: for example only admins can reach /admin.
  • Rate limiting: throttle:60,1.
  • CORS, CSRF protection, logging, setting the locale.
php
class EnsureUserIsAdmin
{
    public function handle(Request $request, Closure $next): Response
    {
        if (! $request->user()?->is_admin) {
            abort(403);
        }

        return $next($request);
    }
}

Route::middleware(['auth', EnsureUserIsAdmin::class])->group(function () {
    Route::get('/admin', AdminDashboardController::class);
});

Migrations are version control for the database schema. Each migration is a PHP class with an up() method that makes a change and a down() method that reverses it.

php
Schema::create('jobs', function (Blueprint $table) {
    $table->id();
    $table->foreignId('company_id')->constrained()->cascadeOnDelete();
    $table->string('title');
    $table->unsignedInteger('salary_min')->nullable();
    $table->timestamps();
});

Useful commands: php artisan make:migration, migrate, migrate:rollback, migrate:status.

Why they are useful:

  • Every developer and server gets the same schema by running php artisan migrate.
  • Changes are reviewed in Git like any other code.
  • Changes can be rolled back.

Never edit a migration that has already run in production. Create a new one instead.

Dependency injection (DI) means a class receives the objects it needs (its dependencies) from outside, usually through the constructor, instead of creating them itself. This makes code easier to test and swap.

The service container is Laravel's tool for building objects and their dependencies. It uses reflection on type hints to auto-resolve concrete classes, so this works with no configuration:

php
class InvoiceController
{
    public function __construct(private InvoiceService $invoices) {}
}

For interfaces, you tell the container which implementation to use, usually in a service provider:

php
$this->app->bind(PaymentGateway::class, KhaltiGateway::class);
$this->app->singleton(ExchangeRates::class, fn () => new ExchangeRates(config('services.nrb.url')));

Benefits:

  • In tests you can replace an implementation with a fake: $this->app->instance(PaymentGateway::class, new FakeGateway).
  • Switching from eSewa to Khalti only changes one binding, not every class that uses the gateway.
  • SQL injection: the query builder and Eloquent use PDO parameter binding, so user input is never pasted into SQL. Stay safe with raw SQL by passing bindings: DB::select('select * from users where email = ?', [$email]). Never concatenate input into whereRaw.
  • XSS (cross-site scripting): Blade's {{ $value }} escapes output with htmlspecialchars. Only use {!! $value !!} for HTML you have sanitised.
  • CSRF (cross-site request forgery): web routes check a CSRF token on POST, PUT, PATCH and DELETE requests. Add @csrf inside Blade forms. Token-authenticated APIs (for example Sanctum tokens) are not exposed to CSRF in the same way.

Also mention: mass assignment protection with $fillable, validation with Form Requests, hashing passwords with Hash::make (bcrypt or argon2), and authorisation with policies.

  • Session-based: after login the server stores the session (in files, the database or Redis) and sends the browser a session cookie. Each request sends the cookie and the server looks up the session. This is stateful and works best for same-domain web apps. Protect it with CSRF tokens.
  • Token-based: after login the server returns a token that the client sends in the Authorization: Bearer <token> header. This suits mobile apps and third-party clients.
    • Opaque tokens (such as Laravel Sanctum personal access tokens) are stored in the database and are easy to revoke.
    • JWTs are signed and self-contained, so the server does not need a lookup, but they are harder to revoke before they expire.

In Laravel, Sanctum handles both: cookie-based SPA authentication for your own frontend and API tokens for mobile apps. Never store tokens where scripts can read them (such as localStorage) if you can use an httpOnly cookie instead.