i have three table i wanted to know how to export data using find_in_set from my database table also i wanted to know how can i export data from other tables in same excel sheet by using seconday id
here is by controller
<?php
namespace App\Http\Controllers;
use DB;
use Excel;
use App\ProductsExport;
use Illuminate\Http\Request;
class ImportExportController extends Controller
{
public function importExportView()
{
return view('dashboard.excel.export_excel');
}
public function export(Request $request)
{
return Excel::download(new ProductsExport($request->primaryCategory), 'products.xlsx');
}
}
and here is my model for exporting data
<?php
namespace App;
use App\ProductAdd;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\Exportable;
use DB;
class ProductsExport implements ShouldAutoSize, FromView
{
use Exportable;
public $catId;
public function __construct($catId)
{
$this->catId = $catId;
}
public function view(): View
{
return view('dashboard.excel.export', [
'users' => ProductAdd::whereRaw("FIND_IN_SET(?, primaryCategory) > 0", explode(',', $this->catId))->get();
]);
}
on view page ist givind blank. also please help me for importing data on three tables using same process
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire