<commit_before><?php

class StreetSnap extends Eloquent {

	protected $visible=array('id', 'name', 'affiliation', 'cached_total_likes', 'cached_total_comments', 'user', 'primary', 'meta', 'single_url', 'likes', 'liked');
	protected $appends=array('single_url');
	protected $category;
	protected $slug;

	public function user() {
		return $this->belongsTo('User');
	}

	public function primary() {
		return $this->hasOne('StreetSnapPrimary', 'snap_id');
	}

	public function attachments() {
		return $this->hasMany('StreetSnapAttachment', 'snap_id');
	}

	public function pins() {
		return $this->morphMany('PinTag', 'target');
	}

	public function meta() {
		return $this->morphTo();
	}

	public function setContext($category=null, $slug=null) {
		$this->category=$category;
		$this->slug=$slug;
		return $this;
	}

	public function likes() {
		return $this->morphMany('UserLike', 'target');
	}

	/*
	public function liked() {
		$liked=UserLike::where('target_type', '=', 'StreetSnap')->where('target_id', '=', $this->id)->where('user_id', '=', Auth::user()->id)->first();
		return $liked;
	}
	*/

	/*
	public function myLike() {
		return $this->hasOne('Like', '');
	}
	*/

	/*
	public function pinlinks() {
		return $this->hasManyThrough('PinLink', 'PinTag', null, 'pin_id');
	}
	*/

	public function liked() {
		if(Auth::check()) {
			return $this->morphMany('UserLike', 'target')->where('user_id', '=', Auth::user()->id);
		} else {
			return $this->morphMany('UserLike', 'target')->where('user_id', '=', 0);
		}
	}

	public function getSingleUrlAttribute() {
		if($this->category=='all') {
			$metaCategory=array(
				'CampusMeta'=>'campus',
				'ClubMeta'=>'club',
				'FashionWeekMeta'=>'fashion-week',
				'FestivalMeta'=>'festival',
				'StreetMeat'=>'street'
			);

			return action('StreetSnapController@getSingle', array('category'=>$metaCategory[$this->meta_type], 'slug'=>$this->meta->slug, 'id'=>$this->id));
		} elseif($this->category=='men' || $this->category=='ladies') {
			return action('StreetSnapController@getSingle', array('category'=>'filter', 'slug'=>$this->category, 'id'=>$this->id));
		} else {
			return action('StreetSnapController@getSingle', array('category'=>$this->category, 'slug'=>$this->slug, 'id'=>$this->id));
		}
	}
<commit_msg>Modified StreetSnap model to return url even when context is not set.<commit_after><?php

class StreetSnap extends Eloquent {

	protected $visible=array('id', 'name', 'affiliation', 'cached_total_likes', 'cached_total_comments', 'user', 'primary', 'meta', 'single_url', 'likes', 'liked');
	protected $appends=array('single_url');
	protected $category;
	protected $slug;

	public function user() {
		return $this->belongsTo('User');
	}

	public function primary() {
		return $this->hasOne('StreetSnapPrimary', 'snap_id');
	}

	public function attachments() {
		return $this->hasMany('StreetSnapAttachment', 'snap_id');
	}

	public function pins() {
		return $this->morphMany('PinTag', 'target');
	}

	public function meta() {
		return $this->morphTo();
	}

	public function setContext($category=null, $slug=null) {
		$this->category=$category;
		$this->slug=$slug;
		return $this;
	}

	public function likes() {
		return $this->morphMany('UserLike', 'target');
	}

	/*
	public function liked() {
		$liked=UserLike::where('target_type', '=', 'StreetSnap')->where('target_id', '=', $this->id)->where('user_id', '=', Auth::user()->id)->first();
		return $liked;
	}
	*/

	/*
	public function myLike() {
		return $this->hasOne('Like', '');
	}
	*/

	/*
	public function pinlinks() {
		return $this->hasManyThrough('PinLink', 'PinTag', null, 'pin_id');
	}
	*/

	public function liked() {
		if(Auth::check()) {
			return $this->morphMany('UserLike', 'target')->where('user_id', '=', Auth::user()->id);
		} else {
			return $this->morphMany('UserLike', 'target')->where('user_id', '=', 0);
		}
	}

	public function getSingleUrlAttribute() {
		if($this->category=='all' || $this->category===null) {
			$metaCategory=array(
				'CampusMeta'=>'campus',
				'ClubMeta'=>'club',
				'FashionWeekMeta'=>'fashion-week',
				'FestivalMeta'=>'festival',
				'StreetMeat'=>'street'
			);

			return action('StreetSnapController@getSingle', array('category'=>$metaCategory[$this->meta_type], 'slug'=>$this->meta->slug, 'id'=>$this->id));
		} elseif($this->category=='men' || $this->category=='ladies') {
			return action('StreetSnapController@getSingle', array('category'=>'filter', 'slug'=>$this->category, 'id'=>$this->id));
		} else {
			return action('StreetSnapController@getSingle', array('category'=>$this->category, 'slug'=>$this->slug, 'id'=>$this->id));
		}
	}

{'fraction_non_alphanumeric': 0.2197921177999134, 'fraction_numerical': 0.00043308791684711995, 'mean_word_length': 5.5240112994350286, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 96, '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': '4088205', 'n_tokens_mistral': 1718, 'n_tokens_neox': 1571, 'n_words': 268}