草庐IT

root-view-controller

全部标签

php - 为什么 Laravel REST Controller $request->input 为 NULL?

我正在学习教程http://www.tutorials.kode-blog.com/laravel-5-angularjs-tutorial我已经设法为我的Controller编写了类似的方法:publicfunctionupdate(Request$request,$id){$employee=Employee::find($id);$employee->name=$request->input('name');//...$employee->save();return"Sucessupdatinguser#".$employee->id;}在教程中认为此代码有效,但实际上var_d

php - 如何将 php 变量从 View (html)发送到 Controller

这是我的html代码。我想将“$category_edit->c_name”值传递给我的Update()Controller。我从另一个Controller获取“$category_edit”变量。我正在使用CodeIgniter框架。">ParentCategory:id.'">';echo$category_edit->p_name;echo'';?>Categoryc_name;?>"id="category_name"value="c_name;?>">Update这是我的update()Controller。我收到错误:undefinedvariable:category_e

php - 在 Controller 中找不到接口(interface) 'Silex\ControllerProviderInterface'

执行api.php时:Fatalerror:Interface'Silex\ControllerProviderInterface'notfoundinC:\xampp\htdocs\lab\src\Api\UserController.phponline9Composer:{"require":{"silex/silex":"^2.0"},"autoload":{"psr-4":{"Api\\":"src/Api"}}}api.php:mount('/',newApi\UserController());$app->run();src/Api/UserController.php:g

php - Laravel 多态关系 : Passing model to controller

我想使用一个Controller来保存我对多个模型的评论。所以我使用以下存储方法创建了CommentController:publicfunctionstore(Teacher$teacher,Request$request){$input=$request->all();$comment=newComment();$comment->user_id=Auth::user()->id;$comment->body=$input['body'];$teacher->comments()->save($comment);returnredirect()->back();}在我看来,我有:{

php - 在布局中的 Laravel 5.3 View 中包含 PHP 变量

基于Laravel通知电子邮件模板,这是我正在尝试做的事情。我尝试为电子邮件设计一个带有变量的布局,以便在我的布局中定义一些样式,但可以在我的电子邮件View中访问。这是一个例子:emails/layout.blade.php[...]@php$style=['body'=>'font-size:12px;color:#000;','paragraph'=>'font-size:10px;color:#eee;'];@endphp@yield('content')在我的电子邮件View中:@extends('emails.layout')@section('content')Hithe

php - 如何在 codeigniter 的核心函数中加载 View 文件

我正在尝试加载application/core/MY_Controller.php中的View文件,但它给出如下。Message:Undefinedproperty:Edustaticlanding::$loadFilename:core/MY_Controller.phpMY_Controller.php中函数如下functionmenu(){$arrr=array();return$arrdata['menu']=$this->load->view('menu',$arrr,true);}我在Controller(Edustaticlanding.php)中调用这个函数如下。fun

php - 了解 Laravel View Composer : Where does my view composer belong?

我正在阅读Laravel文档以加深理解,这将是我第二次遇到一些困惑。不久前,我正在观看一个Laracasts视频,其中我们在AppServicesProvider注册方法中实现了一个Viewcomposer。看起来像这样:publicfunctionregister(){view()->composer('layouts.sidebar',function($view){$archives=\App\Post::archives();$tags=\App\Tag::has('posts')->pluck('name');$view->with(compact('archives','t

php - 返回或回显 View 有什么区别?返回 View 比 echo View 说话的时间更长

加载View的最佳做法是什么。文档说在此处加载Viewhttps://laravel.com/docs/5.7/views以下是我的代码:if(isset($results['status'])){$error[]=$results['msg'];$request->session()->flash('message.level','danger');$request->session()->flash('message.content',$error);}else{if(view()->exists('import.device.results')){echoview('import

PhpStorm 2019.2 Symfony Controller 中未使用的元素

我正在使用PhpStorm2019.2在SymfonyController中,方法被突出显示为未使用。Xdebug,然后我得到一个错误我阅读了https://youtrack.jetbrains.com这可能是一个错误,新版本的IDE不能正确使用注释C:\OpenServer\OSPanel\modules\php\PHP_7.2\php.exe-dxdebug.remote_enable=1-dxdebug.remote_mode=req-dxdebug.remote_port=9090-dxdebug.remote_host=127.0.0.1C:\OpenServer\OSPan

php - 在 Controller 中传递变量

我想将变量从一个Controller函数传递到另一个Controller函数。换句话说,如何从同一Controller中的其他函数访问变量?谢谢 最佳答案 正如Pascal提到的,一种方法是在对象上设置一个属性:classCategoriesControllerextendsAppController{public$foo='';publicfunctionindex(){$this->foo='bar';}publicfunctionview($id=null){$baz=$this->foo;$this->set('baz',$