Laravel - tips summary

 

A, Laravel ajax request to set the header

$.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}});



headers: {
    'X-CSRF-TOKEN': $("meta[name='csrf-token']").attr('content')
},

 

Two, session expiration time

'Lifetime' => the env ( 'SESSION_LIFETIME', 120 ) 

session from the session expiration time is the inactive time counted 
(not generated session time counted)

 

Third, the format of the table into the time

Adding the following methods Model document 

public  function GetDateFormat () {
     return 'Ymd H: I: s.u' ; 
}

 

Fourth, the repeated requests

When you call API, because of various reasons, the request fails. 
You can set multiple requests, reduce errors. 

return the retry (5, function () {
     // try to 5 times at intervals of 100 ms 
}, 100);

 

Five, see SQL

Print SQL debugging is common, you can use the following method 

toSql ()

 

Continued to supplement. . .

 

Guess you like

Origin www.cnblogs.com/rendd/p/11617506.html