public static function laravel code example

Example 1: how set variable public in static method in laravel

class ContentController extends BaseController {

    public static $text = null;

    public static function getContent($description)
    {
        $content = Content::where('description', $description)->first();
        return static::$text = $content->text;
    }
}

Example 2: static function model laravel

public static function isOpen($week)
{
    return (new static)::where('week', $week)->first();
}

Example 3: laravel public static variable

class Export extends Model {
    public static $itemsPerPage = 20;

	public function test() {
		static::$itemsPerPage;
    }
}

Tags:

Php Example