<commit_before><?php

use Cviebrock\EloquentSluggable\SluggableInterface;
use Cviebrock\EloquentSluggable\SluggableTrait;
use Laracasts\Presenter\PresentableTrait;

class Candidate extends Eloquent implements SluggableInterface {

  use PresentableTrait;
  use SluggableTrait;

  /**
   * The presenter class for view logic.
   *
   * @var string
   */
  protected $presenter = 'CandidatePresenter';

  /**
   * The database table used by the model.
   *
   * @var string
   */
  protected $table = 'candidates';

  /**
   * The attributes which may be mass-assigned.
   *
   * @var array
   */
  protected $fillable = [
    'name', 'description', 'category_id'
  ];

  /**
   * Configuration for generating slug with Eloquent-Sluggable.
   *
   * @var array
   */
  protected $sluggable = [
    'build_from' => 'name',
    'save_to' => 'slug'
  ];

  public function category()
  {
    return $this->belongsTo('Category');
  }

  public function voters()
  {
    return $this->belongsToMany('User', 'votes');
  }

  public function savePhoto($photo)
  {
      $filename = $this->sluggify()->slug . '.jpg';

      // Save full-size image
      $photo->encode('jpg', 75)->save(public_path('images') . '/' . $filename);

      // Save thumbnail
      $photo->encode('jpg', 75)->fit(400)
        ->save(public_path('images') . '/' . 'thumb-' . $filename);

      $this->attributes['photo'] = $filename;
  }

  public function thumbnail()
  {
    if($this->photo) {
      return "/images/thumb-" . $this->photo;
    } else {
      return "/placeholder.png";
    }
  }
}
<commit_msg>Remove duplicated thumbnail from model.<commit_after><?php

use Cviebrock\EloquentSluggable\SluggableInterface;
use Cviebrock\EloquentSluggable\SluggableTrait;
use Laracasts\Presenter\PresentableTrait;

class Candidate extends Eloquent implements SluggableInterface {

  use PresentableTrait;
  use SluggableTrait;

  /**
   * The presenter class for view logic.
   *
   * @var string
   */
  protected $presenter = 'CandidatePresenter';

  /**
   * The database table used by the model.
   *
   * @var string
   */
  protected $table = 'candidates';

  /**
   * The attributes which may be mass-assigned.
   *
   * @var array
   */
  protected $fillable = [
    'name', 'description', 'category_id'
  ];

  /**
   * Configuration for generating slug with Eloquent-Sluggable.
   *
   * @var array
   */
  protected $sluggable = [
    'build_from' => 'name',
    'save_to' => 'slug'
  ];

  public function category()
  {
    return $this->belongsTo('Category');
  }

  public function voters()
  {
    return $this->belongsToMany('User', 'votes');
  }

  public function savePhoto($photo)
  {
      $filename = $this->sluggify()->slug . '.jpg';

      // Save full-size image
      $photo->encode('jpg', 75)->save(public_path('images') . '/' . $filename);

      // Save thumbnail
      $photo->encode('jpg', 75)->fit(400)
        ->save(public_path('images') . '/' . 'thumb-' . $filename);

      $this->attributes['photo'] = $filename;
  }

}

{'fraction_non_alphanumeric': 0.15249751902084022, 'fraction_numerical': 0.004631161098246774, 'mean_word_length': 2.8522292993630574, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5490172', 'n_tokens_mistral': 1042, 'n_tokens_neox': 998, 'n_words': 212}