zoukankan      html  css  js  c++  java
  • 新建门脸Facade类

    1.AppContract目录下新建 CommonContract 类

     1 <?php
     2 namespace AppContract;
     3 
     4 use CarbonCarbon;
     5 use DimsavTranslatableTranslatable;
     6 
     7 /**
     8  * 通用函数封装类
     9  */
    10 class CommonContract
    11 {
    12     /**
    13      * 获取当前时间
    14      */
    15     public function gettime()
    16     {
    17         return Carbon::now();
    18     }
    19 
    20 }

    2.在App/Facades 下新建 CommonFacade 

     1 <?php
     2 namespace AppFacades;
     3 
     4 use IlluminateSupportFacadesFacade;
     5 
     6 
     7 /**
     8  * 通用门面代理类
     9  */
    10 class CommonFacade extends Facade
    11 {
    12     /**
    13      * 
    14      */
    15     protected static function getFacadeAccessor()
    16     {
    17         return 'AppContractCommonContract';
    18     }
    19 }

    3.config/app.php文件aliases数组注册服务提供者

    1 'Common' =>AppFacadesCommonFacade::class,

    4.在controller中引用

    1 use Common;
    2 
    3 Common::gettime();
  • 相关阅读:
    【转】双口RAM
    Beep使用
    fcntl函数
    ioctl() 参数
    线程属性:pthread_attr_t
    GPIO
    Linux CGI编程基础
    看门狗watchdog
    Linux库知识大全
    linux进程间通讯
  • 原文地址:https://www.cnblogs.com/clubs/p/11643061.html
Copyright © 2011-2022 走看看