Laravel Upwork Test Answers


1. Use a validation rules inside the custom validation class?

Answer:

  • $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 the 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 the 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('greetings')->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' => 'dimensions:min_width=400,min_height=200'
  • 'avatar' =>'file:image|dimensions:min_width=400,min_height=200'
  • 'avatar' =>'file:type=image,min_width=400,min_height=200'
  • 'avatar' =>'image:min_width=400,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::alltem(); $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. 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');
23. 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)

24. 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
25. ____ 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
26. To define a single action controller for the 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 a single action controller in laravel
27. Which of the following HTML form actions are not supported?
 Note: There may be more than one right answer.

Answers:

  • PUT
  • POST
  • DELETE
  • PATCH
28. Which of the following is the correct way to set SQLite as a 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','database'=> storage_path(). '/database.sqlite','prefix'=>  »,],
  • All of the above
29. 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
30. 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()
31. Which of the following is correct directory for view files?

Answers:

  • app/views
  • storage/views
  • resources/views
  • public/views
32. 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'); });
33. 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
34. 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')); }
35. 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');
36. 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()

37. 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');
38. 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
39. 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');
40. 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
41. 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();


42. 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()


43. 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()


44. Which file contains the database configurations?

Answers:


  •  config/db.php
  •  public/database.php
  •  config/config.php
  •  config/database.php


45. 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();


46. 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();


47. 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


48. 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.


49. 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()


50. Which of the following databases are supported by Laravel 5?
 Note: There may be more than one right answer.

Answers:


  • PostgreSQL
  • MySQL
  • SQLite
  •  MongoDB


51. 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


52. Which method will retrieve the first result of the query in Laravel eloquent?

Answers:


  •  findOrPass(1);
  •  all(1);
  •  findOrFail(1);
  •  get(1);


53. 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;


54. Which of the following methods are provided by migration class?
 Note: There may be more than one right answer.

Answers:


  •  up()
  •  down()
  •  create()
  •  destroy()


55. 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);


56. Which of the following is the correct way to display unescaped data in blade?

Answers:


  • Hello, { $name }.
  • Hello, {! $name !}.
  • Hello, {!! $name !!}.
  • Hello, {{$name }}.


57. 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


58. Which of the following is a shortcut for ternary statement in blade?

Answers:


  •  {{ isset($name) ? $name : ‘Default’ }}
  •  {{ $name or ‘Default’ }}
  •  {{ $name else ‘Default’ }}
  •  none


59. To define a callback when view is rendered we can use:

Answers:


  • View::composer()
  • View::callback()
  • View::method()
  • View::match()


60. 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


61. 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’);


62. 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


63. Which of the following is executed first?

Answers:


  • View::creator(‘profile’, ‘App\Http\ViewCreators\ProfileCreator’);
  • View::composer(‘profile’, ‘App\Http\ViewCreators\ProfileCreator’);


64. 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


65. Which of the following variable is available inside your loops in blade?

Answers:


  • $iterate
  • $first
  • $index
  • $loop


66. 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>


67. 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



68. 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




69. 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>




70. 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




71. 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;});




72. Which of the following is required before using @section and @endsection in blade file?

Answers:


  •  @template
  •  @extends
  •  @require
  •  @include


73. Which one of the following is correct from encoding for file uploads?

Answers:


  • <form method="post" type="mltipart/form-data">
  • <form method="post">
  • <form method="get" enctype="multipart/form-data">
  • <form method="post" enctype="multipart/form-data">
74. To protect the application from cross-site request forgery attacks, which of the following should be included in forms?
Answers:
  • {{secure}}
  • {{csrf_field() }}
  • { { protect() } }
  • { { csrf_protect() } }

75. Which of the following is ignored by blade.
Answers:
  • {{ $variable }}
  • {!! $variable !!}
  • @{{ $vavriable }}
  • {{{ $variable }}}

76. If you need to add additional routes to a resources controller behind the default set of resource routes, you should define those routes after your call to Route::resource.
Answers:
  • True
  • False
77. 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');
78. Which file contains the database configuration?
Answers:
  • Config/db.php
  • Public/database.php
  • Config/config.php
  • Config/database.php
79. Which of the subsequent are valid blade directives?
Answers:
  • @if,@else,@elseif, and @endif
  • @unless and @endunless
  • @for,@foreach, and @while
  • @forelse, @empty and @endforelse
80. Which of the subsequent validation rules are acceptable?
  • ['field'=>'after:10/10/16']
  • ['field'=> 'active_url']
  • ['field' => 'alpha']
  • ['field' =>'accepted']
81. Which of the subsequent validator methods returns 'True' when form data is valid?
Answers:
  • fails ()
  • passes ()
  • valid()
  • success()
82. Which of the subsequent is correct to get the URL of named route 'contact'?
  • $url = route('contact');
  • $url = route()->name('contact');
  • $url = name('contact');
  • $url = route::name('contact');
83. Which of the subsequent is the correct way to get all rows from the table named users?
  • DB::list('users')->get();
  • DB::table('users');
  • DB::table('users')->all();
  • DB::table('users')->get();
84.  @section('content')
Welcome to your application dashboard!
@endsection
In your blade view what else should be there at the top?
  • @yeild('layouts.master')
  • @extends('layouts.master')
  • @include('layouts.master')
  • @require('layouts.master')

