본문 바로가기

개발/Laravel

Laravel Singleton 구현

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class File extends Model
{
    // Singleton
    private static $singleton;

    public static function getInstance() {
        if(!isset(File::$singleton)) File::$singleton = new File('');
        return File::$singleton;
    }

    function __construct() {

    }
}
반응형

'개발 > Laravel' 카테고리의 다른 글

Laravel Storage 라라벨 외부 파일 업로드  (0) 2020.06.26
Laravel Eloquent Static Method  (0) 2020.06.24
Laravel Dependency Injection Container - 1  (0) 2020.06.23
Laravel 6 Auth Login  (0) 2020.06.18
Laravel 6 Custom Exception  (0) 2020.06.10