<commit_before><?php namespace Mascame\Artificer\Fields\Types\Relations;

use Request;
use Route;
use Session;

// Todo: attach somehow the new created items to the a new item (which have not yet been created)

class hasMany extends Relation {

	public function boot()
	{
		//$this->addWidget(new Chosen());
		$this->attributes->add(array('class' => 'chosen'));
		$this->modelObject = \App::make('artificer-model');
	}

	public function input()
	{
		$this->fields = array_get(\View::getShared(), 'fields');
		$id = $this->fields['id']->value;

		$modelName = $this->relation->getRelatedModel();
		$model = $this->modelObject->models[$modelName];
		$model['class'] = $this->modelObject->getClass($modelName);
		$this->model = $model;

        if ((Route::currentRouteName() == 'admin.model.create' || Route::currentRouteName() == 'admin.model.field')
            && Session::has('_set_relation_on_create_'.$this->modelObject->name)) {
            $relateds = Session::get('_set_relation_on_create_'.$this->modelObject->name);

            $related_ids = array();
            foreach ($relateds as $related) {
                $related_ids[] = $related['id'];
            }

            $data = $relateds[0]['modelClass']::whereIn('id', $related_ids)->get()->toArray();
        } else {
            $data = $model['class']::where($this->relation['foreign'], '=', $id)->get(array('id', $this->relation->getShow()))->toArray();
        }<commit_msg>fix regarding model<commit_after><?php namespace Mascame\Artificer\Fields\Types\Relations;

use Request;
use Route;
use Session;

// Todo: attach somehow the new created items to the a new item (which have not yet been created)

class hasMany extends Relation {

	public function boot()
	{
		//$this->addWidget(new Chosen());
		$this->attributes->add(array('class' => 'chosen'));
		$this->modelObject = \App::make('artificer-model');
	}

	public function input()
	{
		$this->fields = array_get(\View::getShared(), 'fields');
		$id = $this->fields['id']->value;

		$modelName = $this->relation->getRelatedModel();
		$model = $this->modelObject->models[$modelName];
		$model['class'] = $this->modelObject->schema->getClass($modelName);
		$this->model = $model;

        if ((Route::currentRouteName() == 'admin.model.create' || Route::currentRouteName() == 'admin.model.field')
            && Session::has('_set_relation_on_create_'.$this->modelObject->name)) {
            $relateds = Session::get('_set_relation_on_create_'.$this->modelObject->name);

            $related_ids = array();
            foreach ($relateds as $related) {
                $related_ids[] = $related['id'];
            }

            $data = $relateds[0]['modelClass']::whereIn('id', $related_ids)->get()->toArray();
        } else {
            $data = $model['class']::where($this->relation['foreign'], '=', $id)->get(array('id', $this->relation->getShow()))->toArray();
        }
{'fraction_non_alphanumeric': 0.19710544452102, 'fraction_numerical': 0.0006891798759476223, 'mean_word_length': 3.7126623376623376, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, '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': '6033890', 'n_tokens_mistral': 919, 'n_tokens_neox': 887, 'n_words': 162}