master

laravel/framework

Last updated at: 29/12/2023 09:21

Factory.php

TLDR

The Factory interface in the Illuminate\Contracts\Auth namespace defines two methods: guard() and shouldUse(). It is used to get guard instances and set the default guard that the factory should serve for authentication.

Methods

guard($name = null)

This method is used to get a guard instance by name. It accepts an optional parameter $name and returns an instance of either Guard or StatefulGuard from the Illuminate\Contracts\Auth namespace.

shouldUse($name)

This method is used to set the default guard that the factory should serve. It accepts a parameter $name of type string and does not return a value.

<?php

namespace Illuminate\Contracts\Auth;

interface Factory
{
    /**
     * Get a guard instance by name.
     *
     * @param  string|null  $name
     * @return \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard
     */
    public function guard($name = null);

    /**
     * Set the default guard the factory should serve.
     *
     * @param  string  $name
     * @return void
     */
    public function shouldUse($name);
}