-
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
41 changed files
with
53,236 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 @@ | ||
<?php | ||
|
||
namespace App\Admin; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Member extends Model | ||
{ | ||
// 定义关联的表 | ||
protected $table = 'member'; | ||
} |
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,61 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
use App\Admin\Member; | ||
use Symfony\Component\Console\Input\Input; | ||
use DB; | ||
|
||
class MemberController extends Controller | ||
{ | ||
// 列表方法 | ||
public function index() { | ||
// 查询数据 | ||
$data = Member::get(); | ||
// 展示视图 | ||
return view('admin.member.index', compact('data')); | ||
} | ||
|
||
// 添加方法 | ||
public function add(Request $request) { | ||
// 判断请求类型 | ||
if ($request -> isMethod('POST')) { | ||
// 实现数据的保存 | ||
// 自动验证 | ||
$result = Member::insert([ | ||
'username' => $request -> get('username'), | ||
'password' => bcrypt('password'), | ||
'gender' => $request -> get('gender'), | ||
'mobile' => $request -> get('mobile'), | ||
'email' => $request -> get('email'), | ||
'avatar' => $request -> get('avatar'), | ||
'country_id'=> $request -> get('country_id'), | ||
'province_id'=> $request -> get('province_id'), | ||
'city_id' => $request -> get('city_id'), | ||
'county_id' => $request -> get('type'), | ||
'type' => $request -> get('status'), | ||
'status' => $request -> get('status'), | ||
'created_at'=> date('Y-m-d H:i:s') | ||
]); | ||
// 返回输出 | ||
return $result ? '1' : '0'; | ||
} else { | ||
// 查询数据(国家的数据) | ||
$country = DB::table('area') -> where('pid', '0') -> get(); | ||
// 展示视图 | ||
return view('admin.member.add', compact('country')); | ||
} | ||
} | ||
|
||
// ajax 四级联动获取下属地区 | ||
public function getAreaById(Request $request) { | ||
// 接收 id | ||
$id = $request -> get('id'); | ||
// 根据 id 去查询下属地区 | ||
$data = DB::table('area') -> where('pid', $id) -> get(); | ||
// 返回 json 数据 | ||
return response() -> json($data); | ||
} | ||
} |
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,62 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
use Storage; | ||
|
||
class UploaderController extends Controller | ||
{ | ||
// 上传文件的处理 | ||
function webuploader(Request $request) { | ||
// 判断是否有文件上传成功 | ||
if ($request -> hasFile('file') && $request -> file('file') -> isValid()) { | ||
// 有文件上传 | ||
$filename = sha1(time() . $request -> file('file') -> getClientOriginalName()) . '.' . $request -> file('file') -> getClientOriginalExtension(); | ||
// 文件保存 | ||
Storage::disk('public') -> put($filename, file_get_contents($request -> file('file') -> path())); | ||
// 返回数据 | ||
$result = [ | ||
'errCode' => '0', | ||
'errMsg' => '', | ||
'succMsg' => '文件上传成功', | ||
'path' => '/storage/' . $filename | ||
]; | ||
} else { | ||
// 没有文件上传或者出错 | ||
$result = [ | ||
'errCode' => '000001', | ||
'errMsg' => $request -> file('file') -> getErrorMessage(), | ||
]; | ||
} | ||
// 返回信息 | ||
return response() -> json($result); | ||
} | ||
|
||
// 上传文件的处理 | ||
function qiniu(Request $request) { | ||
// 判断是否有文件上传成功 | ||
if ($request -> hasFile('file') && $request -> file('file') -> isValid()) { | ||
// 有文件上传 | ||
$filename = sha1(time() . $request -> file('file') -> getClientOriginalName()) . '.' . $request -> file('file') -> getClientOriginalExtension(); | ||
// 文件保存 | ||
Storage::disk('qiniu') -> put($filename, file_get_contents($request -> file('file') -> path())); | ||
// 返回数据 | ||
$result = [ | ||
'errCode' => '0', | ||
'errMsg' => '', | ||
'succMsg' => '文件上传成功', | ||
'path' => Storage::disk('qiniu') -> getDriver() -> downloadUrl($filename), | ||
]; | ||
} else { | ||
// 没有文件上传或者出错 | ||
$result = [ | ||
'errCode' => '000001', | ||
'errMsg' => $request -> file('file') -> getErrorMessage(), | ||
]; | ||
} | ||
// 返回信息 | ||
return response() -> json($result); | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
40 changes: 40 additions & 0 deletions
40
database/migrations/2020_02_06_143944_create_member_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,40 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateMemberTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('member', function (Blueprint $table) { | ||
$table -> bigIncrements('id'); | ||
$table -> string('username', 20) -> notNull(); | ||
$table -> string('password') -> notNull(); | ||
$table -> enum('gender', [1, 2, 3]) -> notNull() -> default('1'); | ||
$table -> string('mobile', 11); | ||
$table -> string('email', 40); | ||
$table -> string('avatar'); | ||
$table -> timestamps(); | ||
$table -> rememberToken(); | ||
$table -> enum('type', [1, 2]) -> notNull() -> default('1'); | ||
$table -> enum('status', [1, 2]) -> notNull() -> default('2'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('member'); | ||
} | ||
} |
Oops, something went wrong.