首页 > 其他分享 >laravel:blade模板(10.27.0)

laravel:blade模板(10.27.0)

时间:2023-10-23 09:03:58浏览次数:44  
标签:laravel name 10.27 blade li title post php

一,相关文档:

https://learnku.com/docs/laravel/10.x/blade/14852

二,创建controller和view

1,创建controller

liuhongdi@lhdpc:/data/laravel/dignews$ php artisan make:controller CommentController
   INFO  Controller [app/Http/Controllers/CommentController.php] created successfully.

2,创建view

liuhongdi@lhdpc:/data/laravel/dignews$ php artisan make:view CommentList
   INFO  View [resources/views/CommentList.blade.php] created successfully.

三,php代码:

1,app/Http/Controllers/CommentController.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 <?php   namespace App\Http\Controllers;   use Illuminate\Http\Request;   class CommentController extends Controller {     //启用事务     public function commentList(Request $request) {         $title = "评论列表";         $content = "请文明发言,自觉遵守相关的互联网法律法规";         $menu = ['原神','反恐精英','吃鸡'];           $ls = [             ['name'=>"张三",                 "post"=>"支持原神",                 "reply"=>[                     ["name"=>"李四",                     "post"=>"反对1"],                     ["name"=>"王五",                         "post"=>"反对2"],                 ],             ],             ['name'=>"赵六",                 "post"=>"支持黎明",                 "reply"=>[                     ["name"=>"王老七",                         "post"=>"支持学友"],                     ["name"=>"王大拿",                         "post"=>"支持刘能"],                 ],             ],         ];           return view('CommentList', [             'title' => $title,             'content' => $content,             'menu'=>$menu,             'list'=>$ls,         ]);     } }

2,resources/views/CommentList.blade.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>{{$title}}</title> </head> <body>   <h1>{{$title}}</h1>   {{$content}}   <ul> @foreach($menu as $v)     <li>{{$v}}</li> @endforeach </ul>   <ul> @foreach($list as $one)     <li><div>{{$one['name']}}:{{$one['post']}}</div>         <div>         <ul>              @foreach($one['reply'] as $k =>$value)         <li><div>{{$value['name']}}:{{$value['post']}}</div>         </li>               @endforeach         </ul>         </div>     </li>   @endforeach </ul>   </body> </html>

说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/10/22/laravel-blade-mu-ban/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com

四,测试效果:

五,查看laravel框架的版本:

liuhongdi@lhdpc:/data/laravel/dignews$ php artisan --version
Laravel Framework 10.27.0

标签:laravel,name,10.27,blade,li,title,post,php
From: https://www.cnblogs.com/architectforest/p/17781573.html

相关文章

  • laravel:服务容器(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/container/14842二,php代码:假设我们有两种商品:虚拟商品如账号,实体商品如手办需要销售1,App\extend\mall\GoodsInterface.php1234567<?phpnamespaceApp\extend\mall;//接口interfaceGoodsInterfa......
  • laravel:服务提供者(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/providers/14843二,php代码:1,业务代码:App\extend\mall\GoodsInterface.php1234567<?phpnamespaceApp\extend\mall;//接口interfaceGoodsInterface{    publicfunctionsale();}......
  • laravel:捕捉异常记录到日志(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/errors/14857#9e8f93二,php代码:1,代码:12345678910111213141516171819202122232425262728classNewsControllerextendsController{    //启用事务    publicfuncti......
  • laravel:定时任务(10.27.0)
    一,相关的文档:https://learnku.com/docs/laravel/10.x/scheduling/14875二,php代码:1,创建command:liuhongdi@lhdpc:/data/laravel/dignews$phpartisanmake:commandOrderStatus   INFO  Consolecommand[app/Console/Commands/OrderStatus.php]createdsucces......
  • laravel:使用tinker(10.27.0)
    一,启动与退出:liuhongdi@lhdpc:/data/laravel/dignews$phpartisantinkerPsyShellv0.11.22(PHP8.1.1—cli)byJustinHileman>exit   INFO  Goodbye.二,查询数据liuhongdi@lhdpc:/data/laravel/dignews$phpartisantinkerPsyShellv0.11.22(PHP8.1.......
  • php js + laravel + mysql开发的手术麻醉临床信息系统源码
    手术麻醉临床信息系统有着完善的临床业务功能,能够涵盖整个围术期的工作,能够采集、汇总、存储、处理、展现所有的临床诊疗资料。通过该系统的实施,能够规范麻醉科的工作流程,实现麻醉手术过程的信息数字化,自动生成麻醉的各种医疗文书,完成共享HIS、LIS、PACS和EMR等手术患者信息,从而提......
  • laravel:开启/关闭调试模式(10.27.0)
    一,文档地址:https://learnku.com/docs/laravel/10.x/configuration/14836#701998二,设置1,.env中关于调试的默认值:APP_DEBUG=true2,关闭调试APP_DEBUG=false说明:刘宏缔的架构森林—专注it技术的博客,网站:https://blog.imgtouch.com原文: https://blog.imgtouch.com/ind......
  • laravel:访问redis(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/redis/14887二,php代码1,配置.env使用默认的设置:REDIS_HOST=127.0.0.1REDIS_PASSWORD=nullREDIS_PORT=63792,controller中引用:12345678910111213141516171819202122232425<?ph......
  • laravel:关闭默认首页(10.27.0)
    一,php代码修改routes/web.php原代码:Route::get('/',function(){    returnview('welcome');});修改后Route::get('/',function(){    $appName=env('APP_NAME');    return['code'=>0,'msg'=>&#......
  • laravel:部署到nginx服务器(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/deployment/14840二,配置nginx1,站点文件server{listen80;#listen[::]:80;server_namedig.lhdtest.com;root/webdata/site/dig/public;add_headerX-Frame-Options"SAMEORIGIN";a......