예제 #1
0
파일: Acl.php 프로젝트: larakit/lk
 /**
  * Возвращает причину отказа на доступ
  * Если причин нет - возвращает false, что означает наличие доступа
  *
  * @param type $action
  *
  * @return boolean
  */
 function reason($action = 'manage')
 {
     $callback = [$this, 'reason' . \Str::studly($action)];
     if (is_callable($callback)) {
         return call_user_func($callback);
     }
     //по умолчанию разрешаем все!
     return false;
 }
예제 #2
0
 /**
  * @param      $name
  * @param null $container
  *
  * @return ElementTbText
  */
 function add($name, $container = null)
 {
     $method = \Str::studly('add_' . $name);
     if (!$container) {
         $container = $this->form;
     }
     $element = call_user_func([$this, $method], $container);
     /* @var ElementTbText $element */
     $element->toggleFrozen(!$this->isFieldEnabled($name));
     if (!$element->getLabel()) {
         $element->setLabel($this->model->getEntityLabel($name));
     }
     return $element;
 }
예제 #3
0
 protected function _validate($attribute, $rule)
 {
     list($rule, $parameters) = $this->_parseRule($rule);
     if ($rule == '') {
         return true;
     }
     $method = '_validate' . Str::studly($rule);
     $value = $this->_getValue($attribute);
     if (!$this->{$method}($attribute, $value, $parameters, $this)) {
         $this->_addFailure($attribute, $rule, $parameters);
         return false;
     }
     return true;
 }
 /**
  * Fetch the compiled template for a migration
  *
  * @param  string $template Path to template
  * @param  string $name
  * @return string Compiled template
  */
 protected function getTemplate($template, $name)
 {
     // We begin by fetching the master migration stub.
     $stub = $this->file->get(__DIR__ . '/templates/migration/migration.txt');
     // Next, set the migration class name
     $stub = str_replace('{{name}}', \Str::studly($name), $stub);
     // Now, we're going to handle the tricky
     // work of creating the Schema
     $upMethod = $this->getUpStub();
     $downMethod = $this->getDownStub();
     // Finally, replace the migration stub with the dynamic up and down methods
     $stub = str_replace('{{up}}', $upMethod, $stub);
     $stub = str_replace('{{down}}', $downMethod, $stub);
     return $stub;
 }
예제 #5
0
 /**
  * Set a given attribute on the model.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return void
  */
 public function setAttribute($key, $value)
 {
     // First we will check for the presence of a mutator for the set operation
     // which simply lets the developers tweak the attribute as it is set on
     // the model, such as "json_encoding" an listing of data for storage.
     if ($this->hasSetMutator($key)) {
         $method = 'set' . Str::studly($key) . 'Attribute';
         return $this->{$method}($value);
     } elseif (in_array($key, $this->getDates()) && $value) {
         $value = $this->fromDateTime($value);
     }
     if ($this->isArrayCastable($key) && !is_null($value)) {
         $value = self::arrayStringify($value);
     }
     if ($this->isJsonCastable($key) && !is_null($value)) {
         $value = json_encode($value);
     }
     $this->attributes[$key] = $value;
 }
예제 #6
0
 public function store()
 {
     //make plural, title case
     $title = mb_convert_case(Str::plural(Input::get('title')), MB_CASE_TITLE, 'UTF-8');
     //determine table name, todo check if unique
     $name = Str::slug($title, '_');
     //model name
     $model = Str::singular(Str::studly($title));
     //enforce predence always ascending
     $order_by = Input::get('order_by');
     $direction = Input::get('direction');
     if ($order_by == 'precedence') {
         $direction = 'asc';
     }
     //create entry in objects table for new object
     $object_id = DB::table(DB_OBJECTS)->insertGetId(['title' => $title, 'name' => $name, 'model' => $model, 'order_by' => $order_by, 'direction' => $direction, 'list_grouping' => Input::get('list_grouping'), 'updated_at' => new DateTime(), 'updated_by' => Auth::user()->id]);
     //create title field for table by default
     DB::table(DB_FIELDS)->insert(['title' => 'Title', 'name' => 'title', 'type' => 'string', 'visibility' => 'list', 'required' => 1, 'object_id' => $object_id, 'updated_at' => new DateTime(), 'updated_by' => Auth::user()->id, 'precedence' => 1]);
     self::addTable($name, true);
     self::saveSchema();
     return Redirect::action('InstanceController@index', $name);
 }
