草庐IT

php - 类不存在 - Laravel

我正在关注thistutorial.我目前使用的是laravel5.3,所以它有点过时了。我已经按照教程一步一步完成了,但是,我得到了ReflectionExceptioninContainer.phpline749:ClassFirstdoesnotexistinContainer.phpline749atReflectionClass->__construct('First')inContainer.phpline749atContainer->build('First',array())inContainer.phpline644atContainer->make('First'

php - Eloquent "select"方法不适用于使用 "with"方法

我的村庄模型;belongsTo(Map::class,'id','field_id');}}我的map类迁移;Schema::create('map_data',function(Blueprint$table){$table->increments('id');$table->integer('field_type');$table->integer('field_id');$table->string('x');$table->string('y');$table->timestamps();});我在“VillageController”类上的“villages”方法;publ

php - 在 Laravel 5.3 中获取提交按钮的值

我的页面上有一个表单AddNow我在我的Controller中打印了请求publicfunctionvegaspage(Request$request){dd($request);die;}我的页面上也有很多字段,当请求参数到达浏览器时,提交按钮值没有出现在请求中有什么想法吗? 最佳答案 在你的Controller函数中试试这个:Input::get('hostel1','NA');//Itwillreturnitsvalueie`TheVenetian`otherwise`NA`注意:Input::get()的第二个参数是默认值。

php - 拉维尔 5.4 : Api route list

我的routes/api.php中有以下几行Route::middleware('api')->get('/posts',function(Request$request){Route::resource('posts','ApiControllers\PostsApiController');});当我点击http://localhost:8000/api/posts它返回空白,但是当我将上述路线移动到routes/web.php时像这样:Route::group(['prefix'=>'api/v1'],function(){Route::resource('posts','Api

php - 我需要将 Laravel 切换到 Symfony 吗?

我对我当前的项目有同样的问题。项目类型:类似购物车SDK。模特:30岁以上(有分机)扩展:15+表格:47关系:每个模型都有3个以上的关系性能要求最高的部分处理:300毫秒一开始,我有10个有关系的模型,这就是我选择Laravel作为框架的原因,我不考虑增长。现在,我有40个模型,有很多扩展,Laravel工作得很好。我的项目发展很快。现在它是一个包含大量表、关系和扩展的大型SDK。我需要经验丰富的开发人员的建议。DoIneedtoswitchLaraveltoSymfony,toreducefutureproblemswithperformance?如果你能在这方面给我建议,我将很高

php - 在 Laravel 中向父模型添加作用域

我目前正在尝试清理我的Laravel模型中的代码,目前我在每个模型中都有大量与本地作用域相关的代码重复。每个模型都有很多相似的相关列,我正在弄清楚如何将这些范围放在一个地方,但仍然能够传递$table变量,以便它可以动态使用。例如我目前有几个模型publicfunctionscopeName($query,$name){return$query->where($this->table.'name',$name);}publicfunctionscopeStatus($query,$status){return$query->where($this->table.'.status',$s

php - 用户在 Laravel 上注册后无法登录

我正在尝试从头开始在Laravel上设置身份验证系统,但我无法让用户在注册后登录。我的RegisterController用于存储用户:publicfunctionstore(){$this->validate(request(),['name'=>'required','email'=>'required','password'=>'required']);$user=User::create(request(['name','email','password']));auth()->login($user);returnredirect()->home();}现在一切正常,但是当我

php - Laravel 追随者/跟随关系

我正在尝试在laravel中制作一个简单的关注者/关注系统,没什么特别的,只需单击一个按钮即可关注或取消关注,并显示关注者或关注你的人。我的问题是我不知道如何建立模型之间的关系。这些是迁移:-用户迁移:Schema::create('users',function(Blueprint$table){$table->increments('id');$table->timestamps();$table->string('email');$table->string('first_name');$table->string('last_name');$table->string('pas

php - 多个路由的相同 Laravel 资源 Controller

我正在尝试使用trait作为我的Laravel资源Controller的类型提示。Controller方法:publicfunctionstore(CreateCommentRequest$request,Commentable$commentable)其中Commentable是我的Eloquent模型使用的特征类型提示。Commentable特性看起来像这样:namespaceApp\Models\Morphs;useApp\Comment;traitCommentable{/***Getthemodel'scomments.**@return\Illuminate\Databas

php - 使用 Laravel 将图像转换为 base 64 字符串

我想用Laravel将图像转换为base64。我从表格中获取图像。我在我的Controller中试过这个:publicfunctionnewEvent(Request$request){$parametre=$request->all();if($request->hasFile('image')){if($request->file('image')->isValid()){try{$file=$request->file('image');$image=base64_encode($file);echo$image;}catch(FileNotFoundException$e){e