Commit 2b3ac039 by Angel MAS

seguimiento de ordenes

parent b0d9029a
......@@ -14,6 +14,7 @@ use Onestartup\Shop\Model\ProductShopInfo as ProductInfo;
use Onestartup\Shop\DataTables\ClientDataTable;
use Onestartup\Shop\DataTables\OrderDataTable;
use Onestartup\Shop\Model\SaleShop as Sale;
use Onestartup\Shop\Model\OrderTracking as Tracking;
class AdminProductController extends Controller
......@@ -312,4 +313,17 @@ class AdminProductController extends Controller
return redirect()->back()->with('message_success', 'Estatus actualizado correctamente');
}
public function trackingStore(Request $request, $id)
{
$sale = Sale::find($id);
$comment = new Tracking($request->all());
$comment->user_id = \Auth::user()->id;
$sale->tracking_sales()->save($comment);
return redirect()
->back()
->with('message_success', 'Información agregada correctamente');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateOrderTrackingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('order_trackings', function (Blueprint $table) {
$table->increments('id');
$table->string('type', 355);
$table->string('detail', 555);
$table->integer('sale_id')->unsigned();
$table->foreign('sale_id')->references('id')->on('sale_shops');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('order_trackings');
}
}
<?php
namespace Onestartup\Shop\Model;
use Illuminate\Database\Eloquent\Model;
class OrderTracking extends Model
{
protected $table = 'order_trackings';
protected $fillable = [
'type',
'detail',
'sale_id',
'user_id'
];
public function user()
{
return $this->belongsTo('App\User', 'user_id');
}
public function sale()
{
return $this->belongsTo('Onestartup\Shop\Model\SaleShop', 'sale_id');
}
}
......@@ -19,4 +19,9 @@ class SaleShop extends Model
{
return $this->hasMany('Onestartup\Shop\Model\DetailShop', 'sale_id');
}
public function tracking_sales()
{
return $this->hasMany('Onestartup\Shop\Model\OrderTracking', 'sale_id');
}
}
......@@ -61,6 +61,10 @@ Route::group(['middleware' => ['web', 'auth', 'is_admin']], function(){
'Onestartup\Shop\Controller\AdminProductController@updateStatusSale')
->name('admin-shop-client.statussale');
Route::post('admin/shop/client/sale/{id}/tracking',
'Onestartup\Shop\Controller\AdminProductController@trackingStore')
->name('admin-shop-client.trackingStore');
});
......
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