wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PHẦN 1 – ROUTE & CONTROLLER; PHẦN 2 – MIDDLEWARE

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

PHẦN 1 – ROUTE & CONTROLLER: Route::get('/home', ...) dùng để?

a)

Tạo route GET

b)

Tạo route POST

c)

Tạo controller

d)

Tạo middleware

2.

PHẦN 1 – ROUTE & CONTROLLER: Route có name('dashboard') dùng để?

a)

Đặt URL

b)

Đặt tên route

c)

Tạo view

d)

Tạo controller

3.

PHẦN 1 – ROUTE & CONTROLLER: Route::post('/add', ...) dùng để xử lý gì?

a)

Nhận dữ liệu form gửi lên

b)

Lấy dữ liệu

c)

Tạo session

d)

Redirect

4.

PHẦN 1 – ROUTE & CONTROLLER: Khi muốn gọi controller HomeController@index, cú pháp đúng?

a)

Route::get('/', 'HomeController@index');

b)

Route::get('/', '@HomeController@index');

c)

Route::call('HomeController@index');

d)

Route::use('HomeController');

5.

PHẦN 1 – ROUTE & CONTROLLER: File định nghĩa route web nằm ở:

a)

routes/web.php

b)

routes/api.php

c)

app/routes/web.php

d)

config/routes.php

6.

PHẦN 1 – ROUTE & CONTROLLER: Để tạo controller mới:

a)

php artisan make:controller

b)

php artisan new:controller

c)

php artisan controller:create

d)

php artisan controller:new

7.

PHẦN 1 – ROUTE & CONTROLLER: Trong controller, method trả về view có dạng:

a)

return show('view')

b)

return view('view')

c)

return html('view')

d)

return display('view')

8.

PHẦN 1 – ROUTE & CONTROLLER: Để truyền biến sang view, dùng:

a)

return view('a', ['x' => $x])

b)

return view('a')->with($x)

c)

return view()->set($x)

d)

return show($x)

9.

PHẦN 1 – ROUTE & CONTROLLER: Khi route trùng tên, Laravel sẽ?

a)

Lấy route đầu

b)

Lấy route sau

c)

Báo lỗi

d)

Tự sửa tên route

10.

PHẦN 1 – ROUTE & CONTROLLER: Route::resource() dùng để tạo?

a)

Toàn bộ CRUD

b)

Chỉ GET

c)

Chỉ POST

d)

Middleware

11.

PHẦN 2 – MIDDLEWARE: Middleware xử lý khi nào?

a)

Trước hoặc sau controller

b)

Sau view

c)

Sau database

d)

Trước migration

12.

PHẦN 2 – MIDDLEWARE: Hàm quan trọng nhất của middleware?

a)

run()

b)

handle()

c)

execute()

d)

check()

13.

PHẦN 2 – MIDDLEWARE: Để chặn người dưới 18 tuổi, ta dùng?

a)

if ($request->age < 18) redirect(...);

b)

if ($request->age > 18) redirect(...);

c)

if (!age) redirect(...);

d)

redirect all

14.

Đăng ký middleware global ở đâu?

a)

app/Http/Kernel.php

b)

web.php

c)

.env

d)

composer.json

15.

Muốn gắn middleware vào nhóm route:

a)

Route::middleware(['auth'])->group(...)

b)

Route::group(['use'=>auth])

c)

Route::apply(auth)

d)

Route::auth()

16.

Nếu middleware return redirect() thì controller có chạy không?

a)

Không

b)

c)

Tùy

d)

Tùy phiên bản

17.

Lệnh tạo middleware?

a)

php artisan make:middleware

b)

php artisan middleware:create

c)

php artisan new:middleware

d)

php artisan middleware

18.

Middleware chủ yếu dùng để?

a)

Kiểm tra quyền

b)

Tạo database

c)

Chạy migration

d)

Tạo model

19.

Muốn deny request, middleware dùng:

a)

return redirect()

b)

return false

c)

block()

d)

deny()

20.

Nhóm middleware web chứa?

a)

session, csrf

b)

API token

c)

Cấu hình queue

d)

Logging

21.

Authentication dùng để?

a)

Kiểm tra danh tính

b)

Lưu file

c)

Tạo route

d)

Gửi email

22.

Middleware auth giúp?

a)

Chỉ người đã đăng nhập truy cập

b)

Ai cũng truy cập

c)

Chặn người đăng nhập

d)

Chỉ admin truy cập

23.

auth.php trong routes dùng để?

a)

Chứa route login/register

b)

Chứa route API

c)

Chứa view

d)

Chứa controller

24.

Sau khi cài Breeze, Laravel tự tạo?

a)

Login, register, logout

b)

Database

c)

Migration user

d)

API

25.

Muốn logout?

a)

Auth::logout()

b)

Auth::exit()

c)

Auth::leave()

d)

User::logout()

26.

Middleware guest dùng cho?

a)

Người chưa đăng nhập

b)

Người đã đăng nhập

c)

Admin

d)

API

27.

Khi chưa login mà vào /dashboard, hệ thống?

a)

Redirect về login

b)

500 error

c)

404

d)

Vẫn vào được

28.

Muốn bảo vệ toàn nhóm route?

a)

Route::middleware('auth')->group(...)

b)

Route::secure(...)

c)

Route::lock(...)

d)

Route::protect(...)

29.

Guard mặc định của Laravel?

a)

web

b)

api

c)

admin

d)

user

30.

Laravel lưu thông tin login trong?

a)

Session

b)

Cookie

c)

.env

d)

Model

31.

Migration dùng để?

a)

Tạo/tùy chỉnh bảng

b)

Tạo view

c)

Tạo controller

d)

Tạo route

32.

Tạo model mới:

a)

php artisan make:model

b)

php artisan create:model

c)

php artisan model:create

d)

php artisan gen:model

33.

Tạo model kèm migration:

a)

php artisan make:model User -m

b)

php artisan make:model User -mig

34.

$table->string('name') tạo kiểu gì trong cơ sở dữ liệu?

a)

varchar

b)

text

c)

integer

d)

boolean

35.

timestamps() tạo ra các cột nào?

a)

created_at, updated_at

b)

time_start

c)

tất cả các kiểu timestamp

d)

time log

36.

Muốn chạy migration, sử dụng lệnh nào?

a)

php artisan migrate

b)

php artisan run:migration

c)

php artisan exec migrate

d)

php artisan migrate:start

37.

rollback dùng để làm gì?

a)

Quay lại migration trước

b)

Xóa model

c)

Xóa view

d)

Xóa controller

38.

fillable dùng để làm gì trong Eloquent model?

a)

Cho phép gán dữ liệu hàng loạt

b)

Bảo mật token

c)

Tạo khóa chính

d)

Tạo bảng

39.

Muốn xóa toàn bộ bảng rồi migrate lại, dùng lệnh nào?

a)

php artisan migrate:fresh

b)

php artisan migrate:redo

c)

php artisan migrate:clean

d)

php artisan table:reset

40.

belongsTo dùng trong loại quan hệ nào?

a)

Quan hệ 1–n

b)

Quan hệ n–n

41.

In biến trong Blade?

a)

{{ $name }}

b)

<< $name >>

c)

print($name)

d)

[$name]

42.

@yield('content') có chức năng?

a)

Vị trí nội dung thay đổi

b)

In biến

c)

Tạo middleware

d)

Tạo controller

43.

@extends('layout') nghĩa là?

a)

Kế thừa layout

b)

Tách route

c)

Tách controller

d)

Nhúng model

44.

@include('header') dùng để?

a)

Nhúng file blade khác

b)

Nhúng CSS

c)

Nhúng JS

d)

Nhúng API

45.

Comment trong Blade?

a)

{{-- comment --}}

b)

//

c)

d)

##

46.

{{ asset('css/app.css') }} trả về?

a)

URL file trong public

b)

URL file trong storage

c)

URL file trong app

d)

Tên file

47.

@section('title') dùng để?

a)

Truyền giá trị cho @yield

b)

Tạo route

c)

Tạo model

d)

Tạo bảng

48.

Với @yield('title','Trang mặc định'), nếu không truyền title thì hiển thị?

a)

Trang mặc định

b)

Null

c)

Trống

d)

Error

49.

Blade được compile thành?

a)

PHP thuần

b)

HTML

c)

JS

d)

JSON

50.

View chính thường nằm ở đâu?

a)

resources/views

b)

public/views

c)

app/views

d)

routes/views