Merge commit 'bda62ae'
Conflicts: app/Http/routes.php resources/views/good/goodInfo.blade.php resources/views/good/goodList.blade.php
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FavList extends Model
|
||||
{
|
||||
protected $table = 'favlist';
|
||||
}
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\UserInfo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\GoodCat;
|
||||
use App\GoodInfo;
|
||||
use App\Transaction;
|
||||
use App\TransactionLog;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Storage;
|
||||
|
||||
@@ -35,6 +38,18 @@ class GoodController extends Controller
|
||||
return view::make('good.goodList')->with($data);
|
||||
}
|
||||
|
||||
public function check(Request $request)
|
||||
{
|
||||
$data = [];
|
||||
$user_id = $request->session()->get('user_id');
|
||||
$data['goods'] = Transaction::where('seller_id',$user_id)->where('status',1)->get();
|
||||
$data['sells'] = Transaction::where('seller_id',$user_id)->where('status',2)->get();
|
||||
$data['mysells'] = Transaction::where('seller_id',$user_id)->where('status',4)->get();
|
||||
$data['users'] = Transaction::where('buyer_id',$user_id)->where('status',3)->get();
|
||||
$data['transactions'] = Transaction::where('buyer_id',$user_id)->where('status',2)->get();
|
||||
return view::make('good.goodCheck')->with($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @function GoodController@getInfo
|
||||
* @input Request $request, $good_id
|
||||
@@ -44,7 +59,9 @@ class GoodController extends Controller
|
||||
public function getInfo(Request $request, $good_id)
|
||||
{
|
||||
$data = [];
|
||||
$data['goods'] = GoodInfo::where('id', $good_id)->get();
|
||||
$data['goods'] = GoodInfo::where('id', $good_id)->first();
|
||||
$data['users'] = UserInfo::where('id',$data['goods']->user_id)->first();
|
||||
$data['sells'] = Transaction::where('good_id',$good_id)->first();
|
||||
if($request->session()->has('user_id'))
|
||||
$data['user_id'] = $request->session()->get('user_id');
|
||||
else
|
||||
@@ -57,6 +74,43 @@ class GoodController extends Controller
|
||||
return view::make('good.goodInfo')->with($data);
|
||||
}
|
||||
|
||||
public function allow(Request $request, $id)
|
||||
{
|
||||
$data = [];
|
||||
$user_id = $request->session()->get('user_id');
|
||||
$data['buyers'] = Transaction::where('id',$id)->first();
|
||||
$good = Transaction::find($id);
|
||||
if($good->status==1)
|
||||
$good->status = 2;
|
||||
else if($good->status==2&&$user_id==$good->seller_id)
|
||||
$good->status==3;
|
||||
else if($good->status==2&&user_id==$good->buyer_id)
|
||||
$good->status==4;
|
||||
else if($good->status==4||$good->status==3)
|
||||
$good->status=5;
|
||||
$good->save();
|
||||
return Redirect::to('/good');
|
||||
}
|
||||
|
||||
public function getGood(Request $request, $good_id)
|
||||
{
|
||||
$data = GoodInfo::find($good_id);
|
||||
$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->save();
|
||||
return Redirect::to('/good');
|
||||
}
|
||||
|
||||
public function mygood(Request $request)
|
||||
{
|
||||
$data = [];
|
||||
$user_id = $request->session()->get('user_id');
|
||||
$data['mygoods'] = GoodInfo::where('user_id',$user_id)->get();
|
||||
return view::make('good.mygood')->with($data);
|
||||
}
|
||||
/**
|
||||
* @function GoodController@addGood
|
||||
* @input Request $request
|
||||
@@ -186,4 +240,23 @@ class GoodController extends Controller
|
||||
$data['is_admin'] = NULL;
|
||||
return view::make('good.goodList')->with($data);
|
||||
}
|
||||
|
||||
/*
|
||||
* @funtion addFavlist
|
||||
* @input $request (use query)
|
||||
*
|
||||
* @return Redirect or View
|
||||
* @description Process the query and add to certain
|
||||
* user's favorite list
|
||||
*/
|
||||
public function addFavlist(Request $request, $good_id)
|
||||
{
|
||||
if(!$request->session()->has('user_id'))
|
||||
return Redirect::back();
|
||||
$fav = new FavList;
|
||||
$fav->user_id = $request->session()->get('user_id');
|
||||
$fav->good_id = $good_id;
|
||||
$fav->save();
|
||||
return Redirect::to('/good');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class UserController extends Controller
|
||||
return redirect()->back()->withInput()->withErrors('用户名已存在!');
|
||||
echo "用户名已存在!";
|
||||
}
|
||||
$user=new User;
|
||||
$user = new User;
|
||||
$user->username = $input['username'];
|
||||
$user->password = sha1($input['password']);
|
||||
$user->email = "#".$input['email'];
|
||||
|
||||
@@ -41,6 +41,21 @@ Route::group(['middleware' => ['web']],function () {
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::match(['post', 'get'], '/good/mygood', [
|
||||
"uses" => "GoodController@mygood",
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::match(['post', 'get'], '/good/check', [
|
||||
"uses" => "GoodController@check",
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::match(['post', 'get'], '/good/end', [
|
||||
"uses" => "GoodController@end",
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::match(['post', 'get'], '/good/{good_id}/edit', [
|
||||
"uses" => "GoodController@editGood",
|
||||
"middleware" => "auth"
|
||||
@@ -51,6 +66,16 @@ Route::group(['middleware' => ['web']],function () {
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::post('/good/{good_id}/buy', [
|
||||
"uses" => "GoodController@getGood",
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::post('/good/{good_id}/{id}', [
|
||||
"uses" => "GoodController@allow",
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::get('/good/quick_access', [
|
||||
"uses" => "GoodController@quickAccess",
|
||||
"middleware" => "auth"
|
||||
@@ -71,6 +96,11 @@ Route::group(['middleware' => ['web']],function () {
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::get('/good/{good_id}/add_favlist', [
|
||||
"uses" => "GoodController@addFavlist",
|
||||
"middleware" => "auth"
|
||||
]);
|
||||
|
||||
Route::get('/good/{good_id}/check', [
|
||||
"uses" => "AdminController@checkGood",
|
||||
"middleware" => "admin"
|
||||
|
||||
+5021
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateFavlistTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('favlist', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id');
|
||||
$table->integer('good_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('favlist');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
@foreach($goods as $good)
|
||||
<a href="/good/{{ $good->good_id }}">{{ $good->good_id }}</a>
|
||||
<form action='/good/{{$good->good_id}}/{{$good->id}}' method='POST'>
|
||||
{!! csrf_field() !!}
|
||||
<input type="submit" name="sumbit3" value="确认出售" >
|
||||
</form>
|
||||
<br/>
|
||||
@endforeach
|
||||
@foreach($sells as $sell)
|
||||
<a href="/good/{{ $sell->good_id }}">{{ $sell->good_id }}</a>
|
||||
<form action='/good/{{$sell->good_id}}/{{$sell->id}}' method='POST'>
|
||||
{!! csrf_field() !!}
|
||||
<input type="submit" name="sumbit4" value="完成交易" >
|
||||
</form>
|
||||
<br/>
|
||||
@endforeach
|
||||
@foreach($mysells as $mysell)
|
||||
<a href="/good/{{ $mysell->good_id }}">{{ $mysell->good_id }}</a>
|
||||
<form action='/good/{{$mysell->good_id}}/{{$mysell->id}}' method='POST'>
|
||||
{!! csrf_field() !!}
|
||||
<input type="submit" name="sumbit7" value="完成交易" >
|
||||
</form>
|
||||
<br/>
|
||||
@endforeach
|
||||
@foreach($transactions as $transaction)
|
||||
<a href="/good/{{ $transaction->good_id }}">{{ $transaction->good_id }}</a>
|
||||
<form action='/good/{{$transaction->good_id}}/{{$transaction->id}}' method='POST'>
|
||||
{!! csrf_field() !!}
|
||||
<input type="submit" name="sumbit5" value="完成交易" >
|
||||
</form>
|
||||
<br/>
|
||||
@endforeach
|
||||
@foreach($users as $user)
|
||||
<a href="/good/{{ $user->good_id }}">{{ $user->good_id }}</a>
|
||||
<form action='/good/{{$user->good_id}}/{{$user->id}}' method='POST'>
|
||||
{!! csrf_field() !!}
|
||||
<input type="submit" name="sumbit6" value="完成交易" >
|
||||
</form>
|
||||
<br/>
|
||||
@endforeach
|
||||
@@ -11,10 +11,22 @@
|
||||
<form action='/good/{{$good->id}}/delete' method='POST'>
|
||||
{!! csrf_field() !!}
|
||||
{{ method_field('DELETE') }}
|
||||
<input type="submit" value="Delete"/>
|
||||
<input type="submit" name="submit1" value="Delete">
|
||||
</form>
|
||||
<form action = '/good/{{ $good->id }}/add_favlist' method = 'POST'>
|
||||
{!! csrf_field() !!}
|
||||
<input type = "submit" value = "✪ω✪"/>
|
||||
</form>
|
||||
@endif
|
||||
@endforeach
|
||||
@if($user_id!=$goods->user_id)
|
||||
<form action='/good/{{$goods->id}}/buy' method='POST'>
|
||||
{!! csrf_field() !!}
|
||||
<input type="submit" name="sumbit2" value="Buy" >
|
||||
</form>
|
||||
@endif
|
||||
@if($user_id == $sells->buyer_id&&$sells->status==2)
|
||||
{{$users->tel_num}}<br/>
|
||||
@endif
|
||||
<a href='/good'>GoodList</a>
|
||||
</div>
|
||||
@include('layout.footer')
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
<br/>
|
||||
@if($user_id != NULL)
|
||||
<a href='/good/add'>Add</a>
|
||||
<a href='/good/mygood'>my good</a>
|
||||
@endif
|
||||
</div>
|
||||
@include('layout.footer')
|
||||
@include('includes.foot')
|
||||
@include('includes.foot')
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<ul>
|
||||
@foreach($mygoods as $mygood)
|
||||
<div class="cat{{ $mygood->cat_id }}"><a href="/good/{{ $mygood->id }}">{{ $mygood->good_name }}</a></div>
|
||||
@endforeach
|
||||
</ul>
|
||||
Reference in New Issue
Block a user