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?
Correct Answer:
get()
Note: This Question is unanswered, help us to find answer for this one
Which of the following is true for Elixir and Gulp? (choose all that apply)
Correct Answer:
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
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following are route redirect methods? (Choose all that apply)
Correct Answer:
home()
refresh()
away()
secure()
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct Blade for/else syntax?
Correct Answer:
@forelse ($users as $user) {{ $user->first_name }} {{ $user->last_name }}
@empty No users. @endforelse
Note: This Question is unanswered, help us to find answer for this one
Which of the following is the correct sample code to union two queries?
Correct Answer:
$first = DB::table('contacts') ->whereNull('first_name'); $contacts = DB::table('contacts') ->whereNull('last_name') ->union($first) ->get();
Note: This Question is unanswered, help us to find answer for this one
Which of the following are correct route definitions? (Choose all that apply)
Correct Answer:
Route::match(['get', 'post'], '/', function () {});
Route::any('/', function () {});
Route::delete('/', function () {});
Route::put('/', function () {});
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following Request facades are available in Laravel? (Choose all that apply)
Correct Answer:
Request::all()
Request::except()
Request::has()
Request::get()
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following are correct redirects? (Choose all that apply)
Correct Answer:
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'); });
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following are valid validation rules? (Choose all that apply)
Correct Answer:
'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'
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following routes are created by below route declaration? (Choose all that apply) Route::resource('photos', 'PhotoController');
Correct Answer:
/photos
/photos/create
/photos/{photo}/edit
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following can be applied to route group? (Choose all that apply)
Correct Answer:
middleware
prefix
domain
namespace
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following are valid blade directives? (Choose all that apply)
Correct Answer:
@if, @else, @elseif, and @endif
@unless and @endunless
@for, @foreach, and @while
@forelse, @empty and @endforelse
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following DB facades allows you to execute raw commands or queries?
Correct Answer:
DB::select
DB::insert
DB::update
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following HTML form actions are not supported?
Correct Answer:
PUT
DELETE
PATCH
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following is the correct code to select data from database?
Correct Answer:
DB::select('select * from users');
Note: This Question is unanswered, help us to find answer for this one
How to escape output in blade?
Correct Answer:
{!! $stuffToEcho !!}
Note: This Question is unanswered, help us to find answer for this one
Which of the following php artisan command create tables in database on initial run?
Correct Answer:
php artisan migrate
Note: This Question is unanswered, help us to find answer for this one
Which of the following function can be used for named routes in your views?
Correct Answer:
route()
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct command to save an uploaded file?
Correct Answer:
$request->file('avatar')->store('avatars');
Note: This Question is unanswered, help us to find answer for this one
Which one of the following is correct form encoding for file uploads?
Correct Answer:
<form method="post" enctype="multipart/form-data">
Note: This Question is unanswered, help us to find answer for this one
Which of the following is ignored by blade?
Correct Answer:
@{{ $variable }}
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to redirect named route 'photos.index'?
Correct Answer:
Route::get('redirect', function () { return Redirect::route('photos.index'); });
Note: This Question is unanswered, help us to find answer for this one
Which of the following methods should be used to alter the columns of an existing table?
Correct Answer:
Schema::table()
Note: This Question is unanswered, help us to find answer for this one
Which of the following static methods can be used with our models? (choose all that apply)
Correct Answer:
::find()
::destroy()
::all()
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following can be used to add images in a view?
Correct Answer:
<img src="{{ URL::asset('img/myimage.png') }}" alt="a picture"/>
Note: This Question is unanswered, help us to find answer for this one
Which of the following can be used in Schema::create() method?
Correct Answer:
$table->string('username');
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to pass $name variable to views?
Correct Answer:
public function index() { return view('welcome')->with('name', 'Foo'); }
public function index() { $name = 'Foo'; return view('welcome', compact('name')); }
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following loops are available in blade?
Correct Answer:
@for ($i = 0; $i < 10; $i++) The current value is {{ $i }} @endfor This is user {{ $user->id }} No users I'm looping forever.
@foreach ($users as $user)
@forelse ($users as $user)
@while (true)
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
What will be the output of following in view if $name = "Andy"? Welcome, {{ $name or 'John' }}
Correct Answer:
Welcome, Andy
Note: This Question is unanswered, help us to find answer for this one
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?
Correct Answer:
'avatar' => 'file:image|dimensions:min_width=100,min_height=200'
Note: This Question is unanswered, help us to find answer for this one
To get a single column from Database table we can chain one of the following method?
Correct Answer:
->pluck('title');
Note: This Question is unanswered, help us to find answer for this one
Which of the following is required before using @section and @endsection in blade file?
Correct Answer:
@extends
Note: This Question is unanswered, help us to find answer for this one
To define a callback when view is rendered we can use:
Correct Answer:
View::composer()
Note: This Question is unanswered, help us to find answer for this one
To execute the following statement without error, which of the following is correct? $flight = App\User::create(['name' => 'John Doe']);
Correct Answer:
In model, set: protected $fillable = ['name'];
Note: This Question is unanswered, help us to find answer for this one
Which of the following can be used in views to print a message if array is empty?
Correct Answer:
ul> @forelse ($names as $name) <li>{{ $name }}</li> @empty <li>Don't have names to list.</li> @endforelse </ul>
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to loop over an array named $lists in view?
Correct Answer:
ul> @foreach ($lists as $list) <li>{{ $list }}</li> @endforeach </ul>
Note: This Question is unanswered, help us to find answer for this one
Which of the following is convenient and correct way to automatically inject the model instances directly into your routes?
Correct Answer:
Route::get('users/{user}', function (App\User $user) { return $user->email; });
Note: This Question is unanswered, help us to find answer for this one
Which method can be used to apply common properties to collection of routes?
Correct Answer:
group()
Note: This Question is unanswered, help us to find answer for this one
Which of the following artisan command is correct to create a model with table named 'projects'?
Correct Answer:
php artisan make:model Project -m
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to create a model named 'Person' with accompanying migration?
Correct Answer:
php artisan make:model Person -m
Note: This Question is unanswered, help us to find answer for this one
To apply common properties to collection of routes we can use one of the following method?
Correct Answer:
Route::group('article/new', 'ArticleController@newArticle');
Note: This Question is unanswered, help us to find answer for this one
How to route when using URL query string?
Correct Answer:
//routes.php Route::get('stats', 'StatsController@index'); //StatsController public function index() { if(Input::has('name') and Input::has('device'))) return $this->store(); // Show stat ... } public function store() { $input = Input::only('name', 'device'); // Store stat ... }
Note: This Question is unanswered, help us to find answer for this one
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'?
Correct Answer:
Request::only(['foo', 'baz']);
Note: This Question is unanswered, help us to find answer for this one
Using Form class to add the 'disabled' attribute for some options.
Correct Answer:
{{ Form::select('set', $sets, $prod->set_id, array('class' => 'form-select', 'disabled')) }}
Note: This Question is unanswered, help us to find answer for this one
Add default value to select list in form.
Correct Answer:
Form::getselect( 'myselect', array_merge(['' => ['label' => 'Please Select', 'disabled' => true], $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' ) }}
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following can be included in route definition to validate form data?
Correct Answer:
Validator::make($formData, $rules);
Note: This Question is unanswered, help us to find answer for this one
Which of the following are correct to delete a model with primary key 2?
Correct Answer:
$flight = App\Flight::find(2); $flight->delete();
Note: This Question is unanswered, help us to find answer for this one
Which of the following facade can be used to get the current URL for the request?
Correct Answer:
URL::current();
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to include a section('content') in your template?
Correct Answer:
@yield('content')
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct syntax for passing data to views?
Correct Answer:
return view('greetings', ['name' => 'Victoria']);
return view('greeting')->with('user', 'Victoria');
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following is shortcut for ternary statement in blade?
Correct Answer:
{{ $name or 'Default' }}
Note: This Question is unanswered, help us to find answer for this one
The following option will allow you to upload an image with many to many relationships:
Correct Answer:
$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);
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct directory for view files?
Correct Answer:
resources/views
Note: This Question is unanswered, help us to find answer for this one
Which of the following is executed first?
Correct Answer:
View::creator('profile', 'App\Http\ViewCreators\ProfileCreator');
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct for blade template?
Correct Answer:
{{ date('d/m/y') }} Even {{ $i }} red pandas, aren't enough!
@for ($i = 0; $i < 999; $i++)
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
To reference a view view('user.profile', $data); Which of the following is correct name and path for view file?
Correct Answer:
resources/views/user/profile.blade.php
Note: This Question is unanswered, help us to find answer for this one
Suppose we have a collection which contains the website news. What is the best way to share that collection in all views?
Correct Answer:
view()->share('news', NewsStory::orderBy('created_at', 'desc')->paginate(5));
Note: This Question is unanswered, help us to find answer for this one
Which one of the following is the last parameter for @each directive in blade?
Correct Answer:
The view that will be rendered if the given array is empty
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to render the expression using javascript instead of blade?
Correct Answer:
Hello, @{{ name }}.
Note: This Question is unanswered, help us to find answer for this one
Which of the following will list all routes?
Correct Answer:
php artisan route
Note: This Question is unanswered, help us to find answer for this one
Which of the following is true to get the URL of an image 'img/logo.png' from route '/example' ?
Correct Answer:
Route::get('example', function () { return URL::asset('img/logo.png'); });
Note: This Question is unanswered, help us to find answer for this one
Route parameters should not have underscore '_' character?
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to get the URL of named route 'contact'?
Correct Answer:
$url = route('contact');
Note: This Question is unanswered, help us to find answer for this one
Which of the following are correct route methods?
Correct Answer:
Route::get($uri, $callback);
Route::options($uri, $callback);
Route::put($uri, $callback);
Route::delete($uri, $callback);
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following code is correct to insert multiple records?
Correct Answer:
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'); }
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to retrieve all comments which are associated with single Post (post_id = 1) with one to many relation in Model?
Correct Answer:
$comments = App\Post::find(1)->comments;
Note: This Question is unanswered, help us to find answer for this one
Get only selected column from database table.
Correct Answer:
$selected_vote = users_details::get(['selected_vote']);
Note: This Question is unanswered, help us to find answer for this one
Which of the following databases are supported by Laravel 5?
Correct Answer:
PostgreSQL
MySQL
SQLite
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to retrieve soft deleted models?
Correct Answer:
$flights = App\Flight::onlyTrashed()->get();
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to get all rows from the table named users?
Correct Answer:
DB::table('users')->get();
Note: This Question is unanswered, help us to find answer for this one
Creating database view in migration laravel 5.2
Correct Answer:
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);
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
All eloquent models protect against mass-assignment by default.
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
Eloquent can fire the following events allowing you to hook into various points in the model's lifecycle. (choose all that apply)
Correct Answer:
creating
created
updating
restoring
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
To retrieve all blog posts that have at least one comment. (Model has one to many relation already set up)
Correct Answer:
$posts = App\Post::has('comments')->get();
Note: This Question is unanswered, help us to find answer for this one
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. Migration files must not be created manually, as their file name contains a timestamp. Instead usetheArtisanCLIinterfacecommand php artisan migrate:make to create a new Migration.
Correct Answer:
database
Note: This Question is unanswered, help us to find answer for this one
Which method will retrieve the first result of the query in Laravel eloquent?
Correct Answer:
findOrFail(1);
Note: This Question is unanswered, help us to find answer for this one
Which of the following command should be used to run all outstanding migration?
Correct Answer:
php artisan migrate
Note: This Question is unanswered, help us to find answer for this one
Which of the following methods are provided by migration class?
Correct Answer:
up()
down()
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
If you don't want Eloquent to automatically manage created_at and updated_at columns, which of the following will be correct?
Correct Answer:
Set the model $timestamps property to false
Note: This Question is unanswered, help us to find answer for this one
Which of the following file contains the database configurations?
Correct Answer:
config/database.php
Note: This Question is unanswered, help us to find answer for this one
Which of the following is a correct way to assign middleware 'auth' to a route?
Correct Answer:
Route::get('profile', [ 'middleware' => 'auth', 'uses' => 'UserController@show' ]);
Note: This Question is unanswered, help us to find answer for this one
To share route attributes, it is best to use route groups?
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
How to get Header Authorization key in controller?
Correct Answer:
public function yourControllerFunction(\Illuminate\Http\Request $request) { $header = $request->header('Authorization'); // do some stuff }
Note: This Question is unanswered, help us to find answer for this one
Which of the following are correct for route definitions?
Correct Answer:
Route::get('user/{name?}')
Route::get('user/{name}')
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
\Config::set('database.connections.customers.database', 'db_A');
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Which method can be used to store items in cache permanently?
Correct Answer:
Cache::forever('key', 'value');
Note: This Question is unanswered, help us to find answer for this one
List out few different return types of a controller action method?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Which view facade within a service provider's boot method can be used to share data with all views?
Correct Answer:
View::share('key', 'value');
Note: This Question is unanswered, help us to find answer for this one
Which of the following controller should be extended by all controllers?
Correct Answer:
Base Controller
Note: This Question is unanswered, help us to find answer for this one
Which of the following variable is available inside your loops in blade?
Correct Answer:
$loop
Note: This Question is unanswered, help us to find answer for this one
If blog post has infinite number of comments we can define one-to-many relationship by placing following code in post model?
Correct Answer:
public function comments() { return $this->hasMany('App\Comment'); }
Note: This Question is unanswered, help us to find answer for this one
To create a controller which handles all "CRUD" routes, which of the following is correct command?
Correct Answer:
php artisan make:controller CarController –resource
Note: This Question is unanswered, help us to find answer for this one
Which of the following can be used to create a controller with typical "CRUD" routes?
Correct Answer:
php artisan make:controller YourController –resource
Note: This Question is unanswered, help us to find answer for this one
Which of the following methods can be used with models to build relationships?
Correct Answer:
belongsToMany()
hasOne()
hasMany()
belongsTo()
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Use a validation rules inside the custom validation class?
Correct Answer:
$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
Note: This Question is unanswered, help us to find answer for this one
Which of the following is/are correct to define custom validation messages?
Correct Answer:
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
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to define middleware for multiple views in controller file?
Correct Answer:
public function __construct() { $this->middleware('admin', ['only' => ['create', 'edit', 'show']]); }
Note: This Question is unanswered, help us to find answer for this one
How the Laravel controller method get the parameters?
Correct Answer:
public function store(Request $request, $foo = 'bar'){ { $this->validate($request, [ 'title' => 'required|unique|max:255', 'body' => 'required', ]); }
Note: This Question is unanswered, help us to find answer for this one
Which of the following methods can be used to register a route that responds to all HTTP verbs?
Correct Answer:
Route::any()
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to create a route(s) to resource controller named "PostController"?
Correct Answer:
Route::resource('post', 'PostController');
Note: This Question is unanswered, help us to find answer for this one
Which of the following is correct to have an optional parameter in route?
Correct Answer:
Route::get('user/{name?}', function ($name = null) { return $name; });
Note: This Question is unanswered, help us to find answer for this one
Which method can be used to create custom blade directives?
Correct Answer:
Blade::directive()
Note: This Question is unanswered, help us to find answer for this one
Which of the following is the correct way to set SQLite as database for unit testing?
Correct Answer:
'sqlite' => [ 'driver' => 'sqlite', 'database' => storage_path('database.sqlite'), 'prefix' => '', ],
Note: This Question is unanswered, help us to find answer for this one
Which of the following validation rules are acceptable?
Correct Answer:
['field' => 'accepted']
['field' => 'active_url']
['field' => 'after:10/10/16']
['field' => 'alpha']
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
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
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
_____ directory contains much of the custom code used to power your application, including the models, controllers and middleware.
Correct Answer:
app
Note: This Question is unanswered, help us to find answer for this one
How do you define a single action controller for the following route?
Route::get('user/{id}', 'ShowProfile');
Correct Answer:
You may place a single __invoke method on the controller
Note: This Question is unanswered, help us to find answer for this one
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:
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
How access custom textbox name in Laravel using validation 'unique'?
Correct Answer:
'admin_username' => 'required|min:5|max:15|unique:administrators,username',
Note: This Question is unanswered, help us to find answer for this one
How to use laravel routing for unknown number of parameters in URL.
Correct Answer:
//in routes.php Route::get('/{book?}/{chapter?}/{topic?}/{article?}', 'controller@func'); //in your controller public function func($book = null, $chapter = null, $topic = null, $article = null) { ... }
Note: This Question is unanswered, help us to find answer for this one
___ web applications respond to meaningful HTTP verbs with appropriate data.
Correct Answer:
RESTful
Note: This Question is unanswered, help us to find answer for this one
____ 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.
Correct Answer:
Forms
Note: This Question is unanswered, help us to find answer for this one
Validation If checkbox ticked then Input text is required?
Correct Answer:
return [ 'has_login' => 'sometimes', 'pin' => 'required_with:has_login,on', ];
return [ 'has_login' => 'sometimes', 'pin' => 'required_if:has_login,on', ];
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
To protect application from cross-site request forgery attacks, which of the following should be included in forms?
Correct Answer:
{{ csrf_field() }}
Note: This Question is unanswered, help us to find answer for this one
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?
Correct Answer:
'finish_date' => 'required|date|after:start_date'
Note: This Question is unanswered, help us to find answer for this one
Laravel Framework MCQs | Topic-wise