我正在尝试使用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) 我一直在阅读表格模型绑定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)
那么什么是模型绑定的用途.请解释.谢谢
我正在使用 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) 实际上,我想搜索用户在选择任何主题或课程后想要搜索的那些问题。
如果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) 我正在尝试使用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) php ×4
laravel-5 ×3
command ×1
composer-php ×1
cordova ×1
eloquent ×1
file-upload ×1
html ×1
ionic-native ×1
laravel-5.2 ×1
mysql ×1
relationship ×1
typescript ×1