/**
  * Controller constructor.
  * @param $module
  * @param $entity
  */
 public function __construct($module, $entity)
 {
     $this->module = Parse::camelize($module, true);
     $this->entity = Parse::camelize($entity, true);
     $path = Path::name($this->module, $this->entity);
     $this->model = new $path();
 }
Example #2
0
 /**
  * @param $operation
  * @param $module
  * @param $entity
  * @param $spell
  */
 private static function language($operation, $module, $entity, $spell)
 {
     $__default = 'default';
     if ($spell === $__default) {
         $spell = AwesovelServiceProvider::$LANGUAGE;
     }
     $filename = Path::app([config('awesovel')['root'], $module, 'Language', $entity, $spell . '.lng']);
     $content = file_get_contents($filename);
     $translations = Json::decode($content);
     $id = $operation->id;
     $default = $translations->{$__default};
     $language = $default;
     if (isset($translations->{$id})) {
         $language = $translations->{$id};
     }
     /*
      * recover spell to label
      */
     $operation->label = $language->label;
     /*
      * recover spell to items
      */
     foreach ($operation->items as $key => $item) {
         if (isset($language->items->{$key})) {
             foreach ($language->items->{$key} as $__property => $__stub) {
                 $operation->items->{$key}->{$__property} = $language->items->{$key}->{$__property};
             }
         } else {
             if (isset($default->items->{$key})) {
                 foreach ($default->items->{$key} as $__property => $__stub) {
                     $operation->items->{$key}->{$__property} = $default->items->{$key};
                 }
             }
         }
         $operation->items->{$key}->id = $key;
     }
     /*
      * recover spell to operations
      */
     foreach ($operation->operations as $key => $__operation) {
         $id = $__operation->id;
         $properties = ['label' => $default->label, 'title' => ""];
         foreach ($properties as $property => $__default) {
             $__operation->{$property} = $__default;
             if (isset($language->operations) && isset($language->operations->{$id}) && isset($language->operations->{$id}->{$property})) {
                 $__operation->{$property} = $language->operations->{$id}->{$property};
             } else {
                 if (isset($translations->{$id}) && isset($translations->{$id}->{$property})) {
                     $__operation->{$property} = $translations->{$id}->{$property};
                 }
             }
         }
         $operation->operations[$key] = $__operation;
     }
     return $operation;
 }
 /**
  * Parse static requests
  *
  * @param $route
  * @return Response
  */
 public static function stt($route)
 {
     $filename = "";
     $root = isset($route[0]) ? $route[0] : null;
     switch ($root) {
         case 'assets':
             array_shift($route);
             $filename = Path::assets($route);
             break;
     }
     if (File::exists($filename)) {
         return self::render($filename);
     }
 }
Example #4
0
 /**
  *
  * @param type $item
  * @return type
  */
 public function relationshipDefaultModel($item)
 {
     $relationship = $item->relationship;
     $related = Path::name($relationship->module, $relationship->entity);
     $type = $relationship->type;
     switch ($type) {
         case 'one-to-one':
             return $this->hasOne($related, $relationship->key);
         case 'one-to-many':
             return $this->hasMany($related, $relationship->key, $relationship->local);
         default:
             break;
     }
 }