<?php
namespace Laravel\Horizon\Http\Controllers;
class HomeController extends Controller
{
/**
* Single page application catch-all route.
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('horizon::app'); // what's the meaning of this 'horizon::app'
}
}
I found this syntax in the Laravel-Horizon Controller, can anyone explain this:
view('horizon::app');
What is the meaning of 'horizon::app'
?
What are the views? Views contain the html code required by your application, and it is a method in Laravel that separates the controller logic and domain logic from the presentation logic. Views are located in the resources folder, and its path is resources/views.
View Composers are callback or a class method that gets executed when a view is rendered. That means when Laravel loads a *. blade. php file to serve to the browser to display contents it executes View Composers.
MVC Architecture Of Laravel Model (M)–A model handles data used by the web application. View (V)–A view helps to display data to the user. Controller (C)–A controller interacts with the model to create data for the view.
Basically its know as Scope resolution operator (::) Simply it is token which allow access to static, constant and overridden properties of method of a class. Example- in laravel we call model like this.
Like others answers stated, that is known as view namespaces
. It not limited to the package's view, but you can use it inside your project as well.
As example you might have admin and customer module and want to differentiate their view by their own folder name, at this point you could use the namespace declaration. As example you might have these folders structures:
|- resources
|- views
|- admin
|- index.blade.php
|- customer
|- index.blade.php
Then you could register your own namespace that point to that particular folder path in AppServiceProvider.php
:
app('view')->addNamespace('admin', base_path() . '/resources/views/admin');
// or
app('view')->addNamespace('customer', base_path() . '/resources/views/customer');
And later on, inside controller's method, you can reference it using:
return view("admin::index");
// or
return view("customer::index");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With