laravel的环境搭建
1、集成开发环境:PHPSTORM;
2、快速搭建PHP/laravel运行/开发环境:laragon;
3、快速创建Laravel App
- 项目名称
4、创建成功,重新加载Apache运行laravel
5、使用PhpStorm打开工程目录
创建视图:在resources/views目录下创建todos用于存放相关视图
- 建立index.blade.php用于列表展示,并在视图中引入bootstrap模板
@extends('layouts.app')
@section('title','TODO LIST')
@section('content')
<h1 class="text-center my-5">Todo Page</h1>
<div class="row justify justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">
Todo List
</div>
<div class="card-body">
<ul class="list-group">
@foreach($todos ?? '' as $todo)
<li class="list-group-item">
<span @if($todo->is_completed) style="..."@endif>
{
{
$todo->name}}
</span>
{
{
--{
{
$todo->name}}
@if($todo->is_completed)
<span class="badge badge-pill badge-success">已完成</span>
@else
<span class="badge badge-pill badge-secondary">未完成</span>
@endif --}}
<a class="btn btn-primary float-right" href="/todos/{
{
$todo->id}}">View</a>
<form action="/todos/{
{
$todo->id}}" method="post"
class="d-inline-block float-right mr-2">
@method('delete')
@csrf
<button type="submit" class="btn btn-danger">Delete</button>
</form>
@if(!$todo->is_completed)
<form action="/todos/{
{
$todo->id}}/completed" method="post"
class="d-inline-block float-right mr-2">
@method('patch')
@csrf
<button type="submit" class="btn btn-warning">Complete</button>
</form>
@endif
</li>
@endforeach
</ul>
</div>
</div>
</div>
</div>
@endsection
- 添加show.blade.php用于展示单个资源
@extends('layouts.app')
@section('title','TODO SHOW')
@section('content')
<h1 class="text-center my-5">{
{
$todo->name}