File: /var/www/vhost/disk-apps/demo.sports-crowd.com/app/Http/Controllers/StockController.php
<?php
namespace App\Http\Controllers;
use Excel;
use Datatables;
use App\Product;
use App\Http\Controllers\Exports\ReportInventory;
class StockController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($storeType = 'main')
{
return view('stocks.stocks')->with('storeType', $storeType);
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function getStock($storeType = 'main')
{
$stock = Product::with('productAttributes', 'brand')->where('products.store_type', $storeType);
return DataTables::of($stock)
->make(true);
}
public function report($storeType = 'main')
{
return Excel::download(new ReportInventory($storeType), 'stock.xlsx');
}
}