Laravel控制器和视图
2024-10-18 18:23:14
控制器,rawSQL,Model
controller.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests;
use DB; class MyController extends Controller
{
public function hello()
{ $articles = DB::select('select * from posts'); return View('myview',['d1'=>$articles]);
}
}
这里控制器给blade页面传递了一个数组,这个数组是直接通过数据库查询来的。
*.blade.php
@extends('layouts.app') @section('content')
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-heading">{{ count($d1) }}</div> <div class="panel-body">
this is my view!
</div> @for($i = 0; $i < count($d1); $i++)
<p>{{ $d1[$i]->content }}</p>
@endfor </div>
</div>
</div>
</div>
@endsection
最新文章
- ump_player在线直播播放器
- Upgrade NE script with GUI but cannot support multithread, need to add soon
- PC端重置
- 【BZOJ3439】Kpm的MC密码 trie树+主席树
- LTE Module User Documentation(翻译12)——X2切换(X2-based handover)
- 9月15日,YTFCloud,创业圈的技术新宠
- 使用Fabric进行crash收集统计
- JGibbLDA、GibbsLDA++问题解决
- 实现app上对csdn的文章查看,以及文章中图片的保存 (制作csdn app 完结篇)
- ASP.NET-FineUI开发实践-12
- Java--static interface
- liunx清理磁盘du -h --max-depth=1 /data/*
- centos6+cdh5.4.0 离线搭建cdh搭建
- 浅谈Linux基本命令
- Bugku-CTF之成绩单(快来查查成绩吧)
- union、union all 、distinct的区别和用途
- Java基础之IO流学习总结
- Android Studio 3依赖配置
- Sumo生成数据
- Python Singleton模式