-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhangbao05
committed
Nov 4, 2019
1 parent
b21dfac
commit c1966c4
Showing
5 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Admin\Controllers; | ||
|
||
class TopicController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$topics = \App\Topic::all(); | ||
return view('admin/topic/index', compact('topics')); | ||
} | ||
|
||
public function create() | ||
{ | ||
return view('admin/topic/create'); | ||
} | ||
|
||
public function store() | ||
{ | ||
$this->validate(request(), [ | ||
'name' => 'required|string' | ||
]); | ||
|
||
\App\Topic::create(['name' => request('name')]); | ||
|
||
return redirect("/admin/topics"); | ||
} | ||
|
||
public function destroy(\App\Topic $topic) | ||
{ | ||
$topic->delete(); | ||
|
||
return [ | ||
'error' => 0, | ||
'msg' => '' | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@extends('admin.layout.main') | ||
@section("content") | ||
<!-- Main content --> | ||
<section class="content"> | ||
<!-- Small boxes (Stat box) --> | ||
<div class="row"> | ||
<div class="col-lg-10 col-xs-6"> | ||
<div class="box"> | ||
|
||
<!-- /.box-header --> | ||
<div class="box box-primary"> | ||
<div class="box-header with-border"> | ||
<h3 class="box-title">增加专题</h3> | ||
</div> | ||
<!-- /.box-header --> | ||
<!-- form start --> | ||
<form role="form" action="/admin/topics" method="POST"> | ||
{{csrf_field()}} | ||
<div class="box-body"> | ||
<div class="form-group"> | ||
<label for="exampleInputEmail1">专题名</label> | ||
<input type="text" class="form-control" name="name"> | ||
</div> | ||
</div> | ||
<!-- /.box-body --> | ||
<div class="box-footer"> | ||
<button type="submit" class="btn btn-primary">提交</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
<!-- /.content --> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@extends('admin.layout.main') | ||
@section("content") | ||
<!-- Main content --> | ||
<section class="content"> | ||
<!-- Small boxes (Stat box) --> | ||
<div class="row"> | ||
<div class="col-lg-10 col-xs-6"> | ||
<div class="box"> | ||
|
||
<div class="box-header with-border"> | ||
<h3 class="box-title">专题列表</h3> | ||
</div> | ||
<a type="button" class="btn " href="/admin/topics/create">增加专题</a> | ||
<!-- /.box-header --> | ||
<div class="box-body"> | ||
<table class="table table-bordered"> | ||
<tbody> | ||
<tr> | ||
<th style="width: 10px">#</th> | ||
<th>专题名称</th> | ||
<th>操作</th> | ||
</tr> | ||
@foreach($topics as $topic) | ||
<tr> | ||
<td>{{$topic->id}}</td> | ||
<td>{{$topic->name}}</td> | ||
<td> | ||
<a type="button" class="btn resource-delete" delete-url="/admin/topics/{{$topic->id}}" | ||
href="#">删除</a> | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
<!-- /.content --> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters