title: How to make a Trait in Laravel
body: <p>Where to make the file if i want to use this trait on my Models</p>
  
  <p>How should this file look like if i want to have this trait inside:</p>
  
  <pre><code>trait FormatDates
  {
      protected $newDateFormat = 'd.m.Y H:i';
  
  
      // save the date in UTC format in DB table
      public function setCreatedAtAttribute($date){
  
          $this-&gt;attributes['created_at'] = Carbon::parse($date);
  
      }
  
      // convert the UTC format to my format
      public function getCreatedAtAttribute($date){
  
          return Carbon::parse($date)-&gt;format($this-&gt;newDateFormat);
  
      }
  
      // save the date in UTC format in DB table
      public function setUpdatedAtAttribute($date){
  
          $this-&gt;attributes['updated_at'] = Carbon::parse($date);
  
      }
  
      // convert the UTC format to my format
      public function getUpdatedAtAttribute($date){
  
          return Carbon::parse($date)-&gt;format($this-&gt;newDateFormat);
  
      }
  
      // save the date in UTC format in DB table
      public function setDeletedAtAttribute($date){
  
          $this-&gt;attributes['deleted_at'] = Carbon::parse($date);
  
      }
  
      // convert the UTC format to my format
      public function getDeletedAtAttribute($date){
  
          return Carbon::parse($date)-&gt;format($this-&gt;newDateFormat);
  
      }
  }
  </code></pre>
  
  <p>And how to apply it for example on a User Model class...</p>