Laravel Framework Test Upwork

Which of the following are correct redirects? (Choose all that apply)
Note: There may be more than one right 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');
});

Route::get('redirect-with-helper-shortcut', function () {
  return redirect->route('auth/login');
});

Which of the following are route redirect methods? (Choose all that apply)
Note: There may be more than one right answer.

home()
refresh()
away()
secure()

Which of the following methods can be used to register a route that responds to all HTTP verbs?

Route::any()
Route::match()
Route::all()

Which of the following DB facades allows you to execute raw commands or queries?
Note: There may be more than one right answer.

DB::select
DB::sql
DB::insert
DB::update

Which of the following are valid validation rules? (Choose all that apply)
Note: There may be more than one right 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'

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');
});

Which of the following is ignored by blade?

{{ $variable }}
{!! $variable !!}
@{{ $variable }}
{{{ $variable }}}

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.

/photos
/photos/create
/photos/{photo}/edit
/photos/{photo}/delete

Which of the following are correct route definitions? (Choose all that apply)
Note: There may be more than one right answer.

Route::match(['get', 'post'], '/', function () {});
Route::any('/', function () {});
Route::delete('/', function () {});
Route::put('/', function () {});

Which of the following are correct regular expression route constraints?
Note: There may be more than one right answer.

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]+');

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

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

To use @section('content') in your blade view what else should be there at the top?

@yeild(‘layouts.master’)
@extends(‘layouts.master’)
@include(‘layouts.master’)
@require(‘layouts.master’)

Which of the following is correct to get the URL of named route 'contact'?

$url = route('contact');
$url = route()->name('contact');
$url = name('contact');
$url = route::name('contact');

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

Which of the following is correct Blade for/else syntax?

<?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

To protect application from cross-site request forgery attacks, which of the following should be included in forms?

{{ secure }}
{{ csrf_field() }}
{{ protect() }}
{{ csrf_protect() }}

Which of the following can be used to declare a custom blade directive?

Blade::custom()
Blade::directive()
Blade->directive()
Blade::command()

Which file contains the database configurations?

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

To reference a view
view('user.profile', $data);
Which of the following is the correct name and path for view file?

resources/views/user/profile.php
resources/views/admin/user.blade.php
storage/views/admin/profile.blade.php
resources/views/user/profile.blade.php

How the Laravel controller method get the parameters?

public function store(Request $request, $foo = 'bar'){
{
    $this->validate($request, [
        'title' => 'required|unique|max:255',
        'body' => 'required',
    ]);
}

public function store(Request $request)
{
    $this->validate($request, [
        'title' => 'required|unique|max:255',
        'body' => 'required',
    ]);
}

public function store($foo = 'bar', Request $request){
{
    $this->validate($request, [
        'title' => 'required|unique|max:255',
        'body' => 'required',
    ]);
}

All of the above

_____ directory contains much of the custom code used to power your application, including the models, controllers and middleware.

appview
controller
models

How to get Header Authorization key in controller?

public function yourControllerFunction(\Illuminate\Http\Request $request)
{
    $header = $request->addheader('Authorization');
    // do some stuff
}

public function yourControllerFunction(\Illuminate\Http\Request $request)
{
    $header = $request->header('Authorization');
    // do some stuff
}

public function yourControllerFunction(/Illuminate/Http/Request)
{
    $header = $request->addheader('Authorization');
    // do some stuff
}

None of the above

Which of the following can be used to create a controller with typical "CRUD" routes?

php artisan make:controller YourController
php artisan make:controller YourController --crud
php artisan make:controller YourController --resource
php artisan make:controller YourController --all

Which of the following controller should be extended by all controllers?

Add Controller
Advance Controller
Base Controller
View Controller

___ web applications respond to meaningful HTTP verbs with appropriate data.

Validation
RESTful
Database
Views

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

To create a controller which handles all "CRUD" routes, which of the following is correct command?

php artisan make:controller CarController --all
php artisan make:controller CarController --crud
php artisan make:controller CarController
php artisan make:controller CarController --resource

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

True
False

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 the correct validation rule?

‘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’

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?

$comments = App\Post::comments->find(1);
$comments = App\Post::find()->comments(1);
$comments = App\Post::find(1)->comments;

Which of the following is true for Elixir and Gulp? (choose all that apply)
Note: There may be more than one right 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
None of the above

Which of the following is convenient and correct way to automatically inject the model instances directly into your routes?

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

Which view facade within a service provider`s boot method can be used to share data with all views?

View::config(‘key’, ‘value’);
View::put(‘key’, ‘value’);
View::store(‘key’, ‘value’);
View::share(‘key’, ‘value’);

 How do you add default value to a select list in form.

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’
)
}}

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

Which of the following validator methods returns 'True' when form data is valid?

fails()
passes()
valid()
success(

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.

::find()
::destroy()
::all()
::show()

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

$iterate
$first
$index
$loop

Which of the following can be used in views to print a message if array is empty?

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

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.

<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

If you don’t want Eloquent to automatically manage created_at and updated_at columns, which of the following will be correct?

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

Which of the following code is correct to insert multiple records?

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

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

Which of the following is a correct way to assign middleware 'auth' to a route?

Route::get('profile', [
   'middleware' => 'auth',
   'uses' => 'UserController@show'<br<; a="">>]);

Route::get('profile', [
   'controller' => 'auth',
   'uses' => 'UserController@show'<br<; a="">>]);

Route::get('profile', [
   'secure' => 'auth',
   'uses' => 'UserController@show'<br<; a="">>]);

Route::get('profile', [
   'filter' => 'auth',
   'uses' => 'UserController@show'<br<; a="">>]);

List out few different return types of a controller action method?

View Result, Javascript Result
Redirect Result, Json Result
Content Result
All of the above

Which of the following is correct to create a route(s) to resource controller named "PostController"?

Route::resource('PostController', 'post');
Route::resource('post', 'PostController');
Route::get('post', 'PostController');
Route::post('post', 'PostController');

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'?

Request::get('foo', 'baz');
Request::only(['foo', 'baz']);
Request::except('foo', 'baz');

Add default value to select list in form.

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'
    )
}}

How access custom textbox name in Laravel using validation 'unique'?

'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

Route parameters should not have underscore '_' character?

True
False

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:

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

To execute the following statement without error, which of the following is correct?
 $flight = App\User::create(['name' => 'John Doe']);

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.

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

Routing
Module
Views
Forms

Which of the following is executed first?

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

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

@forelse ($users as $user)
<li>{{ $user->name }}</li>
@empty
<p>No users</p>
@endforelse

@while (true)
<p>I’m looping forever.</p>
@endwhile

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

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

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

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

Which of the following validation rules are acceptable?
Note: There may be more than one right answer.

[‘field’ => ‘accepted’]
[‘field’ => ‘active_url’]
[‘field’ => ‘alpha’]
[‘field’ => ‘after:10/10/16’]

Which one of the following is correct form encoding for file uploads?

<form method="post" type="multipart/form-data">
<form method="post">
<form method="get" enctype="multipart/form-data">
<form method="post" enctype="multipart/form-data">

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

Which of the following is correct command to save an uploaded file?

$request->file('avatar')->store('avatars');
$request->input('avatar')->store('avatars');
$request->file('avatar')->save('avatars');
$request->input('avatar')->save('avatars');

Which of the following is/are correct to define custom validation messages?
Note: There may be more than one right 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.

Which of the following is correct to create a model named 'Person' with accompanying migration?

php laravel make:model Person -m
php artisan make:model Person -m
php artisan make:model Person
php artisan create:model Person -m

Which of the following are correct ways to delete a model with primary key 2?
Note: There may be more than one right answer.

$flight = App\Flight::find(2);
$flight->delete();

$flight->delete(2);

App\Flight::destroy(2);

Which of the following can be included in route definition to validate form data?

Validator::valid($formData, $rules);
Validator::make($formData, $rules);
Validate::make($formData, $rules);
Validate::create($formData, $rules););

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?

get()
find()
add()
insert()

Validation If checkbox ticked then Input text is required?
Note: There may be more than one right answer.

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

How to route when using URL query string?

//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 ...
}

//routes.php
Route::get('stats/?name=*&device=*', 'StatsController@store');
//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 ...
}

//routes.php
Route::get('stats/{query}', 'StatsController@store');
//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 ...
}

All of the above

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

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

Which of the following is correct syntax for passing data to views? (choose all that apply)
Note: There may be more than one right answer.

return view(‘greetings’, [‘name’ => ‘Victoria’]);
return view(‘greeting’)->with(‘user’, ‘Victoria’);
return view(‘greeting’)->->withAll(compact(‘teams’))

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

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

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.

creating
created
updating
restoring

Which of the following is correct directory for view files?

app/views
storage/views
resources/views
public/views

Which of the following methods can be chained to get a single column from a database table?

->name(‘title’);
->get(‘title’);
->column(‘title’);
->pluck(‘title’);

How to use laravel routing for unknown number of parameters in URL.
Note: There may be more than one right answer.

//in routes.php
Route::Itemget('/{book?}/{chapter?}/{topic?}/{article?}/{sublevels?}', 'controller@func')->;;where('sublevels', '.*');
//in your controller
public function func($book = null, $chapter = null, $topic = null, $article = null, $sublevels = null) {
  //this will give you the array of sublevels
  if (!empty($sublevels) $sublevels = explode('/', $sublevels);
  ...
}

//in routes.php
Route::get('/{book?}/{chapter?}/{topic?}/{article?}/{sublevels?}', 'controller@func')->;;where('sublevels', '.*');
//in your controller
public function func($book = null, $chapter = null, $topic = null, $article = null, $sublevels = null) {
  //this will give you the array of sublevels
  if (!empty($sublevels) $sublevels = explode('/', $sublevels);
  ...
}

//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) {
  ...
}

//in routes.php
Route::Itemget('/{book?}/{chapter?}/{topic?}/{article?}', 'controller@func');
//in your controller
public function func($book = null, $chapter = null, $topic = null, $article = null) {
  ...
}

To get a single column from Database table we can chain one of the following method?

->name('title');
->get('title');
->column('title');
->pluck('title');

Which one of the following 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

Use a validation rules inside the custom validation class?

$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

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?

'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'
'avatar' => 'image:min_width=100,min_height=200'

Which of the following is correct to pass $name variable to views?
Note: There may be more than one right answer.

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'));
}

To retrieve all blog posts that have at least one comment. (Model has one to many relation already set up)

$posts = App\Post::has('comments')->get();
$posts = App\Post::find('comments')->get();
$posts = App\Post::find()->comments()->get();

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', $sets, $prod->set_id, array('class' => 'form-select', 'adddisabled')) }}
All of the above

Get only selected column from database table.

$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

All eloquent models protect against mass-assignment by default.

True
False

Which of the following methods should be used to alter the columns of an existing table?

Schema::alter()
Schema::create()
Schema::update()
Schema::table()

Which of the following HTML form actions are not supported?
Note: There may be more than one right answer.

PUT
POST
DELETE
PATCH

Which of the following artisan command is correct to create a model with table named ‘projects’?

php artisan make:model Project
php artisan create:model Project -m
php artisan create:table Project
php artisan make:model Project -m

Which of the following is correct to loop over an array named $lists in view?

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

Which of the following is the correct way to render the expression using javascript instead of blade?

Hello, {{ name }}.
Hello, ?{{ name }}.
Hello, @{{ name }}.
Hello, {{{ name }}}.

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

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

PostgreSQL
MySQL
SQLite
MongoDB

Which of the following command should be used to run all outstanding migration?

php artisan migrate:migration_name
php artisan migrate
php artisan create:migration
php artisan generate:migration

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

@template
@extends
@require
@include

How do you upload an image to a form with many to many relationships?
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’]));
$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

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

Laravel Framework Test Upwork 2019