예제 #7
0
 private function validate($attribute, $rule)
 {
     list($rule, $parameters) = $this->parseRule($rule);
     $value = $this->getValue($attribute);
     $method = 'validate' . Str::studly($rule);
     if ($rule != 'required' && $value === null) {
         return true;
     }
     if (!$this->{$method}($attribute, $value, $parameters)) {
         if (in_array($rule, ['min', 'max', 'contain', 'size'])) {
             $this->message = sprintf($this->validateMessages[$rule], $attribute, $parameters[0]);
         } elseif ($rule == 'between') {
             $this->message = sprintf($this->validateMessages[$rule], $attribute, $parameters[0], $parameters[1]);
         } elseif ($rule == 'in') {
             $this->message = sprintf($this->validateMessages[$rule], $attribute, implode(', ', $parameters));
         } else {
             $this->message = sprintf($this->validateMessages[$rule], $attribute);
         }
         return false;
     }
     return true;
 }
예제 #8
0
파일: HelperEntity.php 프로젝트: larakit/lk
 static function getFormFilterClass()
 {
     $object = self::getArgs(func_get_args());
     $entity = \Str::studly(self::getEntity($object));
     $vendor = self::vendorToStudly(self::getVendor($object));
     $section = \Str::studly(self::getSection($object));
     return $vendor . '\\FormFilter\\FormFilter' . $entity . $section;
 }
예제 #9
0
 /**
  * 
  * Revert data
  * @param $id
  */
 function revert($id)
 {
     $dataLog = LogsBaseModel::find($id);
     if ('update' == $dataLog->type_task && strlen($dataLog->pre_content) > 0) {
         $preContent = json_decode($dataLog->pre_content, true);
         $class = Str::studly($dataLog->module) . Str::studly(Request::segment(2)) . 'Model';
         $model = new $class();
         if ($model->where('id', $preContent['id'])->update($preContent)) {
             Session::flash('flash-message', 'Revert Success !');
         }
     }
     return Redirect::to($this->moduleURL . 'show-list');
 }
예제 #10
0
 public function uploadAvatar($avatar, $username)
 {
     $image = new Image();
     $results = $image->addImage(public_path('img/avatars/User'), $avatar, \Str::studly($username));
     return $results;
 }
예제 #11
0
 /**
  *
  * @param string $editorId
  * @param string $name
  * @param string $filter
  * @param string $package
  * @param string $type
  */
 public static function add($editorId, $name = NULL, $filter = NULL, $package = NULL, $type = self::TYPE_HTML)
 {
     self::$editors[$editorId] = ['name' => $name === NULL ? \Str::studly($editorId) : $name, 'type' => $type == self::TYPE_HTML ? self::TYPE_HTML : self::TYPE_CODE, 'filter' => empty($filter) ? $editorId : $filter, 'package' => $package === NULL ? $editorId : $package];
 }
예제 #12
0
파일: Sync.php 프로젝트: larakit/lk
 protected function parseModel(array $thumb_route)
 {
     $vendor = Arr::get($thumb_route, 'vendor');
     $package = Arr::get($thumb_route, 'package');
     $class = '\\' . \Str::studly(str_replace('-', '\\_', $vendor)) . '\\Model\\' . \Str::studly($package);
     if (!class_exists($class)) {
         return false;
     }
     return $class;
 }
예제 #13
0
 /**
  * Creates a studly plural
  */
 public function transformPluralStudly($key, $value)
 {
     return array(Str::plural(Str::studly($key)), Str::plural(Str::studly($value)));
 }
예제 #14
0
파일: TraitEntity.php 프로젝트: larakit/lk
 static function getClassModel()
 {
     return static::getStudlyVendor() . '\\Model\\' . \Str::studly(static::getEntity());
 }
예제 #15
0
 /**
  * Get the user's css file for the laravel style method
  *
  */
 public function themeStyle()
 {
     return '/css/master3/users/' . \Str::studly($this->username) . '.css';
 }
 /**
  * Small override for helping with fetching data from the consumed model
  * @param  string  $key The property name
  * @return boolean
  */
 public function hasGetMutator($key)
 {
     return parent::hasGetMutator($key) || isset($this->consumedModelProps[Str::studly($key)]);
 }
예제 #17
0
 /**
  * Set a given attribute on the model.
  *
  * @param  string $key
  * @param  mixed $value
  *
  * @return $this
  */
 public function setAttribute($key, $value)
 {
     $this->findUploadFields();
     if ($this->isUploadField($key)) {
         list($method, $originalKey) = $this->uploadSetKeys[$key];
         if ($this->hasSetMutator($key)) {
             $method = 'set' . Str::studly($key) . 'Attribute';
             return $this->{$method}($value);
         }
         return $this->{$method}($originalKey, $value);
     }
     return parent::setAttribute($key, $value);
 }
예제 #18
0
 /**
  * Convert a value to studly caps case.
  *
  * @param  string  $value
  * @return string
  */
 function studly_case($value)
 {
     return Str::studly($value);
 }
예제 #19
0
 /**
  * Set a given attribute on the model.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return void
  */
 public function setAttribute($key, $value)
 {
     // First we will check for the presence of a mutator for the set operation
     // which simply lets the developers tweak the attribute as it is set on
     // the model, such as "json_encoding" an listing of data for storage.
     if ($this->hasSetMutator($key)) {
         $method = 'set' . Str::studly($key) . 'Attribute';
         return $this->{$method}($value);
     } elseif (in_array($key, $this->getDates()) && $value) {
         $value = $this->fromDateTime($value);
     }
     if ($this->isJsonCastable($key) && !is_null($value)) {
         $value = json_encode($value);
     }
     // We now have the string version of the value stored in $value.
     // Does it need to be encrypted?  If so encrypt it, and prefix
     // the string with a tag so we know it's been encrypted.
     if ($this->hasEncrypt($key)) {
         $originalValue = $value;
         try {
             $value = $this->getElocryptPrefix() . Crypt::encrypt($value);
         } catch (EncryptException $e) {
             // Reset
             $value = $originalValue;
         }
     }
     $this->attributes[$key] = $value;
 }
예제 #20
0
<?php

