bug problem Laravel save part of the field failed to solve

Problem Description: Today in the preparation of the api update section, discover how some of the fields are updated update does not go up.

Troubleshooting:

  1. After several tests and found that each submission can only update some of the fields, the fields are: id, user_id, device_room_id, name, desc
  2. Test repeatedly found desc field is empty when it can be updated to empty
  3. Consideration whether a problem is automatically filled, automatic filling detection code found only when judged absent or empty is set to null
  4. Repair determination, if the present value is set to this value

 

Resolution code:

    // Source Code 
    // set a default value field desc 
    public  function setDescAttribute ( $ value ) 
    { 
        IF ( empty ( $ value )) {
             $ the this -> Attributes [ 'desc'] = '' ; 
        } 
    }
    // After modifying the code 
    // Set default value field desc 
    public  function setDescAttribute ( $ value ) 
    { 
        IF ( empty ( $ value )) {
             $ the this -> Attributes [ 'desc'] = '' ; 
        } the else {
             $ the this -> Attributes [ 'desc'] = $ value ; 
        } 
    }

 

Guess you like

Origin www.cnblogs.com/xiaqiuchu/p/11456538.html