Laravel展示产品-CRUD之show

  上一篇讲了Laravel创建产品-CRUD之Create and Store,现在我们来做产品展示模块,用到是show,①首先我们先修改controller,文件是在/app/Http/Controllers/ItemController.php,定义一下show function

    public function show($id)
    {
        $item = Item::find($id);
        return view('items.show')->with('item', $item);
    }

  ②创建show模板,文件是/resources/views/items/show.blade.php,添加如下代码

@extends('layouts.app')

@section('content')
    
Item:{{$item->id}}
{{$item->id}}
{{$item->name}}
{{$item->price}}
{{$item->description}}
{{$item->created_at}}
{{$item->updated_at}}
@endsection

Laravel展示产品-CRUD之show_第1张图片  

你可能感兴趣的:(Laravel展示产品-CRUD之show)