protected function imageAvatar()
 {
     $path = 'upload/' . date('Ym/d/');
     $filename = KRandom::getRandStr() . '.jpg';
     if (!File::exists(public_path($path))) {
         File::makeDirectory(public_path($path), 493, true);
     }
     while (File::exists(public_path($path) . $filename)) {
         $filename = KRandom::getRandStr() . '.jpg';
     }
     $this->image->resize(new \Imagine\Image\Box(300, 300))->save(public_path($path) . $filename);
     ImageModel::createUploadedImage($path . $filename, URL::asset($path . $filename));
     $user = AuthModel::user();
     $url = URL::asset($path . $filename);
     if ($user) {
         if ($user->profile) {
             $user->profile->avatar = $url;
             $user->profile->save();
         } else {
             ProfileModel::create(array('user_id' => $user->id, 'avatar' => $url));
         }
     } else {
     }
     return $url;
 }
Пример #2
0
 public static function display_search_modal($id, $field)
 {
     $class = static::$class;
     if (!$id) {
         $id = KRandom::getRandStr(32, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
     }
     $search_action = static::$action . '.show.search_pick_up_item';
     return View::make('laravel-cms::cms/picked-up-items/modal-search')->with('id', $id)->with('field', $field)->with('search_action', $search_action)->render();
 }
 public static function createByUserAndQuiz(\Eloquent $user, QuizModel $quiz)
 {
     return static::create(array('user_id' => $user->getKey(), 'quiz_id' => $quiz->getKey(), 'token' => time() . KRandom::getRandStr(8), 'result_text' => '', 'status' => '未开始'));
 }
Пример #4
0
 public function testGetRandomStr()
 {
     echo KRandom::getRandStr() . "\n";
     echo KRandom::getRandStr(16) . "\n";
     echo KRandom::getRandStr(32, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') . "\n";
 }
Пример #5
0
<div {{ $field->formgroup() }}>
    <div class="row">
        <label for="{{ $field->name() }}" class="control-label col-lg-12 col-md-12" style="text-align:left;">{{ $field->label() }}</label>
    </div>
    <div class="row">
        <div class="tags-span col-lg-12 col-md-12">
        @foreach( $field->value() as $tag )
            <span class="label label-info" style="display:inline-block;margin-right:5px;">{{{ $tag }}}<a href="javascript:;" form-role="tag-remove" style="margin-left:10px;">x</a>
                <input style="display:none;" name="{{ $field->name() }}[]" value="{{{ $tag }}}">
            </span>
        @endforeach
        </div>
    </div>
    <?php 
$id = 'tags-input-' . \Xjtuwangke\Random\KRandom::getRandStr();
?>
    <div style="margin-top:20px;">
        <div class="">
            <div class="input-group">
                <input type="text" id="<?php 
echo $id;
?>
" class="form-control input-tags">
                <span class="input-group-btn">
                    <a class="btn btn-default" href="javascript:;" form-role="add-tag" form-attr-field="{{ $field->name() }}[]">增加标签</a>
                </span>
            </div>
        </div>
    </div>
    <style>