草庐IT

laravel-request

全部标签

php - Laravel 5.3 在 API 中过滤搜索数据

我正在为前端和移动应用程序实现一个API,现在我正在开发搜索功能,用户可以在其中键入列名或任何data我应该能够以JSON格式提供他们请求的数据所以我做了这个在我的Controller中publicfunctiongetSearchResults(Request$request){$data=$request->get('data');$search_drivers=Driver::where('agent_id','like',"%{$data}%")->orWhere('registration_center','like',"%{$data}%")->orWhere('regis

php - Laravel 列表 concat 不显示数据(全名)

我在我的项目中使用Laravel5.3,我试图获取多个列并在View的下拉选择元素中显示数据。我正在做这样的查询:$users=User::select(DB::raw("CONCAT(first_name,'',last_name)ASfull_name,id"))->lists('full_name','id')->toArray();但这是我从中得到的数据:array:6[▼14=>""15=>""16=>""17=>""19=>""22=>""]full_name的值为空,我该如何解决? 最佳答案 尽量避免使用full_na

php - Laravel 5.3 存储和读取文件目录

目前正在尝试处理文件,但很难弄清楚将它们放在哪里以及如何在列表中读回它们。我尝试将几个测试文件放入$files=array();$dir=opendir(asset('files');//openthecwd..alsodoanerrcheck.while(false!=($file=readdir($dir))){if(($file!=".")and($file!="..")and($file!="index.php")){$files[]=$file;//putinarray.}}但尽管其中有3个测试文件,它还是返回空白。查看幼虫食谱和建议说File:allFile()这不是受支持

php - Laravel 路线不适用于生产

我有一个Laravel5/angularJS应用程序(将Laravel作为apirest和angular作为前端)在我的本地环境中,一切都像魅力一样运作。但是当我上传到主机时,我只能访问索引页面,其他所有内容都会抛出404。在我的共享主机中,我有这样的文件系统。public_htmllaravel-backend(ithasapp,bootstrap,confi...etc,alllaravelapp)laravel-frontend(itwouldbelikethepublicfolderofthelaraveldefaultfilesystem).htaccess.htaccess

php - Laravel 在一个函数中加载多个 View

我只知道如何在单个Controller函数中调用多个View。我正在尝试:returnView::make('header');returnView::make('main');returnView::make('footer');任何建议。我如何称呼他们?提前致谢.. 最佳答案 您应该使用sections创建一个View为了便于重复使用。然后它允许您组成各个部分。layout.blade.php@yield('header')@yield('body')@yield('footer')combined.blade.php@exte

php - 为什么在 laravel blade 中条件 @if 不工作? (拉拉维尔 5.3)

如果我的代码是这样的:@foreach($categoriesas$category)@if($loop->first)$category_id=$category->id@endif@endforeach存在错误:Undefinedvariable:category_id(View:C:\xampp\htdocs\myshop\resources\views\front.blade.php)如果我的代码是这样的:@foreach($categoriesas$category)@phpif($loop->first)$category_id=$category->id@endphp@e

php - 在 Laravel 5.4 中从迁移中删除列

我使用像这样的迁移创建了一个表:Schema::create('listings',function(Blueprint$table){$table->increments('id');$table->decimal('original_price',10,2);$table->decimal('discouted_price',10,2);$table->integer('city_id')->index()->unsigned()->nullable();$table->foreign('city_id')->references('id')->on('cities');$tabl

php - 路由如何在 PHP laravel 中工作?

我刚开始玩Laravel框架,我看到了这个:Route::get('foo',function(){return'HelloWorld';});谁能解释一下这是什么?我的意思是,我知道什么是get。但是为什么我们先放'foo'然后放闭包呢?另外,我真正从哪里获得信息? 最佳答案 首先我们声明Route的Facade,想像一个使用Route类的捷径。然后我们选择路由的方法,可以是:Route::get($uri,$callback);//getRoute::post($uri,$callback);//postRoute::put($

php - Laravel:如何在 Controller 方法执行后重定向

web.php:Route::post('caption/{id}/delete','DetailController@deleteCaption');DetailController.php:publicfunctiondeleteCaption(Request$request,$id){$caption=Caption::findOrFail($id);$caption->delete();//doesn'tdeletepermanentlyreturnresponse(204);}admin.blade.php:id}}'>{{$caption->content}}id}}/de

php - Laravel 授权中间件 : Class can does not exist

我正在尝试通过中间件保护路由describedinthedoc当我点击url时,我得到:ReflectionExceptioninContainer.phpline749:Classcandoesnotexist这是来自routes.php的相关部分:Route::get('{user}/profile/edit/{type?}',['as'=>'edit','uses'=>'User\UserController@edit','middleware'=>['can:edit-user,user'],]);AuthServiceProvider.php:publicfunctionbo