草庐IT

拉维尔

全部标签

php - 拉维尔 "File Upload Error Call to a member function getClientOriginalName() on a non-object"

全部。我正在尝试学习Laravel,并且正在努力上传图片。我收到以下错误:“在非对象上调用成员函数getClientOriginalName()”我正在使用这些包:"anahkiasen/former":"dev-master","intervention/image":"dev-master","intervention/imagecache":"2.*"使用SO后,我已验证以下内容不会导致上述错误:表单上的多部分/表单数据存在上传文件数据PHP.ini的max_filesize比这个小测试文件的大小要大得多我的表格是:UploadImage产生错误的代码是:$image=Input

php - 拉维尔 5 : Global Auth $user variable in all controllers

在我的BaseController中我有这个:publicfunction__construct(){$user=Auth::user();View::share('user',$user);}我可以在我的所有View中访问$user数组,但如果我希望它成为我所有Controller中可用的全局变量怎么办?我有以下工作代码:useAuth;useDB;classUsersControllerextendsBaseController{publicfunctionindex(){$user=Auth::user();$users=DB::table('users')->where('us

php - 拉拉维尔。两个项目的公共(public)队列

我有两个不同的项目。Laravel项目A和Laravel项目B。我需要通过队列从项目A到项目B创建任务。我不想在项目A中为此创建作业。目前我的实现是:项目A有状态但没有业务逻辑的作业:_contentId=$contentId;}/***Excess.IdontneedbusinesslogicinprojectA.*/publicfunctionhandle(){}}然后我将作业插入项目A中的队列:...$this->dispatch(newMyJob($this->_contentId));...项目B_contentId=$contentId;}/***Hereismybusin

php - 拉维尔 5 : Alternative for Eloquent's 'orWhere' method for querying collections

所以我有一个产品集合($this->products),这是我通过模型查询得到的,我想通过它的一些属性值来过滤它。问题是Laravel没有类似orWhere的方法用于集合,就像Eloquent用于查询模型一样。此外,我想使用LIKE%{$searching_for}%通配符,但我不确定如何使用它(如果可能的话)来过滤我的收藏。这是我试图过滤我的集合的代码,显然会抛出orWhere方法不存在的Exception:$products=$this->products->where("field1","LIKE%{$searching_for}%")->orWhere("field2","LI

php - 拉维尔;如何使 setLocale 永久化?

我有我的家路线Route::get('/','HomeController@index')->name('home');以及更改语言的特定途径Route::get('/setLocale/{locale}','HomeController@setLocale')->name('setLocale');在HomeController->setLocale($locale)中,我检查$locale是否是一个有效的语言环境,然后简单地做\App::setLocale($locale);然后重定向到主页。在这里,在HomeController->index()中,我使用验证语言环境$local

php - 拉拉维尔 5 : Where define global Vars?

在旧的laravel4代码中,我们使用constants.php来定义全局变量。在Laravel5中使用定义变量的最佳实践是什么?我们不会将其存储在.env文件或routes.php中 最佳答案 我只是想改进一下@Adam的回答。假设有一个在线购物车。然后,您需要一个全局变量来存储currencysymbol以便在View中显示。因为这个值可以随时更改,所以您可以在App\Providers\ConfigServiceProvider中指定它,如下所示:publicfunctionregister(){$currency='what

php - 拉维尔 5 : link to php page

我有两个页面login.blade.php和register.blade.php。在我的login.blade.php上,我有这样的register.blade.php链接:Registeranewmembership当我点击指向register.php的链接时,它会抛出以下错误:RouteCollection.php第143行中的NotFoundHttpException:登录和注册都在同一个View文件夹中。我的route.php文件有:Route::get('/register',function(){returnview('register');});

php - 拉维尔 5.2 : How to get the role of current user when using `Zizaco/entrust` ?

我正在使用Laravel5.2和Zizaco/entrust5.2,我的问题是:使用Zizaco/entrust时如何获取当前用户的角色?名称和角色.phpnamespaceApp\Services;useApp\User;useApp\Role;useZizaco\Entrust\EntrustRole;useIlluminate\Support\Facades\Cache;classNameAndRole{public$username;public$role;publicfunction__construct(){$user=\Auth::user();$this->userna

php - 拉维尔 5 : Fetch ajax data in route and pass to controller

我正在使用Laravel5并希望使用一些数据对Controller进行ajax调用:$.ajax({url:"/getOrgById",data:JSON.stringify({id:1})})routes.php有:Route::get('/getOrgById','HomeController@getOrgById');HomeController.php:publicfunctiongetOrgById($data){//codeherefailswithmessage'Missingargument1forHomeController::getOrgById()}如何将数据从a

php - 拉维尔 5.6 : Table creation failed

我是Laravel的新手,我正在尝试使用Schema外观创建表。我使用命令创建迁移文件phpartisanmake:migrationcreate_products_define_standards_table--create=products_define_standards这是文件:increments('id');$table->string('code')->unique();$table->string('image');$table->timestamps();});}/***Reversethemigrations.**@returnvoid*/publicfunctio