草庐IT

msg_control

全部标签

php - 如何在 Laravel 5 的 Controller 中调用模型函数

我一直面临无法在新的laravel框架版本5中使用Controller内部模型的问题。我使用artisan命令创建了模型“phpartisanmake:modelAuthentication”它在app文件夹中成功创建了模型,之后我在其中创建了一个小的功能测试,我的模型代码如下所示。现在我不知道,我该如何调用模型的函数test()到我的Controller,任何帮助将不胜感激,在此先感谢。 最佳答案 运行该函数并查看输出的一种快速而肮脏的方法是编辑app\Http\routes.php并添加:useApp\Authenticatio

php Laravel ~ 属性 [controller] 不存在

我正在尝试在我的Laravel项目中设置一个路由Controller,我已经设置了Controller和路由。但是,当我在web.php中加载路由时,当我尝试在浏览器中导航到Attribute[controller]doesnotexist这是代码..redirectTo=route('backend.dashboard');$this->middleware('guest')->except('logout');}publicfunctionlogout(Request$request){$this->performLogout($request);returnredirect()-

php - Codeigniter 将数据从 Controller 传递到 View

根据here我有以下Controller:classUserextendsCI_Controller{publicfunctionLogin(){//$data->RedirectUrl=$this->input->get_post('ReturnTo');$data=array('title'=>'MyTitle','heading'=>'MyHeading','message'=>'MyMessage');$this->load->view('User_Login',$data);}//More...}在我的User_Login.phpView文件中,我这样做:结果是:APHPEr

php - 如何在 Symfony2 Controller 中获取 Action 名称?

有没有办法在Symfony2Controller中获取Action的名称?publicfunctioncreateAction(Request$request,$title){//Expectedresult:create$name=$this->getActionName();} 最佳答案 使用:$request->attributes->get('_controller');//willgetyourBundle\Controller\yourController::CreateAction$params=explode('::

php - CodeIgniter:将参数传递给 Controller ​​时找不到页面?

我正在尝试将参数传递给codeigniter中的控件,但我收到404页面未找到错误,我不明白,我按照指南说的做了:https://www.codeigniter.com/user_guide/general/controllers.html#passing-uri-segments-to-your-methods当我删除索引函数中的参数并访问Controller时,一切正常,但我无法将值传递给它...这是我尝试发送参数的代码:http://mysite/123如何从codeigniter获取有关此错误的更多信息?谢谢。 最佳答案 网

php - Symfony2 Controller 中未捕获 Swiftmailer 异常

我正在开发一个简单的邮件应用程序,使用Gmail帐户作为主机。它工作起来很有魅力,但是当send()函数抛出异常时问题就出现了。我看到trycatch语句无法处理异常。即使我使用全局异常类,它也不起作用。这个问题也在某处讨论过。例如:CatchswiftmailerexceptioninSymfony2devenvcontroller或https://groups.google.com/forum/#!topic/symfony2/SlEzg_PKwJw但他们没有找到有效的答案。我的Controller功能代码是:publicfunctionajaxRegisterPublisherA

php - 通过 ajax 调用 phalcon php MVC Controller

我正在使用带有phalconPHP和AngularJs的简单应用程序。我正在尝试通过AJAXPOST请求从angularJSController调用我的phalconPHPController。$http.post('/ControllerName/',{params});我明白了404TherequestedURL/ControllerName/wasnotfoundonthisserver我认为我的请求被路由到我的公共(public)文件夹,而我的phpController位于非公共(public)文件夹中。这些是我的.htaccess规则RewriteEngineonRewrit

php - 需要在单个资源 Controller 中使用 Entrust 角色的建议 - Laravel5

我正在开发一个控制面板应用程序,其中我有多个用户角色,例如globaladmin、编辑器等。现在我想将这些角色与单个UserController资源一起使用。例如,globaladmins应该能够执行所有Restful方法,而编辑器只能查看和更新​​用户。我知道entrust带有开箱即用的中间件,非常适合我的需要。但它只适用于路线(在这种情况下,我需要为每个角色单独的Controller)。我的UserController看起来像这样。ClassUserControllerextendsBaseController{$protected$viewfolder;publicfunctio

javascript - XMLHttpRequest 无法加载 Origin null 不允许 Access-Control-Allow-Origin

我有一个包含以下代码的code.html文件。$.ajax({type:"POST",datatype:"JSONP",url:"path",success:function(msg){vare=document.createElement("div");e.id="ads";document.body.appendChild(e);$("#ads").html(msg);}});当我在浏览器中打开code.html文件时,出现错误:**"XMLHttpRequestcannotloadfile://.....OriginnullisnotallowedbyAccess-Control

php - 路由到子文件夹中的 Controller 在 Laravel 4 中不起作用

当我遇到这个问题时,我正在将我的Laravel3应用程序更新到Laravel4...我尝试过的路线:Route::get('backend/login','backend/UserController@login');Route::get('backend/login','backend.UserController@login'); 最佳答案 就在几个小时前,我遇到了类似的问题,我不得不尝试一下才能使其正常工作。路线:Route::group(array('prefix'=>'admin'),function(){Route::r