PHP code example of jshannon63 / laravel-baton

1. Go to this page and download the library: Download jshannon63/laravel-baton library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jshannon63 / laravel-baton example snippets


array:1 [▼
  "routes" => Collection {#201 ▼
    #items: array:9 [▼
      "blogs" => Collection {#206 ▼
        #items: array:2 [▼
          "uri" => "blog"
          "methods" => array:2 [▼
            0 => "GET"
            1 => "HEAD"
          ]
        ]
      }
      "login" => Collection {#205 ▶}
      "logout" => Collection {#216 ▶}
      "register" => Collection {#217 ▶}
      "password.request" => Collection {#218 ▶}
      "password.email" => Collection {#219 ▶}
      "password.reset" => Collection {#220 ▶}
      "home" => Collection {#221 ▶}
      "about" => Collection {#222 ▶}
    ]
  }
]


use Facades/Jshannon63/Baton/Baton;



Baton::put( 'article', Blog::find(1) );


...  
  
<!-- JAVASCRIPT -->
<script type="text/javascript" src="/js/app.js"></script>
<script type="text/javascript">
    {!!$baton!!}
</script>
<!-- END JAVASCRIPT -->

</body>
</html>

...    
  
<!-- JAVASCRIPT -->
<script type="text/javascript" src="/js/app.js"></script>
<script type="text/javascript">
    var baton = JSON.parse('{"routes":{"blogs":{"uri":"blog","methods":["GET","HEAD"]},"login":{"uri":"login","methods":["GET","HEAD"]},"logout":{"uri":"logout","methods":["POST"]},"register":{"uri":"register","methods":["GET","HEAD"]},"password.request":{"uri":"password\/reset","methods":["GET","HEAD"]},"password.email":{"uri":"password\/email","methods":["POST"]},"password.reset":{"uri":"password\/reset\/{token}","methods":["GET","HEAD"]},"home":{"uri":"home","methods":["GET","HEAD"]},"about":{"uri":"about","methods":["GET","HEAD"]}}}');
</script>
<!-- END JAVASCRIPT -->

</body>
</html>
js
BATON_ROUTES = false    // Disable returning named routes in Baton