Commit 6657f6e9 authored by gxx's avatar gxx

登陆成功

parent f95ff869
<?php
/**
* Created by PhpStorm.
* User: Aladin
* Date: 2017/11/28
* Time: 14:45
*/
namespace App\Contracts;
interface AdminServiceContract
{
public function login($email,$password);
public function logOut();
public function add($name,$email,$password);
public function delete();
public function update();
public function get();
public function getAll();
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mirzat
* Date: 2017/9/18
* Time: 14:47
*/
namespace App\Contracts;
use App\Models\User;
use Illuminate\Http\Request;
interface AuthServiceContract
{
public function register($phone,$password,$user_name,$gender);
public function loginWithPhone($phone,$password);
public function loginWithEmail($email,$password);
public function login(User $user);
public function setUser(User $user);
public function getUser();
public function checkLogin();
public function logout();
}
\ No newline at end of file
<?php
namespace App\Http\Controllers;
use App\Contracts\AdminServiceContract;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
class AdminController extends Controller
{
public function __construct(AdminServiceContract $adminHandle)
{
$this->mAdmin = $adminHandle;
}
public function login(Request $request)
{
$email = $request->email;
$password = $request->password;
$admin = $this->mAdmin->login($email,$password);
if($admin){
return redirect(route('/'));
}else{
return redirect()->back();
}
}
public function add(Request $request)
{
$rules = [
'name'=>'required',
'email'=>'required',
'password'=>'required'
];
$validator = Validator::make($request->all(),$rules);
if($validator->fails()){
return redirect(route('500'));
}else {
$name = $request->name;
$email = $request->email;
$password = $request->password;
$admin = $this->mAdmin->add($name,$email,$password);
if ($admin ){
return redirect(route('admin.getAll'));
}else{
return redirect(route('500'));
}
}
}
public function getAll()
{
$admins = $this->mAdmin->getAll();
return view('admin/admin/admintables',compact('admins'));
}
}
<?php
namespace App\Providers;
use App\Services\AdminService;
use Illuminate\Support\ServiceProvider;
class AdminServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//绑定服务与接口关系
$this->app->singleton("App\Contracts\AdminServiceContract",function(){
return new AdminService();
});
}
}
<?php
/**
* Created by PhpStorm.
* User: Aladin
* Date: 2017/11/28
* Time: 14:48
*/
namespace App\Services;
use App\Contracts\AdminServiceContract;
use App\Models\Admin;
use Illuminate\Support\Facades\Hash;
class AdminService implements AdminServiceContract
{
public function login($email,$password)
{
$admin = Admin::where('email',$email)->first();
if($admin==null){
return null;
}
if (Hash::check($password,$admin->password)){
session(['admin'=>$admin]);
return $admin;
}
return null;
}
public function logOut()
{
// TODO: Implement logOut() method.
}
public function add($name,$email,$password)
{
$admin = new Admin();
$admin->name = $name;
$admin->email = $email;
$admin->password = bcrypt($password);
$admin->save();
return $admin;
}
public function delete()
{
// TODO: Implement delete() method.
}
public function update()
{
// TODO: Implement update() method.
}
public function get()
{
// TODO: Implement get() method.
}
public function getAll()
{
$admins = Admin::all();
if($admins->isEmpty()){
return null;
}
return $admins;
}
}
\ No newline at end of file
...@@ -184,6 +184,7 @@ return [ ...@@ -184,6 +184,7 @@ return [
App\Providers\SMSServiceProvider::class, App\Providers\SMSServiceProvider::class,
App\Providers\UserServiceProvider::class, App\Providers\UserServiceProvider::class,
App\Providers\StatisticsServiceProvider::class, App\Providers\StatisticsServiceProvider::class,
App\Providers\AdminServiceProvider::class,
Zizaco\Entrust\EntrustServiceProvider::class, Zizaco\Entrust\EntrustServiceProvider::class,
Orangehill\Iseed\IseedServiceProvider::class, Orangehill\Iseed\IseedServiceProvider::class,
......
...@@ -15,6 +15,7 @@ class CreateAdminsTable extends Migration ...@@ -15,6 +15,7 @@ class CreateAdminsTable extends Migration
{ {
Schema::create('admins', function (Blueprint $table) { Schema::create('admins', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->string('name');
$table->string('email'); $table->string('email');
$table->string('password'); $table->string('password');
$table->timestamps(); $table->timestamps();
......
@extends('admin/dashboard')
@section('content')
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
管理员添加
{{--<small>advanced tables</small>--}}
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li><a href="#">Tables</a></li>
<li class="active">Data tables</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
{{--<h3 class="box-title">Hover Data Table</h3>--}}
</div>
<!-- /.box-header -->
<div class="box-body" style="">
<br>
<form action="{{route('admin.add')}}" method="get" >
{{--{{csrf_field()}}--}}
{{--<div style="margin-left: 15%;margin-right:20%;">--}}
{{--<div style="float:left; width:200px;height: 100%;">--}}
{{--<p><h4><b>选择角色 or 权限配置</b></h4></p>--}}
{{--@if($roles ==null)--}}
{{--@else--}}
{{--@foreach($roles as $role)--}}
{{--<div class="a" style="text-indent: 1em;" >--}}
{{--<label><input type="checkbox" value="{{$role->id}}" name="role[]" class="da">{{$role->display_name}}</label>--}}
{{--@foreach($role->permission as $per)--}}
{{--<label style="text-indent: 4em;">--}}
{{--<input type="checkbox" value="{{$per->id}}" name="permission[]" class="abc">{{$per->display_name}}</label>--}}
{{--@endforeach--}}
{{--</div>--}}
{{--@endforeach--}}
{{--@endif--}}
{{--</div>--}}
{{--</div>--}}
<!-- /.box-body -->
<script src="{{url('js/jquery-3.2.1.min.js')}}"> </script>
<script>
$(document).ready(function() {
$('.da').click(function () {
var labels = $(this).parent().nextAll();
$.each(labels, function (index, item) {
var a = $(item).find('input');
if (a.prop("checked")) {
a.removeAttr("checked");
} else {
a.prop("checked", true);
}
})
})
$('.abc').click(function () {
// var labels = $(this).parent().prev();
// $.each(labels, function (index, item) {
// var a = $(item).find('input');
//// $('.da').prop('checked') = false
//// a[0].checked = false;
//
// })
var labels = $(this).parent().parent();
$.each(labels, function (index, item) {
var a = $(item).find('input');
a[0].checked = false;
})
})
});
</script>
<div style="float: right;margin-right: 15%">
<p><h4><b> 填写用户资料</b></h4></p>
<!-- general form elements -->
<div style="width:510px;">
<div class="box-body">
<div class="form-group">
<label for="exampleInputEmail1">Email</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email" name="email" style="width: 500px;">
</div>
<div class="form-group">
<label for="exampleInputEmail1">name</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="name" name="name" style="width: 500px;">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" name="password" style="width: 500px;">
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<button type="submit" class="btn btn-primary">添加</button>
</div>
</div>
</div>
</form>
</div>
</div>
<!-- /.box -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
@endsection
\ No newline at end of file
@extends('admin/dashboard')
@section('content')
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
管理员列表
{{--<small>advanced tables</small>--}}
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li><a href="#">Tables</a></li>
<li class="active">Data tables</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
{{--<h3 class="box-title">Hover Data Table</h3>--}}
</div>
<!-- /.box-header -->
<div class="box-body">
<!-- Small modal -->
{{--<a class="btn btn-primary" href="{{route('permission.addPage')}}">添加权限</a>--}}
<br>
<table id="example2" class="table table-condensed table-hover">
<thead>
<tr>
<th>ID</th>
<th>name</th>
<th>email</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
@if($admins == null)
<tbody>
<tr>
<td colspan="5" style="text-align: center;color: red"> 数据暂无 </td>
</tr>
</tbody>
</table>
@else
@foreach($admins as $admin)
<tbody>
<tr class="active">
<td>{{$admin['id']}}</td>
<td>{{$admin['name']}}</td>
<td>{{$admin['email']}}</td>
<td>{{$admin['created_at']}}</td>
<td>
<!-- Small modal -->
<a class="btn btn-primary" href="{{route('admin.updatePage',['id'=>$admin->id])}}">查看并编辑</a>
{{--<a class="btn btn-primary" href="{{route('permission.addChildPage',['id'=>$permission->id])}}"> 添加子权限 </a>--}}
</td>
</tr>
</tbody>
@endforeach
</table>
{{--{{ $groups->links() }}--}}
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- Button trigger modal -->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">添加新的权限</h4>
</div>
<div class="modal-body">
<!-- /.box-header -->
<!-- form start -->
<form action="{{route('login')}}">
<div class="box-body">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">权限名: &nbsp;&nbsp;</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="name">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">功能:&nbsp;</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputPassword3" placeholder="display_name">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">介绍: &nbsp;</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputPassword3" placeholder="description">
</div>
</div>
<!-- /.box-body -->
<!-- /.box-footer -->
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary">保存</button>
</div>
</div>
</div>
</div>
@endif
@endsection
\ No newline at end of file
@extends('admin/dashboard')
@section('content')
<!-- Content Wrapper. Contains page content -->
<!-- Main content -->
<section class="content">
<div class="error-page">
<h2 class="headline text-yellow"> 404</h2>
<div class="error-content">
<h3><i class="fa fa-warning text-yellow"></i> Oops! Page not found.</h3>
<p>
We could not find the page you were looking for.
Meanwhile, you may <a href="../../index.html">return to dashboard</a> or try using the search form.
</p>
<button id="back"> 返回 </button>
</div>
<!-- /.error-content -->
</div>
<!-- /.error-page -->
</section>
<!-- /.content -->
<script src="{{url('js/jquery-3.2.1.min.js')}}"> </script>
<script>
$('#back').click(function () {
history.go(-1)
})
</script>
@endsection
\ No newline at end of file
@extends('admin/dashboard')
@section('content')
<!-- Main content -->
<section class="content">
<div class="error-page">
{{--<h2 class="headline text-red">500</h2>--}}
<div class="error-content">
<h3><i class="fa fa-warning text-red"></i>Missing parameters.</h3>
<p>
参数缺少!请填写后再次操作........
</p>
<button id="back"> 返回 </button>
</div>
</div>
<!-- /.error-page -->
</section>
<script src="{{url('js/jquery-3.2.1.min.js')}}"> </script>
<script>
$('#back').click(function () {
history.go(-1)
})
</script>
@endsection
\ No newline at end of file
@extends('admin/dashboard')
@section('content')
<!-- Content Wrapper. Contains page content -->
<!-- Main content -->
<section class="content">
<div class="error-page">
<h2 class="headline text-yellow"> </h2>
<div class="error-content">
<h3><i class="fa fa-warning text-yellow"></i> Failed to open the page.</h3>
<p>
你的权限你不够!请联系管理员开通...
</p>
<button id="back"> 返回 </button>
</div>
<!-- /.error-content -->
</div>
<!-- /.error-page -->
</section>
<!-- /.content -->
<script src="{{url('js/jquery-3.2.1.min.js')}}"> </script>
<script>
$('#back').click(function () {
history.go(-1)
})
</script>
@endsection
\ No newline at end of file
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
</a> </a>
<ul class="treeview-menu"> <ul class="treeview-menu">
<li><a href="#">管理员列表</a></li> <li><a href="#">管理员列表</a></li>
<li><a href="#">添加管理员</a></li> <li><a href="{{route('admin.addPage')}}">添加管理员</a></li>
</ul> </ul>
</li> </li>
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<div class="login-box-body"> <div class="login-box-body">
<p class="login-box-msg">Sign in to start your session</p> <p class="login-box-msg">Sign in to start your session</p>
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<form action="{{url('admin/login')}}" method="post" > <form action="{{route('login')}}" method="post" >
{{csrf_field()}} {{csrf_field()}}
...@@ -48,9 +48,9 @@ ...@@ -48,9 +48,9 @@
<div class="row"> <div class="row">
<div class="col-xs-8"> <div class="col-xs-8">
<div class="checkbox icheck"> <div class="checkbox icheck">
<label> {{--<label>--}}
<input type="checkbox"> Remember Me {{--<input type="checkbox"> Remember Me--}}
</label> {{--</label>--}}
</div> </div>
</div> </div>
<!-- /.col --> <!-- /.col -->
...@@ -60,9 +60,13 @@ ...@@ -60,9 +60,13 @@
<!-- /.col --> <!-- /.col -->
</div> </div>
</form> </form>
</div> </div>
<!-- /.login-box-body --> <!-- /.login-box-body -->
</div> </div>
...@@ -75,7 +79,20 @@ ...@@ -75,7 +79,20 @@
<!-- iCheck --> <!-- iCheck -->
<script src="{{asset('/bower_components/AdminLTE/plugins/iCheck/icheck.min.js')}}"></script> <script src="{{asset('/bower_components/AdminLTE/plugins/iCheck/icheck.min.js')}}"></script>
<script src="{{url('js/jquery-3.2.1.min.js')}}"> </script>
<script> <script>
$(document).ready(function () {
//alert(1)
})
$(function () { $(function () {
$('input').iCheck({ $('input').iCheck({
checkboxClass: 'icheckbox_square-blue', checkboxClass: 'icheckbox_square-blue',
......
...@@ -17,116 +17,138 @@ ...@@ -17,116 +17,138 @@
// 登录 Route::get('500',function (){
Route::get('login',function (){ return view('admin/error/500');
})->name('500');
return view('login'); Route::get('404',function (){
return view('admin/error/404');
})->name('404');
})->name('login');
Route::get('permission',function (){
return view('admin/error/permission');
})->name('permission');
// 登录
Route::get('a',function (){
return view('login');
})->name('a');
Route::post('login','AdminController@login')->name('login');
// admin
Route::group(['prefix'=>'admin'],function (){
route::get('add_page',function (){ return view('admin/admin/addadmin'); })->name('admin.addPage');
// 统计 首页 route::get('add','AdminController@add')->name('admin.add');
Route::get('/','StatisticsController@newUser'); route::get('get_all','AdminController@getAll')->name('admin.getAll');
Route::get('statistics','StatisticsController@newUser'); route::get('update_page',function (){return view('admin/admin/update'); })->name('admin.updatePage');
});
Route::get('admin',function (){
return view('Admin-lte/dashboard');
});
// 短信 // 统计 首页
Route::get('sms','SMSController@surplus'); Route::get('/','StatisticsController@newUser')->name('/');
Route::get('statistics','StatisticsController@newUser');
// 测试路由
Route::get('test','Testcontroller@test')->name('test');
Route::get('admin',function (){
return view('Admin-lte/dashboard');
});
// 短信
Route::get('sms','SMSController@surplus');
// 用户
Route::group(['prefix'=> 'user'],function (){
Route::get('getAll','UserController@getAll')->name('user.getAll'); // 测试路由
Route::get('get/{id}','UserController@get')->name('user.get'); Route::get('test','Testcontroller@test')->name('test');
Route::get('updatePage/{id}','UserController@updatePage')->name('user.updatePage');
Route::post('update','UserController@update')->name('user.update');
Route::get('search','UserController@simpleSearch')->name('user.search');
});
// 用户
Route::group(['prefix'=> 'user'],function (){
// 团队 Route::get('getAll','UserController@getAll')->name('user.getAll');
Route::group(['prefix'=> 'group'],function (){ Route::get('get/{id}','UserController@get')->name('user.get');
Route::get('updatePage/{id}','UserController@updatePage')->name('user.updatePage');
Route::post('update','UserController@update')->name('user.update');
Route::get('search','UserController@simpleSearch')->name('user.search');
Route::get('getAll','GroupController@getAll')->name('group.getAll');
Route::get('get','GroupController@get')->name('group.get');
Route::get('updatePage','GroupController@updatePage')->name('group.updatePage');
Route::post('update','GroupController@update')->name('group.update');
Route::get('transferPage','GroupController@transferPage')->name('group.transferPage');
Route::get('ajax/{phone}','GroupController@ajax')->name('group.ajax');
Route::post('transfer','GroupController@transfer')->name('group.transfer');
Route::get('search','GroupController@simpleSearch')->name('group.search');
Route::get('search_user/{search}','GroupController@simpleSearchUser')->name('group.simpleSearchUser');
Route::get('invite_page','GroupController@invitePage')->name('group.invitePage'); });
Route::post('invite','GroupController@invite')->name('group.invite');
});
// 项目 // 团队
Route::group(['prefix'=> 'project'],function (){ Route::group(['prefix'=> 'group'],function (){
Route::get('getAll','ProjectController@getAll')->name('project.getAll');
Route::get('get','ProjectController@get')->name('project.get');
Route::get('updatePage','ProjectController@updatePage')->name('project.updatePage');
Route::post('update','ProjectController@update')->name('project.update');
Route::get('search','ProjectController@search')->name('project.search');
}); Route::get('getAll','GroupController@getAll')->name('group.getAll');
Route::get('get','GroupController@get')->name('group.get');
Route::get('updatePage','GroupController@updatePage')->name('group.updatePage');
Route::post('update','GroupController@update')->name('group.update');
Route::get('transferPage','GroupController@transferPage')->name('group.transferPage');
Route::get('ajax/{phone}','GroupController@ajax')->name('group.ajax');
Route::post('transfer','GroupController@transfer')->name('group.transfer');
Route::get('search','GroupController@simpleSearch')->name('group.search');
Route::get('search_user/{search}','GroupController@simpleSearchUser')->name('group.simpleSearchUser');
Route::get('invite_page','GroupController@invitePage')->name('group.invitePage');
Route::post('invite','GroupController@invite')->name('group.invite');
// 统计
Route::group(['prefix'=> 'statistics'],function (){
Route::get('user_increase','StatisticsController@UserIncrease')->name('statistics.UserIncrease');
Route::get('active_user','StatisticsController@ActiveUser')->name('statistics.ActiveUser');
Route::get('outflow_user','StatisticsController@OutflowUser')->name('statistics.OutflowUser');
Route::get('return_visit','StatisticsController@ReturnVisit')->name('statistics.ReturnVisit');
Route::get('user_retention','StatisticsController@UserRetention')->name('statistics.UserRetention');
Route::get('average_user_operation','StatisticsController@AverageUserOperation')->name('statistics.AverageUserOperation');
Route::get('retention_time','StatisticsController@RetentionTime')->name('statistics.RetentionTime');
Route::get('new_user','StatisticsController@NewUsers')->name('statistics.NewUser');
Route::get('user_engagement','StatisticsController@UserEngagement')->name('statistics.UserEngagement');
Route::get('total','StatisticsController@Total')->name('statistics.Total');
});
});
// 项目
Route::group(['prefix'=> 'project'],function (){
Route::get('getAll','ProjectController@getAll')->name('project.getAll');
Route::get('get','ProjectController@get')->name('project.get');
Route::get('updatePage','ProjectController@updatePage')->name('project.updatePage');
Route::post('update','ProjectController@update')->name('project.update');
Route::get('search','ProjectController@search')->name('project.search');
});
// 权限
Route::group(['prefix'=> 'auth'],function (){
Route::get('getAll','AuthController@getAll')->name('auth.getAll');
Route::get('add','AuthController@add')->name('auth.add');
});
// 统计
Route::group(['prefix'=> 'statistics'],function (){
Route::get('user_increase','StatisticsController@UserIncrease')->name('statistics.UserIncrease');
Route::get('active_user','StatisticsController@ActiveUser')->name('statistics.ActiveUser');
Route::get('outflow_user','StatisticsController@OutflowUser')->name('statistics.OutflowUser');
Route::get('return_visit','StatisticsController@ReturnVisit')->name('statistics.ReturnVisit');
Route::get('user_retention','StatisticsController@UserRetention')->name('statistics.UserRetention');
Route::get('average_user_operation','StatisticsController@AverageUserOperation')->name('statistics.AverageUserOperation');
Route::get('retention_time','StatisticsController@RetentionTime')->name('statistics.RetentionTime');
Route::get('new_user','StatisticsController@NewUsers')->name('statistics.NewUser');
Route::get('user_engagement','StatisticsController@UserEngagement')->name('statistics.UserEngagement');
Route::get('total','StatisticsController@Total')->name('statistics.Total');
});
// 权限
Route::group(['prefix'=> 'auth'],function (){
Route::get('getAll','AuthController@getAll')->name('auth.getAll');
Route::get('add','AuthController@add')->name('auth.add');
});
Route::get('table',function (){
return view('admin/usertables');
});
//Auth::routes();
//Route::get('/home', 'HomeController@index')->name('home');
Route::get('table',function (){
return view('admin/usertables');
});
//Auth::routes();
//Route::get('/home', 'HomeController@index')->name('home');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment