Reputation: 375
Example :
Auth::guard($guard)->guest()
I dont get what double colon (::) notation means in laravel framework. from http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php I learn that it stand for scope resolution operator to access static, constant and overridden properties or methods of a class. but from laravel I learn that Auth
means the alias for class facade so I need an explanation of the example above especially guard(parameter)->guest()
means.
I'm still new to php and now learning laravel framework for my back-end.
Upvotes: 12
Views: 13408
Reputation: 26258
::
Scope Resolution Operator
::
is called as scope resolution operator
(AKA Paamayim Nekudotayim). This operator is used to refer the scope of some block or program context like classes, objects, namespace and etc. For this reference an identifier is used with this operator to access or reproduce the code inside that scope.
Auth::guard($guard)->guest()
: In this line you are using the guard() method of static class Auth
. To use the function of a static class we use ::
Scope Resolution Operator.
Upvotes: 14
Reputation: 1513
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
User::select('name')->get()->toArray()
;
Upvotes: 1
Reputation: 8678
You are likely encountering this as a way of accessing a static method or property of a class.
For example:
class Foo
{
public static function bar()
{
return "bar";
}
}
Foo::bar // access the bar method without instantiating the Foo class.
Upvotes: 5