partial update opnames and detail table
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\WarehouseManagement;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Menu;
|
||||
use App\Models\Opname;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class OpnamesController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
$menu = Menu::where('link','opnames.index')->first();
|
||||
if($request->ajax()){
|
||||
$data = Opname::with('user','dealer');
|
||||
return DataTables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('user_name', function ($row){
|
||||
return $row->user ? $row->user->name : '-';
|
||||
})
|
||||
->addColumn('dealer_name', function ($row){
|
||||
return $row->dealer ? $row->dealer->name : '-';
|
||||
})
|
||||
->addColumn('action', function ($row) use ($menu) {
|
||||
$btn = '<div class="d-flex">';
|
||||
|
||||
$btn .= '<button class="btn btn-sm btn-secondary btn-product-stock-dealers">Detail</button>';
|
||||
|
||||
$btn .= '</div>';
|
||||
|
||||
return $btn;
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
return view('warehouse_management.opnames.index');
|
||||
}
|
||||
|
||||
public function create(){
|
||||
return view('warehouse_management.opnames.create');
|
||||
}
|
||||
|
||||
public function store(Request $request){
|
||||
try{
|
||||
|
||||
}catch(\Exception $ex){
|
||||
Log::error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,16 +32,10 @@ class ProductsController extends Controller
|
||||
return $row->category ? $row->category->name : '-';
|
||||
})
|
||||
->addColumn('total_stock', function ($row){
|
||||
return $row->dealers->sum(function($dealer){
|
||||
return $dealer->pivot->quantity ?? 0;
|
||||
});
|
||||
return 0;
|
||||
})
|
||||
->addColumn('action', function ($row) use ($menu) {
|
||||
$btn = '<div class="d-flex">';
|
||||
|
||||
// if (Auth::user()->can('delete', $menu)) {
|
||||
// $btn .= '<button style="margin-right: 8px;" class="btn btn-danger btn-sm btn-destroy-product" data-action="' . route('products.destroy', $row->id) . '" data-id="' . $row->id . '">Hapus</button>';
|
||||
// }
|
||||
|
||||
if (Auth::user()->can('update', $menu)) {
|
||||
$btn .= '<a href="' . route('products.edit', $row->id) . '" class="btn btn-warning btn-sm" style="margin-right: 8px;">Edit</a>';
|
||||
|
||||
Reference in New Issue
Block a user