<commit_before><?php namespace Fbf\LaravelCompetitions;

class Competition extends \Eloquent {

	/**
	 * Status values for the database
	 */
	const DRAFT = 'DRAFT';
	const APPROVED = 'APPROVED';

	const CLOSED = 'closed';
	const REQUIRES_LOGIN = 'requires_login';
	const ALREADY_ENTERED = 'already_entered';
	const INVALID = 'invalid';

	/**
	 * Name of the table to use for this model
	 * @var string
	 */
	protected $table = 'fbf_competitions';

	/**
	 * The prefix string for config options.
	 *
	 * Defaults to the package's config prefix string
	 *
	 * @var string
	 */
	protected $configPrefix = 'laravel-competitions::';

	/**
	 * Used for Cviebrock/EloquentSluggable
	 * @var array
	 */
	public static $sluggable = array(
		'build_from' => 'title',
		'save_to' => 'slug',
		'separator' => '-',
		'unique' => true,
		'include_trashed' => true,
	);

	/**
	 * Defines the Competition hasMany Entries relationship
	 *
	 * @return mixed
	 */
	public function entries()
	{
		return $this->hasMany('Fbf\LaravelCompetitions\Entry');
	}

	/**
	 * Query scope for "live" items, adds conditions for status = APPROVED and published date is in the past
	 *
	 * @param $query
	 * @return mixed
	 */
	public function scopeLive($query)
	{
		return $query->where($this->getTable().'.status', '=', Competition::APPROVED)
			->where($this->getTable().'.published_date', '<=', \Carbon\Carbon::now());
	}

	/**
	 * Returns the HTML img tag for the requested image type and size for this item
	 *
	 * @param $type
	 * @param $size
	 * @return null|string
	 */
	public function getImage($type, $size)
	{
		if (empty($this->$type))
		{
			return null;
		}
		$html = '<img src="' . $this->getImageSrc($type, $size) . '"';<commit_msg>Adding query scopes for open and closed competitions<commit_after><?php namespace Fbf\LaravelCompetitions;

class Competition extends \Eloquent {

	/**
	 * Status values for the database
	 */
	const DRAFT = 'DRAFT';
	const APPROVED = 'APPROVED';

	const CLOSED = 'closed';
	const REQUIRES_LOGIN = 'requires_login';
	const ALREADY_ENTERED = 'already_entered';
	const INVALID = 'invalid';

	/**
	 * Name of the table to use for this model
	 * @var string
	 */
	protected $table = 'fbf_competitions';

	/**
	 * The prefix string for config options.
	 *
	 * Defaults to the package's config prefix string
	 *
	 * @var string
	 */
	protected $configPrefix = 'laravel-competitions::';

	/**
	 * Used for Cviebrock/EloquentSluggable
	 * @var array
	 */
	public static $sluggable = array(
		'build_from' => 'title',
		'save_to' => 'slug',
		'separator' => '-',
		'unique' => true,
		'include_trashed' => true,
	);

	/**
	 * Defines the Competition hasMany Entries relationship
	 *
	 * @return mixed
	 */
	public function entries()
	{
		return $this->hasMany('Fbf\LaravelCompetitions\Entry');
	}

	/**
	 * Query scope for "live" items, adds conditions for status = APPROVED and published date is in the past
	 *
	 * @param $query
	 * @return mixed
	 */
	public function scopeLive($query)
	{
		return $query->where($this->getTable().'.status', '=', Competition::APPROVED)
			->where($this->getTable().'.published_date', '<=', \Carbon\Carbon::now());
	}

	/**
	 * Query scope for "open" items, adds conditions for closing date is in the future
	 *
	 * @param $query
	 * @return mixed
	 */
	public function scopeOpen($query)
	{
		return $query->where($this->getTable().'.closing_date', '>=', \Carbon\Carbon::now());
	}

	/**
	 * Query scope for "open" items, adds conditions for closing date is in the future
	 *
	 * @param $query
	 * @return mixed
	 */
	public function scopeClosed($query)
	{
		return $query->where($this->getTable().'.closing_date', '<=', \Carbon\Carbon::now());
	}

	/**
	 * Returns the HTML img tag for the requested image type and size for this item
	 *
	 * @param $type
	 * @param $size
	 * @return null|string
	 */
	public function getImage($type, $size)
	{
		if (empty($this->$type))
		{
			return null;
		}
		$html = '<img src="' . $this->getImageSrc($type, $size) . '"';
{'fraction_non_alphanumeric': 0.15546113471632092, 'fraction_numerical': 0.0, 'mean_word_length': 3.5374149659863945, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 32, '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': '4908397', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1308, 'n_words': 367}