小编Jit*_*dra的帖子

命令"clear-compiled"未定义.Laravel 5.2

我正在尝试使用Composer下载Laravel HTML依赖项.

composer.json 在这儿:

"name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "illuminate/html": "5.2"
    },
Run Code Online (Sandbox Code Playgroud)

当我运行composer update或者php composer update,终端日志是:

E:\xampp\htdocs\lara-test>composer update
> php artisan clear-compiled

  [InvalidArgumentException]
  Command "clear-compiled" is not defined.

Script php artisan clear-compiled handling the pre-update-cmd event returned with an error

  [RuntimeException]
  Error Output:

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock]
 [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-
progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]
 [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] …
Run Code Online (Sandbox Code Playgroud)

php command composer-php laravel-5.2

5
推荐指数
1
解决办法
3543
查看次数

laravel 5.2中的表单模型绑定

我一直在阅读表格模型绑定https://laravelcollective.com/docs/5.0/html#form-model-binding

以html格式填充数据库值非常酷.我试过这样,这很棒.

{{ Form::model($university,array('url' => admin_path('universities/edit'),'id' => 'add_university','name' =>'add_university','data-validate'=>"parsley")) }}
    {{ Form::label('university_name', 'University name',array('class'=>'control-label')) }}
    {{ Form::text('university_name')}}
{{Form::close()}}
Run Code Online (Sandbox Code Playgroud)

但问题出在这里,因为我想在输入中添加更多属性,比如class我正在使用的SO

{{ Form::label('university_name', 'University name',array('class'=>'control-label')) }}
{{ Form::text('university_name','',array('class' => 'form-control'))}}
Run Code Online (Sandbox Code Playgroud)

如果我留下空白value列,那么在文本框中没有任何内容,如果我使用这样的话

{{ Form::label('university_name', 'University name',array('class'=>'control-label')) }}
{{ Form::text('university_name',$university->university_name,array('class' => 'form-control'))}}
Run Code Online (Sandbox Code Playgroud)

那么什么是模型绑定的用途.请解释.谢谢

html php laravel-5

5
推荐指数
1
解决办法
890
查看次数

Laravel 5 在静态函数中调用非静态函数

我正在使用 laravel 5。在模型中,我有一个静态函数,我在控制器中调用它。它工作正常,但我希望这个函数与另一个非静态函数进行相同的更改,当我在静态函数内调用它时,它会产生错误。

Non-static method App\Models\Course::_check_existing_course() should not be called statically
Run Code Online (Sandbox Code Playgroud)

这是我的模型

namespace App\Models;
use Illuminate\Database\Eloquent\Model;

    class Course extends Model {
        public $course_list;
        protected $primaryKey = "id";
        public function questions(){
            return $this->belongsToMany('App\Models\Question','course_questions')->where("status",1)->orderBy("id","DESC");
        }

        public static function courses_list(){
            self::_check_existing_course();
        }
        private function _check_existing_course(){
            if(empty($this->course_list)){
                $this->course_list = self::where("status",1)->orderBy("course")->get();
            }
            return $this->course_list;
        }
    }
Run Code Online (Sandbox Code Playgroud)

php static-methods static-functions laravel-5

2
推荐指数
1
解决办法
8600
查看次数

在laravel 5中的belongsToMany关系中搜索

实际上,我想搜索用户在选择任何主题或课程后想要搜索的那些问题。

如果whereHas从主题或课程中删除它的作品,但两者都不起作用。

请给出一个更好的解决方案在belongsToMany 中搜索。

我有一个带有Question模型类的问题表

class Question extends Model{
    public function courses(){
        return $this->belongsToMany('App\Models\Course','course_questions');
    }

    public function subjects(){
        return $this->belongsToMany('App\Models\Subject','subject_questions');
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的 searchController

public function index(Request $request){
        $questions = Question::with(['user','courses','branches','subjects','years','universities','question_type'])
            ->where("status","=",1)
            ->where(function($query) use($request){
                $q = $request->q;
                if(isset($q) && !is_null($q)){
                    $query->where("question","LIKE","%$q%");
                }
            })
            ->whereHas('subjects',function($query) use($request){
                $subjects = $request->subject;
                if(isset($subjects)){
                    $_subjects = explode(" ",$subjects);
                    $query->whereIn("slug",$_subjects)
                    ->orWhereIn("subject_name",$_subjects);
                }
            })
            ->whereHas('courses',function($query) use($request){
                $course = $request->course;
                if(isset($course)){
                    $_course = explode(" ",$course);
                    $query->whereIn("slug",$_course)
                        ->orWhereIn("course",$_course);
                }
            })
            ->paginate();
        if($request->ajax()){
            $returnHTML = view('questions.question_list')->with('questions', …
Run Code Online (Sandbox Code Playgroud)

php mysql relationship eloquent laravel-5

2
推荐指数
1
解决办法
1050
查看次数

在ionic2中上传之前如何获取文件名和mime类型?

我正在尝试使用ionic / file-chooser插件来上传文件。一切都很完美,直到我没有要求上传doc或pdf文件。我正在使用离子3.12.0和科尔多瓦7.0.1。

 const fileTransfer: FileTransferObject = this.transfer.create();
    let options: FileUploadOptions = {
      fileKey: 'files0',
      fileName: 'name.jpg',
      params: {
        Authkey: this.CS.auth_key,
        Token: this.CS.token,
        group_id: this.CS.activeGroupId,
        Userid: this.CS.userId
      }
    };
    this.fileChooser.open()
      .then(uri => {
        this.CS.show_loader();
        //alert(uri );
        this.file.resolveLocalFilesystemUrl(uri)
          .then((files)=> {
          alert(JSON.stringify(files, null, 4));
        }).catch((err) => {
          alert(JSON.stringify(err, null, 4));
        });
        //let name = uri.split("/");
        //options.fileName = name[name.length - 1];
       // alert(options.fileName);
        fileTransfer.upload(uri, this.CS.base_url + 'groups/uploadChat', options)
          .then((data) => {
            this.CS.hide_loader();
            this.res = data;
            //alert(JSON.stringify(data, null, 4));
            let d = JSON.parse(this.res.response);

            if(d.status …
Run Code Online (Sandbox Code Playgroud)

file-upload cordova typescript ionic-framework ionic-native

2
推荐指数
1
解决办法
1758
查看次数