Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
evsmash/widgets / libs / Form.php
Size: Mime:
<?php

namespace Evsmash\Widgets;

use Evsmash\Core\Database\Eloquent;

use Evsmash\Core\Database\SoftDeleting;
use Evsmash\Core\Simpy\Params;

class Form extends Eloquent {

	use SoftDeleting;

	// params
	public function scopeParams($query, $params = false) {

		$scope = new Params();
		$scope->scope($query, $params);
		$scope->search(['email', 'data']);
		$scope->order(['id' => 'desc']);
		return $scope->query;

	}

	// data list
	public function getDataListAttribute() {

		// check if empty
		if(empty($this->data)) {
			return null;
		}

		// unserialize
		$data = unserialize($this->data, ['allowed_classes' => false]);

		// output
		return $data;

	}

	// recipients
	static public function recipients($setting) {

		// lines
		$lines = explode("\n", $setting);

		// one or multiple
		if(count($lines) == 1) {
			return false;
		}

		// multiple
		$output = [];
		foreach($lines as $line) {
			$recipient = explode('::', $line);
			$output[$recipient[0]] = $recipient[1];
		}
		return $output;

	}

}