<commit_before><?php

Class TemplatesController extends AdminBaseController {

	const VoucherHome = 'tpl.voucher.index';
	const EmailHome = 'tpl.email.index';

	public function getVoucherTemplates()
	{
		$tpls = VoucherTemplate::paginate(10);
		return View::make('admin.templates.vouchers.index')
							->with('templates',$tpls);
	}

	public function getAddVoucherTemplate()	
	{
		return View::make('admin.templates/vouchers/add-edit');
	}

	public function postAddVoucherTemplate()
	{
		$input = Input::all();

		//validation input here.
		
		$this->flash(VoucherTemplate::create($input));

		return Redirect::route(self::VoucherHome);
	}

	public function getEditVoucherTemplate($id)
	{
		try{
			$tpl = VoucherTemplate::findOrFail($id);
			return View::make('admin.templates/vouchers/add-edit')
						->with('template',$tpl);
		}
		catch(Illuminate\Database\Eloquent\ModelNotFoundException $e) {
			App::abort(404);
		}
	}

	public function postEditVoucherTemplate()
	{
		if( ! Input::has('id')) {
			return Redirect::route(self::VoucherHome);
		}
		$input = Input::all();
		try{
			$tpl = VoucherTemplate::findOrFail($input['id']);
			$tpl->fill( $input );
			$this->flash( $tpl->save() );
			return Redirect::route(self::VoucherHome);
		}
		catch(Illuminate\Database\Eloquent\ModelNotFoundException $e) {
			App::abort(404);
		}
	}

	public function postDeleteVoucherTemplate($id)
	{
		$this->flash( VoucherTemplate::destroy($id) );
		return Redirect::route(self::VoucherHome);
	}

	public function getEmailTemplates()
	{
		$tpls = EmailTemplate::paginate(10);
		return View::make('admin.templates.email.index')
						->with('templates',$tpls);
	}

	public function getAddEmailTemplate()
	{
		return View::make('admin.templates.email.add-edit');
	}

	public function postAddEmailTemplate()
	{
		$input = Input::all();
		//validate input.
		$this->flash( EmailTemplate::create($input) );
		return Redirect::route(self::EmailHome);
	}

	public function getEditEmailTemplate($id)
	{
		try{
			$tpl = EmailTemplate::findOrFail($id);
			return View::make('admin.templates/email/add-edit')
						->with('template',$tpl);
		}
		catch(Illuminate\Database\Eloquent\ModelNotFoundException $e) {
			App::abort(404);
		}
	}

	public function postEditEmailTemplate()
	{
		if( ! Input::has('id')) {
			return Redirect::route(self::EmailHome);
		}
		$input = Input::all();
		try{
			$tpl = EmailTemplate::findOrFail($input['id']);
			$tpl->fill( $input );
			$this->flash( $tpl->save() );
			return Redirect::route(self::EmailHome);
		}
		catch(Illuminate\Database\Eloquent\ModelNotFoundException $e) {
			App::abort(404);
		}
	}

	public function postDeleteEmailTemplate($id)
	{
		$this->flash( EmailTemplate::destroy($id) );
		return Redirect::route(self::EmailHome);
	}

}<commit_msg>replaced old flash method with notifySuccess/notifyError methods.<commit_after><?php

Class TemplatesController extends AdminBaseController {

	const VoucherHome = 'tpl.voucher.index';
	const EmailHome = 'tpl.email.index';

	public function getVoucherTemplates()
	{
		$tpls = VoucherTemplate::paginate(10);
		return View::make('admin.templates.vouchers.index')
							->with('templates',$tpls);
	}

	public function getAddVoucherTemplate()	
	{
		return View::make('admin.templates/vouchers/add-edit');
	}

	public function postAddVoucherTemplate()
	{
		$input = Input::all();

		//validation input here.

		if( VoucherTemplate::create($input) ) {
			$this->notifySuccess("Voucher Template Created.");
		} else {
			$this->notifyError("Voucher Template Creation Failed.");
		}
		return Redirect::route(self::VoucherHome);
	}

	public function getEditVoucherTemplate($id)
	{
		try{
			$tpl = VoucherTemplate::findOrFail($id);
			return View::make('admin.templates/vouchers/add-edit')
						->with('template',$tpl);
		}
		catch(Illuminate\Database\Eloquent\ModelNotFoundException $e) {
			App::abort(404);
		}
	}

	public function postEditVoucherTemplate()
	{
		if( ! Input::has('id')) {
			return Redirect::route(self::VoucherHome);
		}
		$input = Input::all();
		try{
			$tpl = VoucherTemplate::findOrFail($input['id']);
			$tpl->fill( $input );
			if( $tpl->save() ) {
				$this->notifySuccess("Voucher Template Updated.");
			} else {
				$this->notifyError("Voucher Template Updation Failed.");
			}
			return Redirect::route(self::VoucherHome);
		}
		catch(Illuminate\Database\Eloquent\ModelNotFoundException $e) {
			App::abort(404);
		}
	}

	public function postDeleteVoucherTemplate($id)
	{
		$this->flash( VoucherTemplate::destroy($id) );
		return Redirect::route(self::VoucherHome);
	}

	public function getEmailTemplates()
	{
		$tpls = EmailTemplate::paginate(10);
		return View::make('admin.templates.email.index')
						->with('templates',$tpls);
	}

	public function getAddEmailTemplate()
	{
		return View::make('admin.templates.email.add-edit');
	}

	public function postAddEmailTemplate()
	{
		$input = Input::all();
		//validate input.
		$this->flash( EmailTemplate::create($input) );
		return Redirect::route(self::EmailHome);
	}

	public function getEditEmailTemplate($id)
	{
		try{
			$tpl = EmailTemplate::findOrFail($id);
			return View::make('admin.templates/email/add-edit')
						->with('template',$tpl);
		}
		catch(Illuminate\Database\Eloquent\ModelNotFoundException $e) {
			App::abort(404);
		}
	}

	public function postEditEmailTemplate()
	{
		if( ! Input::has('id')) {
			return Redirect::route(self::EmailHome);
		}
		$input = Input::all();
		try{
			$tpl = EmailTemplate::findOrFail($input['id']);
			$tpl->fill( $input );
			$this->flash( $tpl->save() );
			return Redirect::route(self::EmailHome);
		}
		catch(Illuminate\Database\Eloquent\ModelNotFoundException $e) {
			App::abort(404);
		}
	}

	public function postDeleteEmailTemplate($id)
	{
		$this->flash( EmailTemplate::destroy($id) );
		return Redirect::route(self::EmailHome);
	}

}
{'fraction_non_alphanumeric': 0.16817638010596478, 'fraction_numerical': 0.0054691505725517, 'mean_word_length': 4.75984251968504, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '7054722', 'n_tokens_mistral': 2244, 'n_tokens_neox': 2033, 'n_words': 301}