laravel 控制器跳转_Laravel的控制器
laravel 控制器跳转
For further process we need to know something about it,
为了进一步处理,我们需要了解一些有关它的信息,
-
You can say that the Controller is the entry point of any project or any web-based application because you can assume it's meaning by the name itself.
您可以说Controller是任何项目或任何基于Web的应用程序的入口点,因为您可以假设名称本身就是它的含义。
-
We make a controller to control our project. It receives HTTP requests, communicates with models and manages the views of our project.
我们制作一个控制器来控制我们的项目。 它接收HTTP请求,与模型进行通信并管理我们项目的视图。
Laravel的控制器 (Controller in Laravel)
ADD the postcontroller with --resource parameters on CMD,
在CMD上使用--resource参数添加后控制器 ,
$ php artisan make:controller PostController --resource
Path: "app/http/controller/PostController.php"
路径: “ app / http / controller / PostController.php”
In postcontroller, we use our model (post) model
在postcontroller中 ,我们使用模型(post)模型
-
use "App\post" (on top of the file)
使用“ App \ post” (在文件顶部)
-
public function index{}
公共职能指数{}
Example: PostController.php code for index method.
示例:用于索引方法的PostController.php代码。
use App\Post;
class PostController extends Controller
{
// Display a listing of the resource.
public function index()
{
$posts = Post::latest()->paginate(5);
return view('posts.index',compact('posts'))->with('i',(request()->input('page',1) -1) *5);
}
}
-
'index' method will show all data from the database to our index view.
“索引”方法将显示从数据库到索引视图的所有数据。
-
'paginate' method to sort data in the view.
'paginate'方法对视图中的数据进行排序。
-
The controller has created, store, show, update and destroy method with index method. We will also be using these methods in the upcoming article with an example or with creating a form.
控制器已使用索引方法创建,存储,显示,更新和销毁方法。 在后面的文章中,我们还将通过示例或创建表单来使用这些方法。
-
After creating a route declaration in route.php in the controller directory.
在controller目录中的route.php中创建路由声明之后。
-
In the controller directory, the auth folder exists which is pre-defined in Laravel for reset password, Login, and Register.
在controller目录中 ,存在auth文件夹 ,该文件夹在Laravel中预定义,用于重置密码,登录和注册。
Conclusion:
结论:
In this article, we have learnt about the Controller in Laravel. I hope you understood the concept, we will be knowing more about it in the upcoming articles. Have a great day! Happy Learning!
在本文中,我们了解了Laravel中的Controller 。 希望您理解这个概念,我们将在以后的文章中进一步了解它。 祝你有美好的一天! 学习愉快!
laravel 控制器跳转
上一篇: WinForm中更改下拉选项实现页面刷新 TextChanged事件
下一篇: Eclipse 内存分析器MAT(一)--MAT安装配置 博客分类: Eclipse eclipsememory analyzer
推荐阅读