Route::pattern('idu', '[0-9]+');
Route::group(array('before' => 'basicAuth', 'prefix' => Config::get('backend.uri') . '/' . Config::get('backend.group_advertiser_manager_url')), function () {
    $prefixName = Str::studly(pathinfo(__DIR__, PATHINFO_BASENAME));
    $prefixSlug = Str::snake($prefixName, '-');
    Route::get('/tool', array('as' => $prefixName . 'ShowTool', 'uses' => $prefixName . 'Controller@tool'));
    Route::post('/tool/search', array('uses' => $prefixName . 'Controller@getListSelect'));
    //profile publisher
    Route::get('/tool/profile', array('before' => 'hasPermissions:' . $prefixSlug . '-edit', 'as' => $prefixName . 'Profile', 'uses' => $prefixName . 'Controller@myProfile'));
    Route::post('/tool/profile', array('before' => 'hasPermissions:' . $prefixSlug . '-edit', 'as' => $prefixName . 'Profile', 'uses' => $prefixName . 'Controller@myProfile'));
    Route::post('/tool/get-list', array('as' => $prefixName . 'GetList', 'uses' => $prefixName . 'Controller@getList'));
    Route::post('/tool/get-user', array('as' => $prefixName . 'GetUser', 'uses' => $prefixName . 'Controller@getUserId'));
    Route::get('/tool/user-manager', array('before' => 'hasPermissions:' . $prefixSlug . '-edit', 'as' => $prefixName . 'UserManager', 'uses' => $prefixName . 'Controller@userManager'));
    Route::get('/tool/list-publisher', array('before' => 'hasPermissions:' . $prefixSlug . '-read', 'as' => $prefixName . 'ShowListPublisher', 'uses' => $prefixName . 'Controller@showListPublisher'));
    Route::post('/tool/get-list-publisher', array('as' => $prefixName . 'GetListPublisher', 'uses' => $prefixName . 'Controller@getListPublisherManager'));
    Route::get('/tool/user-edit/{idu}', array('as' => $prefixName . 'ShowUpdate', 'uses' => $prefixName . 'Controller@myProfile'));
    Route::post('/tool/user-edit/{idu}', array('as' => $prefixName . 'ShowUpdate', 'uses' => $prefixName . 'Controller@myProfile'));
    Route::post('/tool/sort-flight-running', array('before' => 'hasPermissions:' . $prefixSlug . '-edit', 'as' => $prefixName . 'SortFlightRunning', 'uses' => $prefixName . 'Controller@sortFlightRunning'));
    Route::post('/tool/update-sort-flight-running', array('before' => 'hasPermissions:' . $prefixSlug . '-edit', 'as' => $prefixName . 'UpdateSortFlightRunning', 'uses' => $prefixName . 'Controller@postSortFlightRunning'));
    Route::post('/tool/preview', array('as' => $prefixName . 'Preview', 'uses' => $prefixName . 'Controller@preview'));
    Route::get('/tool/dashboard', array('as' => $prefixName . 'Preview', 'uses' => $prefixName . 'Controller@getDashboard'));
    Route::post('/tool/dashboard/campaign', array('as' => $prefixName . 'PreviewCampaign', 'uses' => $prefixName . 'Controller@getDashboardCampaign'));
    Route::post('/tool/dashboard/flightwebsite', array('as' => $prefixName . 'PreviewFlightWebsite', 'uses' => $prefixName . 'Controller@getDashboardFilghtWebsite'));
    Route::get('/tool/create-new-url-track', array('as' => $prefixName . 'CreateNew', 'uses' => $prefixName . 'Controller@createNewTrackURL'));
    Route::post('/tool/create-new-url-track', array('as' => $prefixName . 'CreateNew', 'uses' => $prefixName . 'Controller@createNewTrackURl'));
    Route::get('/tool/url-track-ga', array('as' => $prefixName . 'URLTrackGA', 'uses' => $prefixName . 'Controller@getUrlTrackGA'));
    Route::get('/tool/edit-url-track/{id}', array('as' => $prefixName . 'Edit', 'uses' => $prefixName . 'Controller@editTrackURL'));
    Route::post('/tool/edit-url-track/{id}', array('as' => $prefixName . 'Edit', 'uses' => $prefixName . 'Controller@editTrackURL'));
    Route::get('/tool/detail-url-track/{id}', array('as' => $prefixName . 'DetailUrlTrack', 'uses' => $prefixName . 'Controller@detailTrackURL'));
    Route::post('/tool/delete-url-track', array('as' => $prefixName . 'Delete', 'uses' => $prefixName . 'Controller@deleteTrackURL'));
예제 #21
0
 /**
  * Get the correct class to call according to the created field
  *
  * @param  string $method The field created
  *
  * @return string The correct class
  */
 protected function getClassFromMethod($method)
 {
     // If the field's name directly match a class, call it
     $class = Str::singular(Str::title($method));
     $studly_class = Str::singular(Str::studly($method));
     foreach ($this->repositories as $repository) {
         if (class_exists($repository . $studly_class)) {
             return $repository . $studly_class;
         } else {
             if (class_exists($repository . $class)) {
                 return $repository . $class;
             }
         }
     }
     // Else convert known fields to their classes
     switch ($method) {
         case 'submit':
         case 'link':
         case 'reset':
             $class = Former::FIELDSPACE . 'Button';
             break;
         case 'multiselect':
             $class = Former::FIELDSPACE . 'Select';
             break;
         default:
             $class = Former::FIELDSPACE . 'Input';
             break;
     }
     return $class;
 }