While I was reading Laravel documentation, I faced a method named fresh and refresh on the Eloquent model. Please explain the major difference between them? I am having hard time understanding those.
            Asked
            
        
        
            Active
            
        
            Viewed 1.4k times
        
    15
            
            
         
    
    
        Gursewak Singh
        
- 642
- 1
- 7
- 20
1 Answers
16
            
            
        This is the comment for the refresh method on Illuminate\Database\Eloquent\Model :
/**
 * Reload the current model instance with fresh attributes from the database.
 *
 * @return $this
 */
public function refresh()
Here is the one for fresh:
/**
 * Reload a fresh model instance from the database.
 *
 * @param  array|string  $with
 * @return static|null
 */
public function fresh($with = [])
refresh will refresh the current model instance (including relationships). fresh will get a new instance of the model from the database and return it.
 
    
    
        lagbox
        
- 48,571
- 8
- 72
- 83