85. How do you add a default value to a select list in a form?
  • Form::getselect('myselect',$categories,$myselectedcategories,array('class'=>'form-control','id'=>'myselect') }}
  • Form::getselec('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') }}
86. Which of the following are correct route definitions?
  • Route::match(['get','post'],'/',function(){});
  • Route::any('/',function() {} );
  • Route::delete('/',function () {} );
  • Route::put('/',function() {} );
87. Which of the subsequent is the last parameter for @each directive in blade
  • 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
88. Which subsequent validation rule is correct to validate that the file is an image file having dimensions of min 200 height x min 400 width?
  • 'avatar' => 'dimensions:min_width=400,min_height=200'
  • 'avatar' =>'file:image|dimensions:min_width=400,min_height=200'
  • 'avatar' =>'file:type=image,min_width=400,min_height=200'
  • 'avatar' =>'image:min_width=400,min_height=200'
89. How do you define a single action controller for the following route? Route::get('user/{id}','ShowProfile');
  • 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
90. Which of the following are correct regular expression route constraints? Route::get('user/{id}','ShowProfile');
  • 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}/{slud}',function($id,$slug){ })->where(['id'=>['0-9]+','slug'=>'[A-Za-z]+']);
  • Route::get('users/id',function($id){ })->where('id','[1-9]+');
91. Which subsequent methods should be used to alter the columns of an existing table?
  • Schema::alter()
  • Schema::create()
  • Schema::update()
  • Schema::table()
92. Using form class to add the "disabled" attribute for some options.
  • {{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',$set,$prod->set_id,array('class'=>'form-select','adddisabled'))}}
  • All of above
93. if you need to add additional routes to a resource controller beyond the default set of resour routes, you should define those routes after your call to Route::resource
  • True
  • False
94. Which of the following can be appliedd to route group?
  • middleware
  • prefix
  • domain
  • namespace
95. Which method can be used to create custom blade directives?
  • Blade::directive()
  • Blade::custom()
  • Blade->directive()
  • Blade::command()
96. Which of the following are valid validation rules?
  • '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'
97. Which of the following are correct route methods?
  • Route::get($uri,$callback);
  • Route::options($uri,$callback);
  • Route::put($uri,$callback);
  • Route::delete($uri,$callback);
98. What will be the output of the following in view if $name = «Andy»? Welcome, {{ $name or 'John'}}
  • Welcome, Andy John
  • Welcome, Andy or John
  • Welcome, Andy
  • Welcome, John 
99. Which subsequent is correct to retrieve all comments that are associated with a single post (post_id =1) with one to many relations in the model?
  • $comments = App/Post::comments->find(1);
  • $comments = App/Post::find->Comments(1);
  • $comments = App/Post::find(1)Comments;

100. Which of the following methods are provided by migration class?
  • up()
  • Down()
  • Create()
  • Destroy()
101. Which of the following is a shortcut for the ternary statement in the blade?


  • {{ isset($name) ? $name : 'Default' }}
  • {{ $name or 'Default' }}
  • {{ $name else 'Default' }}
  • None
102. Which of the following databases are supported by Laravel 5?
  • PostgreSQL
  • MySQL
  • SQLite
  • MongoDB
103. Which of the following is correct to redirect named route 'photos.index'?
  • 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'); });
104. Which of the following is true for Elixir and Gulp?
  • Elixir is built on top of Gulp, so to run the 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
105. Which of the following is the correct directory for view files?
  • app/views
  • storage/views
  • resources/views
  • public/views
106. To define a callback when view is rendered we can use
  • View::callback()
  • View::method()
  • View::composer()
  • View::match()
107. Suppose we have a collection which contains the website news. What is the best way to share that collection in all views?
  • $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
108. Which of the following methods can be used to register a route that responds to all HTTP verbs?


  • Route::any()
  • Route::match()
  • Route::all()
109. Which of the following is the correct way to get all rows from the table named users?
  • DB::list('users')->get();
  • DB::table('users');
  • DB::table('users')->all();
  • DB::table('users')->get();
110. Which of the following are correct route methods?
Note: There may be more than one right answer.
  • Route::get($uri,$callback);
  • Route::options($uri,$callback);
  • Route::put($uri,$callback);
  • Route::delete($uri,$callback);
111. Which method can be used to store items in cache permanently?


  • Cache::permanent('key',value');
  • Cache::add('key','value');
  • Cache::put('key','value');
  • Cache::forever('key','value');
112. Which of the following loops are available in blade? (choose all that apply)
Note: There may be more than one right answer

  • @for($i = 0; $i <10; $i++) The current value is {{$i}} @endfor
  • @foreach ($users as $user) <p>This is user {{$user->id }}</p>@endforeach
  • @foresle($users as $user)<li>{{$user->name}}</li><@empty<p>No Users</p>@endforelse
  • @while(true)<p>I'm looping forever</p>@endwhile
113. Which of the following can be applied to route group? (Choose all that apply)
Note: There may be more than one right answer.

  • middleware
  • prefix
  • domain
  • namespace
114. Which of the following are valid blade directives? (choose all that apply)
Note: There may be more than one right answer.
  • @if, @else, @elseif, and @endif
  • @unless and @endunless
  • @for, @foreach, and @while
  • @forelse, @empty and @endforelse
115. The following option will allow you to upload an image with many to many relationships:
  • $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'])0; $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
116. Which of the following is correct to define middleware for multiple views in controller file?
  • 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

No comments:

Post a Comment