-
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
Showing
15 changed files
with
308 additions
and
2 deletions.
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
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,27 @@ | ||
<?php | ||
namespace App\Admin\Controllers; | ||
|
||
|
||
use App\Post; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class PostController extends Controller | ||
{ | ||
//文章审核页面 | ||
public function index() | ||
{ | ||
// $posts = DB::table('posts')->where('status',0)->get(); | ||
$posts = Post::withoutGlobalScope('available')->where('status',0)->get(); | ||
// dd($posts); | ||
return view('admin.post.index',compact('posts')); | ||
} | ||
|
||
public function check(Post $post) | ||
{ | ||
$post->status = request('status'); | ||
dd($post); | ||
return ; | ||
} | ||
|
||
|
||
} |
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,35 @@ | ||
<?php | ||
namespace App\Admin\Controllers; | ||
|
||
use App\AdminUser; | ||
use Illuminate\Http\Request; | ||
|
||
class UserController extends Controller | ||
{ | ||
//管理员列表页面 | ||
public function index() | ||
{ | ||
$users = AdminUser::paginate(10); | ||
return view('admin.user.index',compact('users')); | ||
} | ||
|
||
public function create() | ||
{ | ||
return view('admin.user.create'); | ||
} | ||
|
||
public function store(Request $request) | ||
{ | ||
$this->validate($request,[ | ||
'name' =>'required', | ||
'password' =>'required|min:3|max:10', | ||
]); | ||
$name = request('name'); | ||
$password = bcrypt(request('password')); | ||
$res = AdminUser::firstOrCreate(compact('name')); | ||
$res && AdminUser::where('id',$res->id)->update(compact('password')); | ||
return redirect('admin/users'); | ||
} | ||
|
||
|
||
} |
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,10 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class AdminUser extends Model | ||
{ | ||
protected $guarded = ['_token']; | ||
} |
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
34 changes: 34 additions & 0 deletions
34
database/migrations/2017_08_23_135046_create_admin_users_table.php
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,34 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateAdminUsersTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('admin_users', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('name'); | ||
$table->string('password'); | ||
$table->rememberToken(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('admin_users'); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
database/migrations/2017_08_23_153602_alter_posts_table.php
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,32 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class AlterPostsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table('posts', function (Blueprint $table) { | ||
$table->tinyInteger('status')->default(0);//0 未知 1审核通过 -1已删除 | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table('posts', function (Blueprint $table) { | ||
$table->dropColumn('status'); | ||
}); | ||
} | ||
} |
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,13 @@ | ||
|
||
|
||
function check(button) { | ||
var post_id=$(button).attr('post-id'); | ||
var status = $(button).attr('post-action-status'); | ||
$.post('posts/'+post_id+'/check',{'status':status},function (res) { | ||
if(res.status==1) { | ||
alert('成功'); | ||
}else if (res.status==0) { | ||
alert('失败'); | ||
} | ||
},'json'); | ||
} |
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,41 @@ | ||
@extends('admin.layout.main') | ||
@section('content') | ||
<div class="content-wrapper"> | ||
|
||
<!-- 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> | ||
<!-- /.box-header --> | ||
<div class="box-body"> | ||
<table class="table table-bordered"> | ||
<tbody><tr> | ||
<th style="width: 10px">#</th> | ||
<th>文章标题</th> | ||
<th>操作</th> | ||
</tr> | ||
@foreach($posts as $key=>$post) | ||
<tr> | ||
<td>{{$key+1}}</td> | ||
<td><a href="{{url('posts/'.$post->id.'')}}">{{$post->title}}</a> </td> | ||
<td> | ||
<button type="button" class="btn btn-block btn-default post-audit" post-id="{{$post->id}}" onclick="check(this)" post-action-status="1" >通过</button> | ||
<button type="button" class="btn btn-block btn-default post-audit" post-id="{{$post->id}}" onclick="check(this)" post-action-status="-1" >拒绝</button> | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody></table> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
<!-- /.content --> | ||
</div> | ||
@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,43 @@ | ||
@extends('admin.layout.main') | ||
@section('content') | ||
<div class="content-wrapper"> | ||
|
||
<!-- 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/users/store" method="POST"> | ||
{{csrf_field()}} | ||
<div class="box-body"> | ||
<div class="form-group"> | ||
<label for="exampleInputEmail1">用户名</label> | ||
<input type="text" class="form-control" name="name" placeholder="Name"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="exampleInputPassword1">密码</label> | ||
<input type="password" class="form-control" placeholder="Password" name="password"> | ||
</div> | ||
</div> | ||
<!-- /.box-body --> | ||
<div class="box-footer"> | ||
<button type="submit" class="btn btn-primary">提交</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
<!-- /.content --> | ||
</div> | ||
@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,43 @@ | ||
@extends('admin.layout.main') | ||
@section('content') | ||
<div class="content-wrapper"> | ||
|
||
<!-- 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/users/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($users as $key=>$user) | ||
<tr> | ||
<td>{{$key+1}}.</td> | ||
<td>{{$user->name}}</td> | ||
<td> | ||
<a type="button" class="btn" href="/admin/users/{{$user->id}}/role" >角色管理</a> | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody></table> | ||
{{$users->links()}} | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
<!-- /.content --> | ||
</div> | ||
@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
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