Мы не гарантируем правильность всех предоставленных ответов.
103 Test Questions:
1. Use a validation rules inside the custom validation class?
Answers:
• $emailsOutput = Output::get(’email’);
$emails = explode(‘,’, $emails);
foreach($emails as $email) {
$validator = Validator::make(
[’email’ => $email],
[’email’ => ‘required|email’]
);
if ($validator->fails())
{
// There is an invalid email in the input.
}
}
• $emailsInput = Input::get(’email’);
$emails = explode(‘,’, $emails);
foreach($emails as $email) {
$validator = Validator::make(
[’email’ => $email],
[’email’ => ‘required|email’]
);
if ($validator->fails())
{
// There is an invalid email in the input.
}
}
• $emailsOutput = Output::get_email(’email’);
$emails = explode(‘,’, $emails);
foreach($emails as $email) {
$validator = Validator::make(
[’email’ => $email],
[’email’ => ‘required|email’]
);
if ($validator->fails())
{
// There is an invalid email in the input.
}
}
• None
2. If blog post has infinite number of comments we can define one-to-many relationship by placing following code in post model?
Answers:
• public function comments()
{
return $this->hasMany(‘App\Comment’);
}
• public function comments()
{
return $this->belongsTo(‘App\Comment’);
}
• public function comments()
{
return $this->oneToMany(‘App\Comment’);
}
3. Using Form class to add the ‘disabled’ attribute for some options.
Answers:
• {{ Form::select(‘set’, $sets, $prod->set_id, array(‘class’ => ‘form-select’)) }}
• {{ Form::select(‘set’, $sets, $prod->set_id, array(‘class’ => ‘form-select’, ‘disabled’)) }}
• {{ Form::select(‘set’, $sets, $prod->set_id, array(‘class’ => ‘form-select’, ‘adddisabled’)) }}
• All of the above
4. Which of the following are correct for route definitions?
Note: There may be more than one right answer.
Answers:
• Route::get(‘user/{name?}’)
• Route::get(‘user/{name}’)
• Route::get(‘{user}/name’)
• Route::get(‘user/?name}’)
5. To protect application from cross-site request forgery attacks, which of the following should be included in forms?
Answers:
• {{ secure }}
• {{ csrf_field() }}
• {{ protect() }}
• {{ csrf_protect() }}
Так же вас может заинтересовать
6. Which of the following will list all routes?
Answers:
• php artisan route:all
• php artisan route:list
• php artisan route
• php artisan route —all
7. Which of the following validator methods returns ‘True’ when form data is valid?
Answers:
• fails()
• passes()
• valid()
• success()
8. Which of the following is correct to define middleware for multiple views in controller file?
Answers:
• public function __construct()
{
$this->middleware(‘admin’, [‘only’ => [‘create’, ‘edit’, ‘show’]]);
}
• public function __construct()
{
$this->middleware(‘admin’, [‘only’ => ‘create|edit|show’]);
}
• public function __construct()
{
$this->middleware(‘admin’, [‘only’ => ‘create’]);
}
• All of the above
9. Which of the following command should be used to run all outstanding migration?
Answers:
• php artisan migrate:migration_name
• php artisan migrate
• php artisan create:migration
• php artisan generate:migration
10. Which of the following is/are correct to define custom validation messages?
Note: There may be more than one right answer.
Answers:
• Pass the custom messages as the third argument to the Validator::make method
• Specify your custom messages in a language file.
• Customize the error messages used by the form request by overriding the messages method.
11. Which of the following can be included in route definition to validate form data?
Answers:
• Validator::valid($formData, $rules);
• Validator::make($formData, $rules);
• Validate::make($formData, $rules);
• Validate::create($formData, $rules););
12. How access custom textbox name in Laravel using validation ‘unique’?
Answers:
• ‘admin_username’ => ‘required|min:5|max:15|unique:administrators,username’,
• ‘admin_username’ => ‘required|min:5|max:15|unique:administrators’,
• ‘admin_username’ => ‘requireds|min:5|max:15|unique:administrators’.username’,
• All of the above
13. The field under validation must be present in the input data and not empty. A field is considered «empty» if one of the following conditions are true:
Answers:
• The value is null.
• The value is an empty string.
• The value is an empty array or empty Countable object.
• The value is an uploaded file with no path.
• All of the above
14. To validate a date named finish_date against following rules:
-Should be date
-Required
-Should be greater than start_date
which of the following is correct validation rule?
Answers:
• ‘finish_date’ => ‘required|date|after|start_date’
• ‘finish_date’ => ‘required|date|>:start_date’
• ‘finish_date’ => ‘required|date|after:start_date’
• ‘finish_date’ => ‘required|date|greater:start_date’
15. If we have a following URL
http://myapp.dev/?foo=bar&baz=boo
Which of the following will get the values of ‘foo’ and ‘baz’?
Answers:
• Request::get(‘foo’, ‘baz’);
• Request::only([‘foo’, ‘baz’]);
• Request::except(‘foo’, ‘baz’);
16. Which of the following is correct syntax for passing data to views?
Note: There may be more than one right answer.
Answers:
• return view(‘greetings’, [‘name’ => ‘Victoria’]);
• return view(‘greeting’)->with(‘user’, ‘Victoria’);
• return view(‘greeting’)->->withAll(compact(‘teams’))
17. Which of the following is a correct way to assign middleware ‘auth’ to a route?
Answers:
• Route::get(‘profile’, [
‘middleware’ => ‘auth’,
‘uses’ => ‘UserController@show’
]);
• Route::get(‘profile’, [
‘controller’ => ‘auth’,
‘uses’ => ‘UserController@show’
]);
• Route::get(‘profile’, [
‘secure’ => ‘auth’,
‘uses’ => ‘UserController@show’
]);
• Route::get(‘profile’, [
‘filter’ => ‘auth’,
‘uses’ => ‘UserController@show’
]);
18. Which of the following validation rule is correct to validate that the file is an image file having dimensions of min 200 height x min 400 width?
Answers:
• ‘avatar’ => ‘image:min_width=100,min_height=200’
• ‘avatar’ => ‘dimensions:min_width=100,min_height=200’
• ‘avatar’ => ‘file:image|dimensions:min_width=100,min_height=200’
• ‘avatar’ => ‘file:type=image,min_width=100,min_height=200’
19. Which of the following validation rules are acceptable?
Note: There may be more than one right answer.
Answers:
• [‘field’ => ‘accepted’]
• [‘field’ => ‘active_url’]
• [‘field’ => ‘alpha’]
• [‘field’ => ‘after:10/10/16’]
20. If you don’t want Eloquent to automatically manage created_at and updated_at columns, which of the following will be correct?
Answers:
• Set the model $timestamps property to false
• Eloquent will always automatically manage created_at and updated_at columns
• Set the model $created_at and updated_at properties to false
21. Which of the following code is correct to insert multiple records?
Answers:
• public function store(Request $request)
{
$inputArrays = Getinput::allItem();
$schedule = new Schedule;
foreach ($inputArrays as $array) {
$student->name = $name;
$student->for_date = $date;
$student->save();
}
return view(‘students.index’);
}
• public function store(Request $request)
{
$inputArrays = Getinput::all();
$schedule = new Schedule;
foreach ($inputArrays as $array) {
$student->name = $name;
$student->for_date = $date;
$student->save();
}
return view(‘students.index’);
}
• public function store(Request $request)
{
$inputArrays = Input::all();
$schedule = new Schedule;
foreach ($inputArrays as $array) {
$student->name = $name;
$student->for_date = $date;
$student->save();
}
return view(‘students.index’);
}
• All of the above
22. Creating database view in migration laravel 5.2
Note: There may be more than one right answer.
Answers:
• CREATE VIEW wones AS SELECT (name from leagues) AS name
join teams where (leagues.id = team.country_id)
join players where (teams.id = players.team_id)
join points where (players.id = points.player_id)
sum(points.remnants) AS trem
count(points.remnants where points.remnants < 4) AS crem
• CREATE VIEW wones AS
SELECT
leagues.name,
sum(points.remnants) AS trem
sum(IF(points.remnants<4, 1, 0)) AS crem
FROM leagues
JOIN teams ON (leagues.id = team.country_id)
JOIN players ON (teams.id = players.team_id)
JOIN points ON (players.id = points.player_id);
• DB::statement( ‘CREATE VIEW wones AS
SELECT
leagues.name as name,
sum(points.remnants) as trem,
count(case when points.remnants < 4 then 1 end) as crem
FROM leauges
JOIN teams ON (teams.league_id = leagues.id)
JOIN players ON (players.team_id = teams.id)
JOIN points ON (points.player_id = players.id);
‘ );
• All of the above
23. Which of the following is correct to create a route(s) to resource controller named «PostController»?
Answers:
• Route::resource(‘PostController’, ‘post’);
• Route::resource(‘post’, ‘PostController’);
• Route::get(‘post’, ‘PostController’);
• Route::post(‘post’, ‘PostController’);
24. Which of the following are correct to delete a model with primary key 2?
Note: There may be more than one right answer.
Answers:
• $flight = App\Flight::find(2);
$flight->delete();
• $flight->delete(2);
• App\Flight::destroy(2);
25. Which of the following loops are available in blade?
Note: There may be more than one right answer.
Answers:
• @for ($i = 0; $i < 10; $i++)
The current value is {{ $i }}
@endfor
• @foreach ($users as $user)
<p>This is user {{ $user->id }}</p>
@endforeach
• @forelse ($users as $user)
<li>{{ $user->name }}</li>
@empty
<p>No users</p>
@endforelse
• @while (true)
<p>I’m looping forever.</p>
@endwhile
26. ____ are an important part of any web-based application. They help control the flow of the application which allows us to receive input from our users and make decisions that affect the functionality of our applications.
Answers:
• Routing
• Module
• Views
• Forms
27. To define a single action controller for following route
Route::get(‘user/{id}’, ‘ShowProfile’);
which of the following is correct?
Answers:
• You may place a single __construct method on the controller
• You may place a single __invoke method on the controller
• You may place a single __create method on the controller
• You can not create single action controller in laravel
28. Which of the following HTML form actions are not supported?
Note: There may be more than one right answer.
Answers:
• PUT
• POST
• DELETE
• PATCH
29. Which of the following is the correct way to set SQLite as database for unit testing?
Answers:
• ‘sqlite’ => [
‘driver’ => ‘sqlite’,
‘database’ => storage_path.’/database.sqlite’,
‘prefix’ => »,
],
• ‘sqlite’ => [
‘driver’ => ‘sqlite’,
‘database’ => storage_path(‘database.sqlite’),
‘prefix’ => »,
],
• ‘sqlite’ => [
‘driver’ => ‘sqlite’,
‘dtabase’ => storage_path().’/database.sqlite’,
‘prefix’ => »,
],
• All of the above
30. Validation If checkbox ticked then Input text is required?
Note: There may be more than one right answer.
Answers:
• return [
‘has_login’ => ‘sometimes’,
‘pin’ => ‘required_with:has_login,on’,
];
• return [
‘has_login’ => ‘sometimes’,
‘pin’ => ‘required_if:has_login,on’,
];
• return [
‘has_login’ => ‘accepted’,
‘pin’ => ‘required’,
];
• All of the above
31. Which of the following methods can be used to register a route that responds to all HTTP verbs?
Answers:
• Route::any()
• Route::match()
• Route::all()
32. Which of the following is correct directory for view files?
Answers:
• app/views
• storage/views
• resources/views
• public/views
33. Which of the following is true to get the URL of an image ‘img/logo.png’ from route ‘/example’ ?
Answers:
• Route::get(‘example’, function () {
return URL::asset(‘img/logo.png’);
});
• Route::get(‘example’, function () {
return URL::assets(‘img/logo.png’);
});
• Route::get(‘example’, function () {
return URL::full(‘img/logo.png’);
});
34. How do you add default value to a select list in form.
Answers:
• Form::getselect(
‘myselect’,
$categories,
$myselectedcategories,
array(
‘class’ => ‘form-control’,
‘id’ => ‘myselect’
)
}}
• Form::getselect(
‘myselect’,
array_merge([» => [‘label’ => ‘Please Select’, ‘disabled’ => true], $categories),
$myselectedcategories,
array(
‘class’ => ‘form-control’,
‘id’ => ‘myselect’
)
}}
• Form::select(
‘myselect’,
array_merge([» => [‘label’ => ‘Please Select’, ‘disabled’ => true], $categories),
$myselectedcategories,
array(
‘class’ => ‘form-control’,
‘id’ => ‘myselect’
)
}}
• Form::select(
‘myselect’,
$categories,
$myselectedcategories,
array(
‘class’ => ‘form-control’,
‘id’ => ‘myselect’
)
}}
35. Which method can be used to create custom blade directives?
Answers:
• Blade::directive()
• Blade::custom()
• We can not create custom blade commands
36. To create a controller which handles all «CRUD» routes, which of the following is correct command?
Answers:
• php artisan make:controller CarController —all
• php artisan make:controller CarController —crud
• php artisan make:controller CarController
• php artisan make:controller CarController —resource
37. Which of the following is correct to pass $name variable to views?
Note: There may be more than one right answer.
Answers:
• public function index() {
return view(‘welcome’)->with(‘name’, ‘Foo’);
}
• public function index() {
$name = ‘Foo’;
return view(‘welcome’)->withName($name);
}
• public function index() {
$name = ‘Foo’;
return view(‘welcome’, compact(‘name’));
}
38. Which of the following methods can be chained to get a single column from a database table?
Answers:
• ->name(‘title’);
• ->get(‘title’);
• ->column(‘title’);
• ->pluck(‘title’);
39. Which of the following methods should be used to alter the columns of an existing table?
Answers:
• Schema::alter()
• Schema::create()
• Schema::update()
• Schema::table()
40. Which of the following can be used in Schema::create() method? (check all that apply)
Note: There may be more than one right answer.
Answers:
• $table->integer(‘id’);
• $table->string(‘username’);
• $table->primary(‘id’);
• $table->unique(‘username’);
41. Which of the following is correct in order to create a model named ‘Person’ with accompanying migration?
Answers:
• php laravel make:model Person -m
• php artisan make:model Person -m
• php artisan make:model Person
• php artisan create:model Person -m
42. Which method can be used to store items in cache permanently?
Answers:
• Cache::permanent(‘key’, ‘value’);
• Cache::add(‘key’, ‘value’);
• Cache::put(‘key’, ‘value’);
• Cache::forever(‘key’, ‘value’);
43. Which of the following artisan command is correct to create a model with table named ‘projects’?
Answers:
• php artisan make:model Project
• php artisan create:model Project -m
• php artisan create:table Project
• php artisan make:model Project -m
44. Which of the following is the correct way to retrieve soft deleted models?
Answers:
• $flights = App\Flight::withTrashed()->get();
• $flights = App\Flight::onlyTrashed()->get();
• $flights = App\Flight::onlyDeleted()->get();
• $flights = App\Flight::Trashed()->get();
45. Which of the following methods can be used to retrieve the record as an object containing the column names and the data stored in the record?
Answers:
• get()
• find()
• add()
• insert()
46. Which of the following static methods can be used with our models? (choose all that apply)
Note: There may be more than one right answer.
Answers:
• ::find()
• ::destroy()
• ::all()
• ::show()
47. Which file contains the database configurations?
Answers:
• config/db.php
• public/database.php
• config/config.php
• config/database.php
48. Which of the following is the correct way to get all rows from the table named users?
Answers:
• DB::list(‘users’)->get();
• DB::table(‘users’);
• DB::table(‘users’)->all();
• DB::table(‘users’)->get();
49. Which of the following is used to retrieve all blog posts that have at least one comment?
Answers:
• $posts = App\Post::has(‘comments’)->get();
• $posts = App\Post::find(‘comments’)->get();
• $posts = App\Post::find()->comments()->get();
50. The migrations directory contains PHP classes which allow Laravel to update the schema of your current____, or populate it with values while keeping all versions of the application in sync.
Answers:
• language
• config
• libraries
• database
51. Which of the following is correct to execute the below statement without error?
$flight = App\User::create([‘name’ => ‘John Doe’]);
Answers:
• In model, set:
protected $fillable = [‘name’];
• In model, set:
protected $guarded = [‘name’];
• Above statement will execute without any error and will create a record in database.
52. Which of the following methods can be used with models to build relationships?
Note: There may be more than one right answer.
Answers:
• belongsToMany()
• hasOne()
• hasMany()
• belongsTo()
53. Which of the following databases are supported by Laravel 5?
Note: There may be more than one right answer.
Answers:
• PostgreSQL
• MySQL
• SQLite
• MongoDB
54. Eloquent can fire the following events allowing you to hook into various points in the model’s lifecycle. (choose all that apply)
Note: There may be more than one right answer.
Answers:
• creating
• created
• updating
• restoring
55. Which method will retrieve the first result of the query in Laravel eloquent?
Answers:
• findOrPass(1);
• all(1);
• findOrFail(1);
• get(1);
56. Which of the following is correct to retrieve all comments that are associated with a single post (post_id = 1) with one to many relation in Model?
Answers:
• $comments = App\Post::comments->find(1);
• $comments = App\Post::find()->comments(1);
• $comments = App\Post::find(1)->comments;
57. Which of the following methods are provided by migration class?
Note: There may be more than one right answer.
Answers:
• up()
• down()
• create()
• destroy()
58. Which of the following can be used to get only selected column from a database table?
Answers:
• $selected_vote = users_details::lists(‘selected_vote’);
• $selected_vote = users_details::all()->get(‘selected_vote’);
• $selected_vote = users_details::get([‘selected_vote’]);
• All of the above
59. Which of the following are correct route methods?
Note: There may be more than one right answer.
Answers:
• Route::get($uri, $callback);
• Route::options($uri, $callback);
• Route::put($uri, $callback);
• Route::delete($uri, $callback);
60. Which of the following is the correct way to display unescaped data in blade?
Answers:
• Hello, { $name }.
• Hello, {! $name !}.
• Hello, {!! $name !!}.
• Hello, {{$name }}.
61. What will be the output of the following in view if $name = «Andy»?
Welcome, {{ $name or ‘John’ }}
Answers:
• Welcome, Andy John
• Welcome, Andy or John
• Welcome, Andy
• Welcome, John
62. Which of the following is a shortcut for ternary statement in blade?
Answers:
• {{ isset($name) ? $name : ‘Default’ }}
• {{ $name or ‘Default’ }}
• {{ $name else ‘Default’ }}
• none
63. To define a callback when view is rendered we can use:
Answers:
• View::composer()
• View::callback()
• View::method()
• View::match()
64. Suppose we have a collection which contains the website news. What is the best way to share that collection in all views?
Answers:
• $news=NewsStory::orderBy(‘created_at’, ‘desc’)->paginate(5);
• view()->share(‘news’, NewsStory::orderBy(‘created_at’, ‘desc’)->paginate(5));
• view()->addShare(‘news’, NewsStory::orderBy(‘created_at’, ‘desc’)->paginate(5));
• All of the above
65. Which view facade within a service provider’s boot method can be used to share data with all views?
Answers:
• View::config(‘key’, ‘value’);
• View::put(‘key’, ‘value’);
• View::store(‘key’, ‘value’);
• View::share(‘key’, ‘value’);
66. Which of the following can be used to add images in a view? (choose all that apply)
Note: There may be more than one right answer.
Answers:
• <img src=»{{ URL::asset(‘img/myimage.png’) }}» alt=»a picture»/>
• {{ HTML::image(‘img/myimage.png’, ‘a picture’) }}
• include(app_path().»/../resources/views/fronthead.blade.php»);
• All of the above
67. Which of the following is executed first?
Answers:
• View::creator(‘profile’, ‘App\Http\ViewCreators\ProfileCreator’);
• View::composer(‘profile’, ‘App\Http\ViewCreators\ProfileCreator’);
68. Which of the following is true for Elixir and Gulp? (choose all that apply)
Note: There may be more than one right answer.
Answers:
• Elixir is built on top of Gulp, so to run your Elixir tasks you only need to run the gulp
• The gulp watch command will continue running in your terminal and watch your assets for any changes.
• Adding the —production flag to the command will instruct Elixir to minify your CSS and JavaScript files
• None of the above
69. Which of the following variable is available inside your loops in blade?
Answers:
• $iterate
• $first
• $index
• $loop
70. Which of the following can be used in views to print a message if array is empty?
Answers:
• <ul>
@while ($names as $name)
<li>{{ $name }}</li>
@else
<li>Don’t have names to list.</li>
@endwhile
</ul>
• <ul>
@if ($names as $name)
<li>{{ $name }}</li>
@else
<li>Don’t have names to list.</li>
@endif
</ul>
• <ul>
@for ($names as $name)
<li>{{ $name }}</li>
@else
<li>Don’t have names to list.</li>
@endfor
</ul>
• <ul>
@forelse ($names as $name)
<li>{{ $name }}</li>
@empty
<li>Don’t have names to list.</li>
@endforelse
</ul>
71. Which one of the following is the last parameter for @each directive in blade?
Answers:
• Array or collection you wish to iterate over
• View partial to render for each element in the array or collection
• The view that will be rendered if the given array is empty
72. To reference a view
view(‘user.profile’, $data);
Which of the following is the correct name and path for view file?
Answers:
• resources/views/user/profile.php
• resources/views/admin/user.blade.php
• storage/views/admin/profile.blade.php
• resources/views/user/profile.blade.php
73. Which of the following is correct to loop over an array named $lists in view?
Answers:
• <ul>
@foreach ($lists as $list)
<li>{{ $list }}</li>
@endforeach
</ul>
• <ul>
{ foreach ($lists as $list) }
<li>{{ $list }}</li>
{ endforeach }
</ul>
• <ul>
@foreach ($list as $lists)
<li>{{ $list }}</li>
@endforeach
</ul>
• <ul>
@foreach ($lists as $list)
<li>{{ $list }}</li>
@end
</ul>
74. If you need to add additional routes to a resource controller beyond the default set of resource routes, you should define those routes after your call to Route::resource
Answers:
• True
• False
75. How do you upload an image to a form with many to many relationships?
Answers:
• $file = Request::file(‘resume’);
$extension = $file->getClientOriginalExtension();
Storage::disk(‘local’)->put($file->getFilename().’.’.$extension, File::get($file));
$resume = new Resume();
$resume->mime = $file->getClientMimeType();
$resume->filename = $file->getFilename().’.’.$extension;
$candidate=new Candidate();
$data=array_except($data, array(‘_token’,’resume’));
$user->candidate()->save($candidate);
$candidate->resume()->save($resume);
$candidate=$user->candidate($user);
$candidate->update($data);
• public function create()
{
$categories = Category::lists(‘name’, ‘id’);
$days = Day::lists(‘dayname’, ‘id’);
return view(‘articles.create’, compact(‘categories’, ‘days’));
}
public function store(ArticleRequest $request)
{
$image_name = $request->file(‘image’)->getClientOriginalName();
$request->file(‘image’)->move(base_path().’/public/images’, $image_name);
$article = ($request->except([‘image’]));
$article[‘image’] = $image_name;
Article::create($article);
}
• $file = Request::addfile(‘resume’);
$extension = $files->getClientOriginalExtension();
Storage::disk(‘local’)->put($file->getFilename().’.’.$extension, File::get($file));
$resume = new Resume();
$resume->mime = $file->getClientMimeType();
$resume->filename = $file->getFilename().’.’.$extension;
$candidate=new Candidate();
$data=array_except($data, array(‘_token’,’resume’));
$user->candidate()->save($candidate);
$candidate->resume()->save($resume);
$candidate=$user->candidate($user);
$candidate->update($data);
• All of the above
76. Which of the following is convenient and correct way to automatically inject the model instances directly into your routes?
Answers:
• Route::get(‘api/users/{user}’, function ($user) {
return $user->email;
});
• Route::get(‘users/{user}’, function (App\User $user) {
return $user->email;
});
• Route::get(‘users/{id}’, function (App\User $user) {
return $user->email;
});
77. Which of the following is required before using @section and @endsection in blade file?
Answers:
• @template
• @extends
• @require
• @include
78. Which of the following is the correct way to render the expression using javascript instead of blade?
Answers:
• Hello, {{ name }}.
• Hello, ?{{ name }}.
• Hello, @{{ name }}.
• Hello, {{{ name }}}.
79. Which of the following is correct to include a section(‘content’) in your template?
Answers:
• @include(‘content’)
• @yield(‘content’)
• {{ content }}
• @define(‘content’)
80. Which of the following are valid validation rules? (Choose all that apply)
Note: There may be more than one right answer.
Answers:
• ‘name’ => ‘required|max:255’
• ’email’ => ’email’
• ‘website’ => [‘regex:/^((?:https?\:\/\/|www\.)(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)$/’]
• ‘re_occurance_end_date’ => ‘required_if:repeat_appointment,daily,weekly,monthly,yearly’
81. Which of the following is correct syntax to use layout of another view?
Answers:
• @extends(‘layouts.master’)
• @use(‘layouts.master’)
• @extend(‘layouts.master’)
• @view(‘layouts.master’)
82. Which of the following DB facades allows you to execute raw commands or queries?
Note: There may be more than one right answer.
Answers:
• DB::select
• DB::sql
• DB::insert
• DB::update
83. Which of the following is correct command to save an uploaded file?
Answers:
• $request->file(‘avatar’)->store(‘avatars’);
• $request->input(‘avatar’)->store(‘avatars’);
• $request->file(‘avatar’)->save(‘avatars’);
• $request->input(‘avatar’)->save(‘avatars’);
84. Which of the following are route redirect methods? (Choose all that apply)
Note: There may be more than one right answer.
Answers:
• home()
• refresh()
• away()
• secure()
85. Which of the following Request facades are available in Laravel? (Choose all that apply)
Note: There may be more than one right answer.
Answers:
• Request::all()
• Request::except()
• Request::has()
• Request::get()
86. Which of the following are correct route definitions? (Choose all that apply)
Note: There may be more than one right answer.
Answers:
• Route::match([‘get’, ‘post’], ‘/’, function () {});
• Route::any(‘/’, function () {});
• Route::delete(‘/’, function () {});
• Route::put(‘/’, function () {});
87. Which of the following can be applied to route group? (Choose all that apply)
Note: There may be more than one right answer.
Answers:
• middleware
• prefix
• domain
• namespace
88. Which of the following is correct to redirect named route ‘photos.index’?
Answers:
• Route::get(‘redirect’, function () {
return Redirect::to(‘photos.index’);
});
• Route::get(‘redirect’, function () {
return Redirect::route(‘photos.index’);
});
• Route::get(‘redirect’, function () {
return Redirect(‘photos.index’);
});
• Route::get(‘redirect’, function () {
return Redirect::route(‘photos’);
});
89. Which one of the following is correct form encoding for file uploads?
Answers:
• <form method=»post» type=»multipart/form-data»>
• <form method=»post»>
• <form method=»get» enctype=»multipart/form-data»>
• <form method=»post» enctype=»multipart/form-data»>
90. Which of the following are correct regular expression route constraints?
Note: There may be more than one right answer.
Answers:
• Route::get(‘users/{id}’, function ($id) {
//
})->where(‘id’, ‘[0-9]+’);
• Route::get(‘users/{username}’, function ($username) {
//
})->where(‘username’, ‘[A-Za-z]+’);
• Route::get(‘posts/{id}/{slug}’, function ($id, $slug) {
//
})->where([‘id’ => ‘[0-9]+’, ‘slug’ => ‘[A-Za-z]+’]);
• Route::get(‘users/id’, function ($id) {
//
})->where(‘id’, ‘[1-9]+’);
91. Which of the following is the correct code to select data from database?
Answers:
• DB::get(‘select * from users’);
• DB::query(‘select * from users’);
• DB::select(‘select * from users’);
• Query::select(‘select * from users’);
92. Which of the following are correct redirects? (Choose all that apply)
Note: There may be more than one right answer.
Answers:
• Route::get(‘redirect-with-facade’, function () {
return Redirect::to(‘auth/login’);
});
• Route::get(‘redirect-with-helper’, function () {
return redirect()->to(‘auth/login’);
});
• Route::get(‘redirect-with-helper-shortcut’, function () {
return redirect(‘auth/login’);
});
• Route::get(‘redirect-with-helper-shortcut’, function () {
return redirect->route(‘auth/login’);
});
93. Which of the following routes are created by below route declaration? (Choose all that apply)
Route::resource(‘photos’, ‘PhotoController’);
Note: There may be more than one right answer.
Answers:
• /photos
• /photos/create
• /photos/{photo}/edit
• /photos/{photo}/delete
94. Which of the following function can be used for named routes in your views?
Answers:
• url()
• route()
• uri()
• slug()
95. Which of the following is the correct sample code to union two queries?
Answers:
• $first = DB::table(‘contacts’)
->whereNull(‘first_name’);
$contacts = DB::table(‘contacts’)
->whereNull(‘last_name’)
->get()
->union($first);
• $first = DB::table(‘contacts’)
->whereNull(‘first_name’);
$contacts = DB::table(‘contacts’)
->whereNull(‘last_name’)
->get();
$union = DB::union($first,$contacts );
• $first = DB::table(‘contacts’)
->union($contacts)
->whereNull(‘first_name’);
$contacts = DB::table(‘contacts’)
->whereNull(‘last_name’)
->union($first)
->get();
• $first = DB::table(‘contacts’)
->whereNull(‘first_name’);
$contacts = DB::table(‘contacts’)
->whereNull(‘last_name’)
->union($first)
->get();
96. To use
@section(‘content’)
Welcome to your application dashboard!
@endsection
in your blade view what else should be there at the top?
Answers:
• @yeild(‘layouts.master’)
• @extends(‘layouts.master’)
• @include(‘layouts.master’)
• @require(‘layouts.master’)
97. Which of the following php artisan command create tables in database on initial run?
Answers:
• php artisan make:tables
• php artisan migrate
• php artisan create:table
• php artisan create:db
98. Which of the following is correct Blade for/else syntax?
Answers:
• <?php if (empty($users)): ?>
No users.
<?php else: ?>
<?php foreach ($users as $user): ?>
<?= $user->first_name ?> <?= $user->last_name ?><br>
<?php endforeach; ?>
<?php endif; ?>
• {% for user in users %}
{{ user.first_name }} {{ user.last_name }}<br>
{% else %}
No users.
{% endfor %}
• @forelse ($users as $user)
{{ $user->first_name }} {{ $user->last_name }}<br>
@empty
No users.
@endforelse
• @foreach ($users as $user)
{{ $user->first_name }} {{ $user->last_name }}<br>
@else
No users.
@endforeach
99. Which of the following is ignored by blade?
Answers:
• {{ $variable }}
• {!! $variable !!}
• @{{ $variable }}
• {{{ $variable }}}
100. Which of the following can be used to declare a custom blade directive?
Answers:
• Blade::custom()
• Blade::directive()
• Blade->directive()
• Blade::command()
101. How to escape output in blade?
Answers:
• {{ $stuffToEcho }}
• {!! $stuffToEcho !!}
• { $stuffToEcho }
• @{ $stuffToEcho }
102. Which of the following is correct to get the URL of named route ‘contact’?
Answers:
• $url = route(‘contact’);
• $url = route()->name(‘contact’);
• $url = name(‘contact’);
• $url = route::name(‘contact’);
103. Which of the following are valid blade directives? (Choose all that apply)
Note: There may be more than one right answer.
Answers:
• @if, @else, @elseif, and @endif
• @unless and @endunless
• @for, @foreach, and @while
• @forelse, @empty and @endforelse