更改了good_info表,good_tags表,以及相应controller
This commit is contained in:
@@ -9,6 +9,11 @@ DB_DATABASE=homestead
|
||||
DB_USERNAME=homestead
|
||||
DB_PASSWORD=secret
|
||||
|
||||
DB_TEST_HOST=127.0.0.1
|
||||
DB_TEST_DATABASE=homestead
|
||||
DB_TEST_USERNAME=homestead
|
||||
DB_TEST_PASSWORD=secret
|
||||
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GoodTag extends Model
|
||||
{
|
||||
protected $table='good_tags';
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class AdminController extends Controller
|
||||
public function adminIndex(Request $request)
|
||||
{
|
||||
$data = [];
|
||||
$data['goods'] = GoodInfo::where('checked', '0')->orderby('id', 'asc')->get();
|
||||
$data['goods'] = GoodInfo::where('baned', '1')->orderby('id', 'asc')->get();
|
||||
$data['users'] = User::orderby('id', 'asc')->get();
|
||||
$data['cats'] = GoodCat::orderby('cat_name', 'asc')->get();
|
||||
return View::make('admin.index')->with($data);
|
||||
@@ -37,7 +37,7 @@ class AdminController extends Controller
|
||||
public function checkGood(Request $request, $good_id)
|
||||
{
|
||||
$good = GoodInfo::find($good_id);
|
||||
$good->checked = 1;
|
||||
$good->baned = 0;
|
||||
$good->update();
|
||||
return Redirect::to('/admin');
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ class ContentController extends Controller
|
||||
public function Mainpage()
|
||||
{
|
||||
$data = [];
|
||||
$data['stargoods'] = GoodInfo::where('checked', '1')->where('stared', '1')->orderby('id', 'asc')->limit(5)->get();
|
||||
$data['newgoods'] = GoodInfo::where('checked', '1')->orderby('id', 'dsc')->limit(8)->get();
|
||||
$data['stargoods'] = GoodInfo::where('baned', '0')->where('stared', '1')->orderby('id', 'asc')->limit(5)->get();
|
||||
$data['newgoods'] = GoodInfo::where('baned', '0')->orderby('id', 'dsc')->limit(8)->get();
|
||||
$data['cats'] = GoodCat::orderby('cat_index', 'asc')->get();
|
||||
foreach($data['cats'] as $cat){
|
||||
$data['catgoods'][$cat->cat_name] = GoodInfo::where('cat_id', $cat->id)->where('checked', '1')->inRandomOrder()->limit(4)->get();
|
||||
$data['catgoods'][$cat->cat_name] = GoodInfo::where('cat_id', $cat->id)->where('baned', '0')->inRandomOrder()->limit(4)->get();
|
||||
}
|
||||
$data['announces'] = Announcement::orderby('id', 'dsc')->limit(3)->get();
|
||||
return View::make('welcome')->with($data);
|
||||
|
||||
@@ -11,9 +11,11 @@ use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use App\GoodCat;
|
||||
use App\GoodInfo;
|
||||
use App\GoodTag;
|
||||
use App\Transaction;
|
||||
use App\TransactionLog;
|
||||
use App\Messages;
|
||||
use App\Tag;
|
||||
use App\FavList;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Storage;
|
||||
@@ -41,7 +43,7 @@ class GoodController extends Controller
|
||||
$data['goods'] = GoodInfo::where('cat_id', $input['cat_id']);
|
||||
$data['cat_id'] = $input['cat_id'];
|
||||
}
|
||||
$data['goods'] = $data['goods']->orderby('id', 'asc')->where('checked', 1)->paginate(16);
|
||||
$data['goods'] = $data['goods']->orderby('id', 'asc')->where('baned', 0)->paginate(16);
|
||||
if($request->session()->has('user_id'))
|
||||
$data['user_id'] = $request->session()->get('user_id');
|
||||
else
|
||||
@@ -111,7 +113,7 @@ class GoodController extends Controller
|
||||
{
|
||||
$good->status=5;
|
||||
$goodinfo = GoodInfo::find($good->good_id);
|
||||
$goodinfo->counts = $goodinfo->counts-$good->number;
|
||||
$goodinfo->count = $goodinfo->count-$good->number;
|
||||
$goodinfo->save();
|
||||
}
|
||||
$good->save();
|
||||
@@ -122,14 +124,14 @@ class GoodController extends Controller
|
||||
{
|
||||
$input = $request->all();
|
||||
$data = GoodInfo::find($good_id);
|
||||
if($input['counts']<=0||$input['counts']>$data->counts)
|
||||
if($input['count']<=0||$input['count']>$data->count)
|
||||
return Redirect::to('/good/'.$good_id)->withErrors('购买数量不符合规范');
|
||||
$buy = new Transaction;
|
||||
$buy->good_id = $good_id;
|
||||
$buy->buyer_id = $request->session()->get('user_id');
|
||||
$buy->seller_id = $data->user_id;
|
||||
$buy->status = 1;
|
||||
$buy->number = $input['counts'];
|
||||
$buy->number = $input['count'];
|
||||
$buy->save();
|
||||
$buyername = User::find($data->user_id);
|
||||
$goodname = GoodInfo::where('id',$good_id)->first();
|
||||
@@ -155,43 +157,63 @@ class GoodController extends Controller
|
||||
* @return Redirect
|
||||
* @description Add a new good.
|
||||
*/
|
||||
public function showAddGood(AddGoodRequest $request)
|
||||
{
|
||||
$data = [];
|
||||
if(!$request->session()->has('user_id'))
|
||||
return Redirect::back();
|
||||
$data['cats'] = GoodCat::orderby('cat_index', 'asc')->get();
|
||||
//$data['tags'] = Tag::orderby('id', 'asc')->get();
|
||||
return view::make('good.addPage')->with($data);
|
||||
}
|
||||
|
||||
public function addGood(AddGoodRequest $request)
|
||||
{
|
||||
if($request->method() == "GET"){
|
||||
$data = [];
|
||||
if(!$request->session()->has('user_id'))
|
||||
return Redirect::back();
|
||||
$data['cats'] = GoodCat::orderby('cat_index', 'asc')->get();
|
||||
return view::make('good.addPage')->with($data);
|
||||
}else{
|
||||
if(!$request->session()->has('user_id'))
|
||||
return Redirect::back();
|
||||
$this->validate($request, [
|
||||
'good_name' => 'required',
|
||||
'description' => 'required',
|
||||
'pricemin' => 'required',
|
||||
'pricemax' => 'required',
|
||||
'counts' => 'required',
|
||||
]);
|
||||
$input = $request->all();
|
||||
$good = new GoodInfo;
|
||||
$good->good_name = $input['good_name'];
|
||||
$good->cat_id = $input['cat_id'];
|
||||
$good->description = $input['description'];
|
||||
$good->pricemin = $input['pricemin'];
|
||||
$good->pricemax = $input['pricemax'];
|
||||
$good->type = $input['type'];
|
||||
$good->counts = $input['counts'];
|
||||
$good->good_tag = $input['good_tag'];
|
||||
$good->user_id = $request->session()->get('user_id');
|
||||
$good->checked = '1';
|
||||
$good->save();
|
||||
Storage::put(
|
||||
'good/titlepic/'.sha1($good->id),
|
||||
Image::make($request->file('goodTitlePic'))->crop(round($input['crop_width']),round($input['crop_height']),round($input['crop_x']),round($input['crop_y']))->resize(800, 450)->encode('data-url')
|
||||
);
|
||||
return Redirect::to('/good/'.$good->id);
|
||||
}
|
||||
if(!$request->session()->has('user_id'))
|
||||
return Redirect::back();
|
||||
$this->validate($request, [
|
||||
'good_name' => 'required',
|
||||
'description' => 'required',
|
||||
'price' => 'required',
|
||||
'count' => 'required',
|
||||
//'good_tag' => 'required',
|
||||
]);
|
||||
$input = $request->all();
|
||||
$good = new GoodInfo;
|
||||
$good->good_name = $input['good_name'];
|
||||
$good->cat_id = $input['cat_id'];
|
||||
$good->description = $input['description'];
|
||||
$good->price = $input['price'];
|
||||
$good->type = $input['type'];
|
||||
$good->count = $input['count'];
|
||||
$good->user_id = $request->session()->get('user_id');
|
||||
$good->baned = '0';
|
||||
$good->save();
|
||||
|
||||
/*$good_tags = $input['good_tag'];
|
||||
foreach($good_tags as $tag_id)
|
||||
{
|
||||
$tag = new GoodTag;
|
||||
if(!$tag_id)
|
||||
{
|
||||
$otherTag = new Tag;
|
||||
$otherTag->tag_name = $input['other_tag'];
|
||||
$otherTag->save();
|
||||
$tag->tag_id = $otherTag->id;
|
||||
}
|
||||
else if($tag_id)
|
||||
{
|
||||
$tag->tag_id = $tag_id;
|
||||
}
|
||||
$tag->good_id = $good->id;
|
||||
$tag->save();
|
||||
}*/
|
||||
|
||||
Storage::put(
|
||||
'good/titlepic/'.sha1($good->id),
|
||||
Image::make($request->file('goodTitlePic'))->crop(round($input['crop_width']),round($input['crop_height']),round($input['crop_x']),round($input['crop_y']))->resize(800, 450)->encode('data-url')
|
||||
);
|
||||
return Redirect::to('/good/'.$good->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,40 +222,64 @@ class GoodController extends Controller
|
||||
* @return Redirect
|
||||
* @description Edit a specify good.
|
||||
*/
|
||||
public function showEditGood(Request $request, $good_id)
|
||||
{
|
||||
$data = [];
|
||||
$data['cats'] = GoodCat::orderby('cat_index', 'asc')->get();
|
||||
$data['goods'] = GoodInfo::where('id', $good_id)->get();
|
||||
/*$data['tags'] = Tag::orderby('id', 'asc')->get();
|
||||
$collection = GoodTag::where('good_id', $good_id)->pluck('tag_id');
|
||||
$data['this_good_tags'] = $collection->toArray();*/
|
||||
return view::make('good.editPage')->with($data);
|
||||
}
|
||||
|
||||
public function editGood(Request $request, $good_id)
|
||||
{
|
||||
if($request->method() == "GET"){
|
||||
$data = [];
|
||||
$data['cats'] = GoodCat::orderby('cat_index', 'asc')->get();
|
||||
$data['goods'] = GoodInfo::where('id', $good_id)->get();
|
||||
return view::make('good.editPage')->with($data);
|
||||
}else{
|
||||
if(!$request->session()->has('user_id'))
|
||||
return Redirect::back();
|
||||
$this->validate($request, [
|
||||
'good_name' => 'required',
|
||||
'cat_id' => 'required',
|
||||
'description' => 'required',
|
||||
'pricemin' => 'required',
|
||||
'pricemax' => 'required',
|
||||
'type' => 'required',
|
||||
'counts' => 'required',
|
||||
]);
|
||||
$input = $request->all();
|
||||
$good = GoodInfo::find($good_id);
|
||||
if($request->session()->get('user_id')!=$good->user_id && !$request->session()->has('is_admin'))
|
||||
return Redirect::back();
|
||||
$good->good_name=$input['good_name'];
|
||||
$good->cat_id=$input['cat_id'];
|
||||
$good->description=$input['description'];
|
||||
$good->pricemin=$input['pricemin'];
|
||||
$good->pricemax=$input['pricemax'];
|
||||
$good->type=$input['type'];
|
||||
$good->counts=$input['counts'];
|
||||
$good->good_tag=$input['good_tag'];
|
||||
$good->update();
|
||||
return Redirect::to('/good/'.$good_id);
|
||||
}
|
||||
if(!$request->session()->has('user_id'))
|
||||
return Redirect::back();
|
||||
$this->validate($request, [
|
||||
'good_name' => 'required',
|
||||
'cat_id' => 'required',
|
||||
'description' => 'required',
|
||||
'price' => 'required',
|
||||
'type' => 'required',
|
||||
'count' => 'required',
|
||||
//'good_tag' => 'required',
|
||||
]);
|
||||
$input = $request->all();
|
||||
$good = GoodInfo::find($good_id);
|
||||
if($request->session()->get('user_id')!=$good->user_id && !$request->session()->has('is_admin'))
|
||||
return Redirect::back();
|
||||
$good->good_name=$input['good_name'];
|
||||
$good->cat_id=$input['cat_id'];
|
||||
$good->description=$input['description'];
|
||||
$good->price=$input['price'];
|
||||
$good->type=$input['type'];
|
||||
$good->count=$input['count'];
|
||||
$good->update();
|
||||
|
||||
$deleteoldtags = GoodTag::where('good_id', $good_id)->delete();
|
||||
|
||||
/*$good_tags = $input['good_tag'];
|
||||
foreach($good_tags as $tag_id)
|
||||
{
|
||||
$tag = new GoodTag;
|
||||
if(!$tag_id)
|
||||
{
|
||||
$otherTag = new Tag;
|
||||
$otherTag->tag_name = $input['other_tag'];
|
||||
$otherTag->save();
|
||||
$tag->tag_id = $otherTag->id;
|
||||
}
|
||||
else if($tag_id)
|
||||
{
|
||||
$tag->tag_id = $tag_id;
|
||||
}
|
||||
$tag->good_id = $good->id;
|
||||
$tag->save();
|
||||
}*/
|
||||
|
||||
return Redirect::to('/good/'.$good_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,6 +296,8 @@ class GoodController extends Controller
|
||||
if($request->session()->get('user_id') != $good->user_id)
|
||||
return Redirect::back();
|
||||
$good->delete();
|
||||
//$deleteGoodTag = GoodTag::where('good_id', $good_id)->delete();
|
||||
$deleteFavList = Favlist::where('good_id', $good_id)->delete();
|
||||
return Redirect::to('/good');
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ class addGoodRequest extends Request
|
||||
if($this->method()=='GET') return [];
|
||||
return [
|
||||
'good_name'=>'required|between:3,128',
|
||||
'description'=>'max:2048',
|
||||
'pricemin'=>'required|max:2147483647',
|
||||
'pricemax'=>'required|max:2147483647',
|
||||
'counts'=>'required|max:2147483647',
|
||||
'good_tag'=>'max:128',
|
||||
'description'=>'required|max:2048',
|
||||
'price'=>'required|max:9223372036854775807',
|
||||
'count'=>'required|max:2147483647',
|
||||
//'good_tag'=>'required',
|
||||
//'other_tag'=>'max:128',
|
||||
'goodTitlePic'=>'required',
|
||||
];
|
||||
}
|
||||
@@ -39,14 +39,14 @@ class addGoodRequest extends Request
|
||||
return [
|
||||
'good_name.required' => '商品名不能为空!',
|
||||
'good_name.between' => '商品名必须为3=128个字符!',
|
||||
'description.required' => '商品描述不能为空!',
|
||||
'description.max' => '商品描述不能多于2048个字符!',
|
||||
'pricemin.required' => '最低价格不能为空!',
|
||||
'pricemin.max' => '最低价格不能超过2147483647!',
|
||||
'pricemax.required' => '最高价格不能为空!',
|
||||
'pricemax.max' => '最高价格不能超过2147483647!',
|
||||
'counts.required' => '库存数不能为空!',
|
||||
'counts.max' => '库存数不能超过2147483647!',
|
||||
'good_tag.max'=>'TAG不能多于128个字符!',
|
||||
'price.required' => '商品价格不能为空!',
|
||||
'price.max' => '商品价格不能超过9223372036854775807!',
|
||||
'count.required' => '库存数不能为空!',
|
||||
'count.max' => '库存数不能超过2147483647!',
|
||||
//'good_tag.required' => '商品标签不能为空!',
|
||||
//'other_tag.max' => '自定义标签不能多于2048个字符!',
|
||||
'goodTitlePic.required' => '必须为商品上传一张图片!',
|
||||
];
|
||||
}
|
||||
|
||||
+8
-21
@@ -100,19 +100,16 @@ Route::group(['middleware' => ['web']],function () {
|
||||
"uses" => "ContentController@announcementPage",
|
||||
]);
|
||||
|
||||
Route::get('/good', [
|
||||
"uses" => "GoodController@getList",
|
||||
]);
|
||||
Route::get('/good', "GoodController@getList");
|
||||
Route::get('/good/my', "GoodController@myGood")->middleware('auth');
|
||||
|
||||
Route::match(['post', 'get'], '/good/add', [
|
||||
"uses" => "GoodController@addGood",
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
Route::get('/good/add', "GoodController@showAddGood")->middleware('auth');
|
||||
Route::post('/good/add', "GoodController@addGood")->middleware('auth');
|
||||
|
||||
Route::match(['post', 'get'], '/good/my', [
|
||||
"uses" => "GoodController@myGood",
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
Route::get('/good/{good_id}/edit', "GoodController@showEditGood")->middleware('auth');
|
||||
Route::post('/good/{good_id}/edit', "GoodController@editGood")->middleware('auth');
|
||||
|
||||
Route::delete('/good/{good_id}/delete', "GoodController@deleteGood")->middleware('auth');
|
||||
|
||||
Route::match(['post', 'get'], '/good/check', [
|
||||
"uses" => "GoodController@check",
|
||||
@@ -124,16 +121,6 @@ Route::group(['middleware' => ['web']],function () {
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::match(['post', 'get'], '/good/{good_id}/edit', [
|
||||
"uses" => "GoodController@editGood",
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::delete('/good/{good_id}/delete', [
|
||||
"uses" => "GoodController@deleteGood",
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::post('/good/{good_id}/buy', [
|
||||
"uses" => "GoodController@getGood",
|
||||
"middleware" => "auth"
|
||||
|
||||
@@ -17,14 +17,12 @@ class CreateGoodInfoTable extends Migration
|
||||
$table->string('good_name');
|
||||
$table->integer('cat_id');
|
||||
$table->text('description');
|
||||
$table->integer('pricemin');
|
||||
$table->integer('pricemax');
|
||||
$table->integer('type');
|
||||
$table->bigInteger('price');
|
||||
$table->tinyInteger('type');
|
||||
$table->integer('user_id');
|
||||
$table->integer('counts');
|
||||
$table->text('good_tag');
|
||||
$table->integer('checked');
|
||||
$table->integer('stared');
|
||||
$table->integer('count');
|
||||
$table->boolean('baned');
|
||||
$table->boolean('stared');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateGoodTagsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('good_tags', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('good_id');
|
||||
$table->integer('tag_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('good_tags');
|
||||
}
|
||||
}
|
||||
@@ -21,5 +21,14 @@ class UserSeeder extends Seeder
|
||||
'stuid' => '00000000',
|
||||
'havecheckedemail' => 1
|
||||
]);
|
||||
DB::table('users')->insert([
|
||||
'privilege' => 0,
|
||||
'username' => 'test',
|
||||
'password' => Hash::make('test'),
|
||||
'nickname' => 'test',
|
||||
'email' => 'test@test',
|
||||
'stuid' => '00000001',
|
||||
'havecheckedemail' => 1
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,18 +50,10 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="small-2 columns">
|
||||
<label class="right inline">最低价格:</label>
|
||||
<label class="right inline">商品价格:</label>
|
||||
</div>
|
||||
<div class="small-10 columns">
|
||||
<input type="number" name="pricemin" placeholder="最低价格">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="small-2 columns">
|
||||
<label class="right inline">最高价格:</label>
|
||||
</div>
|
||||
<div class="small-10 columns">
|
||||
<input type="number" name="pricemax" placeholder="最高价格">
|
||||
<input type="number" name="price" placeholder="商品价格">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -80,17 +72,23 @@
|
||||
<label class="right inline">商品数量:</label>
|
||||
</div>
|
||||
<div class="small-10 columns">
|
||||
<input type="number" name="counts" placeholder="库存">
|
||||
<input type="number" name="count" placeholder="库存">
|
||||
</div>
|
||||
</div>
|
||||
{{--
|
||||
<div class="row">
|
||||
<div class="small-2 columns">
|
||||
<label class="right inline">商品标签:</label>
|
||||
</div>
|
||||
<div class="small-10 columns">
|
||||
<input type="text" name="good_tag" placeholder="TAG">
|
||||
@foreach($tags as $tag)
|
||||
<label><input type="checkbox" name="good_tag[]" value="{{$tag->id}}">{{$tag->tag_name}}</label>
|
||||
@endforeach
|
||||
<label><input type="checkbox" name="good_tag[]" value="0">自定义
|
||||
<input type="text" name="other_tag" value="" placeholder="自定义标签请在这里输入"></label>
|
||||
</div>
|
||||
</div>
|
||||
--}}
|
||||
<div class="row">
|
||||
<div class="small-4 columns">
|
||||
<label for="goodTitleUpload" class="button right inline">上传封面</label>
|
||||
|
||||
@@ -53,18 +53,10 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="small-2 columns">
|
||||
<label class="right inline">最低价格:</label>
|
||||
<label class="right inline">商品价格:</label>
|
||||
</div>
|
||||
<div class="small-10 columns">
|
||||
<input type="number" name="pricemin" value="{{$good->pricemin}}" placeholder="最低价格">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="small-2 columns">
|
||||
<label class="right inline">最高价格:</label>
|
||||
</div>
|
||||
<div class="small-10 columns">
|
||||
<input type="number" name="pricemax" value="{{$good->pricemax}}" placeholder="最高价格">
|
||||
<input type="number" name="price" value="{{$good->price}}" placeholder="商品价格">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -83,17 +75,27 @@
|
||||
<label class="right inline">商品数量:</label>
|
||||
</div>
|
||||
<div class="small-10 columns">
|
||||
<input type="number" name="counts" value="{{$good->counts}}" placeholder="库存">
|
||||
<input type="number" name="count" value="{{$good->count}}" placeholder="库存">
|
||||
</div>
|
||||
</div>
|
||||
{{--
|
||||
<div class="row">
|
||||
<div class="small-2 columns">
|
||||
<label class="right inline">商品标签:</label>
|
||||
</div>
|
||||
<div class="small-10 columns">
|
||||
<input type="text" name="good_tag" value="{{$good->good_tag}}" placeholder="TAG">
|
||||
@foreach($tags as $tag)
|
||||
@if(in_array($tag->id, $this_good_tags))
|
||||
<label><input type="checkbox" name="good_tag[]" value="{{$tag->id}}" checked="checked">{{$tag->tag_name}}</label>
|
||||
@else
|
||||
<label><input type="checkbox" name="good_tag[]" value="{{$tag->id}}">{{$tag->tag_name}}</label>
|
||||
@endif
|
||||
@endforeach
|
||||
<label><input type="checkbox" name="good_tag[]" value="0">自定义
|
||||
<input type="text" name="other_tag" value="" placeholder="自定义标签请在这里输入"></label>
|
||||
</div>
|
||||
</div>
|
||||
--}}
|
||||
{{-- <div class="row">
|
||||
<div class="small-4 columns">
|
||||
<label for="goodTitleUpload" class="button right inline">上传封面</label>
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
<div class="small-12 medium-6 medium-offset-1 columns">
|
||||
<h1>{{ $good->good_name }}</h1>
|
||||
<div><!-- 放tag 和更多图片缩略图 --></div>
|
||||
<h4 style="color: #cc4b37"><b>¥{{ $good->pricemin }} - ¥{{ $good->pricemax }}</b></h4>
|
||||
<h4 style="color: #cc4b37"><b>¥{{ $good->price }}</b></h4>
|
||||
<div class="row">
|
||||
<div class="small-5 columns">
|
||||
@if(($good->user_id) != Session::get('user_id'))
|
||||
<form action="/good/{{ $good->id }}/buy" method="post">
|
||||
<div class="input-group">
|
||||
<input type="number" name="counts" value="1" class="input-group-field"/>
|
||||
<input type="number" name="count" value="1" class="input-group-field"/>
|
||||
{!! csrf_field() !!}
|
||||
<div class="input-group-button">
|
||||
<input type="submit" class="button" value="购买"/>
|
||||
@@ -51,8 +51,8 @@
|
||||
{!! csrf_field() !!}
|
||||
{!! method_field('DELETE') !!}
|
||||
<input type="submit" class="button" value="删除">
|
||||
</form>
|
||||
@endif
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -65,21 +65,21 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-6 medium-offset-6 columns">
|
||||
@if(isset($inFvlst))
|
||||
@if(isset($inFvlst))
|
||||
<form id="fav">
|
||||
{!! csrf_field() !!}
|
||||
@if(count($inFvlst) == 0)
|
||||
<input id="fav_smt" class="button" type="button" name="submit1" onclick="add_favlist()"
|
||||
value="收藏OvO"/>
|
||||
value="收藏OvO"/>
|
||||
@endif
|
||||
@if(count($inFvlst) != 0)
|
||||
<input id="fav_smt" class="button" type="button" name="submit1" onclick="del_favlist()"
|
||||
value="取消收藏QAQ"/>
|
||||
value="取消收藏QAQ"/>
|
||||
@endif
|
||||
</form>
|
||||
@else
|
||||
<input class="button" type="button" name="submit1" onclick="window.location.href='/login'"
|
||||
value="收藏OvO"/>
|
||||
value="收藏OvO"/>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -26,12 +26,11 @@
|
||||
</div>
|
||||
<div class="card-section">
|
||||
<div class="one-line-text">{{ $good->good_name }}</div>
|
||||
<div style="color: #cc4b37;" class="one-line-text"><b>¥{{ $good->pricemin }} -
|
||||
¥{{ $good->pricemax }}</b></div>
|
||||
@if($good->counts==0)
|
||||
<div style="color: #cc4b37;" class="one-line-text"><b>¥{{ $good->price }}</b></div>
|
||||
@if($good->count==0)
|
||||
<div style="color: #ffae00;" class="one-line-text">无库存QAQ</div>
|
||||
@else
|
||||
<div class="one-line-text">库存:{{ $good->counts }}</div>
|
||||
<div class="one-line-text">库存:{{ $good->count }}</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
<tr>
|
||||
<td>#</td>
|
||||
<td>商品名称</td>
|
||||
<td>最低价格</td>
|
||||
<td>最高价格</td>
|
||||
<td>商品价格</td>
|
||||
<td>修改信息</td>
|
||||
<td>删除商品</td>
|
||||
</tr>
|
||||
@@ -34,8 +33,7 @@
|
||||
<tr id="good{{ $good->id }}">
|
||||
<td>{{ $good->id }}</td>
|
||||
<td><a href="/good/{{$good->id}}" onMouseOver="toolTip('<img src=/good/{{ sha1($good->id) }}/titlepic>')" onMouseOut="toolTip()">{{ $good->good_name }}</a></td>
|
||||
<td>{{ $good->pricemin }}</td>
|
||||
<td>{{ $good->pricemax }}</td>
|
||||
<td>{{ $good->price }}</td>
|
||||
<td>
|
||||
<form action="/good/{{ $good->id }}/edit">
|
||||
<input type="submit" class="button" value="修改" style="margin: 0;">
|
||||
|
||||
@@ -14,22 +14,20 @@
|
||||
<tr>
|
||||
<td>#</td>
|
||||
<td>商品名称</td>
|
||||
<td>最低价格</td>
|
||||
<td>最高价格</td>
|
||||
<td>商品价格</td>
|
||||
<td>选择</td>
|
||||
</tr>
|
||||
@foreach($goods as $good)
|
||||
<tr>
|
||||
<td>{{ $good->good_id }}</td>
|
||||
<td><a href="/good/{{$good->good_id}}">{{ $good_info[$good->good_id]->good_name }}</a></td>
|
||||
<td>{{ $good_info[$good->good_id]->pricemin }}</td>
|
||||
<td>{{ $good_info[$good->good_id]->pricemax }}</td>
|
||||
<td>{{ $good_info[$good->good_id]->price }}</td>
|
||||
<td><input type="checkBox" name="del_goods[]" value="0" id="box{{ $good->good_id }}"
|
||||
onclick="{setValue({{ $good->good_id }})}"/></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
<input type="submit" name="submit1"class="button" value="删除选中商品"/>
|
||||
<input type="submit" name="submit1" class="button" value="删除选中商品"/>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
@@ -38,15 +38,13 @@
|
||||
<tr>
|
||||
<td>#</td>
|
||||
<td>商品名称</td>
|
||||
<td>最低价格</td>
|
||||
<td>最高价格</td>
|
||||
<td>商品价格</td>
|
||||
</tr>
|
||||
@foreach($goods as $good)
|
||||
<tr class="list">
|
||||
<td>{{ $good->good_id }}</td>
|
||||
<td class="name"><a href="/good/{{$good->good_id}}" onMouseOver="toolTip('<img src=/good/{{ sha1($good->good_id) }}/titlepic>')" onMouseOut="toolTip()">{{ $good_info[$good->good_id]->good_name }}</a><img src="/good/{{ sha1($good->good_id) }}/titlepic" class="pic" /></td>
|
||||
<td>{{ $good_info[$good->good_id]->pricemin }}</td>
|
||||
<td>{{ $good_info[$good->good_id]->pricemax }}</td>
|
||||
<td>{{ $good_info[$good->good_id]->price }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\BrowserKitTestCase;
|
||||
|
||||
class GoodTest extends BrowserKitTestCase
|
||||
{
|
||||
public function testAddGood()
|
||||
{
|
||||
//login
|
||||
$this->visit('/login')
|
||||
->type('test', 'username')
|
||||
->type('test', 'password')
|
||||
->press('登录');
|
||||
|
||||
//test add good
|
||||
$this->visit('/good/add')
|
||||
->see('添加')
|
||||
->press('添加')
|
||||
->see('商品名不能为空')
|
||||
->type('算法竞赛入门经典', 'good_name')
|
||||
->press('添加')
|
||||
->see('商品描述不能为空')
|
||||
->type('算法竞赛入门经典', 'good_name')
|
||||
->select('1', 'cat_id')
|
||||
->type('刘汝佳', 'description')
|
||||
->press('添加')
|
||||
->see('商品价格不能为空')
|
||||
->type('算法竞赛入门经典', 'good_name')
|
||||
->select('1', 'cat_id')
|
||||
->type('刘汝佳', 'description')
|
||||
->type('65', 'price')
|
||||
->press('添加')
|
||||
->see('库存数不能为空')
|
||||
->type('算法竞赛入门经典', 'good_name')
|
||||
->select('1', 'cat_id')
|
||||
->type('刘汝佳', 'description')
|
||||
->type('65', 'price')
|
||||
->select('1', 'type')
|
||||
->type('10', 'count')
|
||||
->press('添加')
|
||||
->see('必须为商品上传一张图片');
|
||||
/*->type('算法竞赛入门经典', 'good_name')
|
||||
->select('1', 'cat_id')
|
||||
->type('刘汝佳', 'description')
|
||||
->type('65', 'price')
|
||||
->select('1', 'type')
|
||||
->type('10', 'count')
|
||||
->attach(__DIR__.'/../storage/good.jpg', 'goodTitlePic') //测试时总会提示validation.uploaded
|
||||
->press('添加')
|
||||
->see('修改');*/
|
||||
}
|
||||
|
||||
/*public function testEditGood()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testDeleteGood()
|
||||
{
|
||||
|
||||
}*/
|
||||
}
|
||||
Reference in New Issue
Block a user