PHP code example of arispati / src-macro

1. Go to this page and download the library: Download arispati/src-macro library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arispati / src-macro example snippets


	$app->register(Arispati\SrcMacro\ServiceProvider::class);
	

	onSearch(
		array $columns = [],
		// default query param dari front-end
		string $searchParam = 'search'
	)
	

	$query = DB::table('namaTabel')->onSearch([
		'namaTabel.id', 'nama'
	])
	

	onSort(
		array $columns = [],
		// default query param dari front-end
		string $sortParam = 'sort',
		string $sortTypeParam = 'sort_type'
	)
	

	$query = DB::table('namaTabel')->onSort([
		'id',
		// dari query param => kolom pada query
		'nama' => 'namaTabel.nama'
	])
	

	onFilter(array $columns) // kolom harus ditetapkan
	

	$query = DB::table('namaTabel')->onFilter([
		'id',
		// dari query param => kolom pada query
		'nama' => 'namaTabel.nama'
	])
	

	onBetween(
		string $column = 'created_at',
		// default query param dari front-end
		string $startDateParam = 'start_date',
		string $endDateParam = 'end_date'
	)
	

	// jika parameter sesuai default
	$query = DB::table('namaTabel')->onBetween()
	

	downloadExcel(
		// $class harus menggunakan trait Maatwebsite\Excel\Concerns\Exportable
		object $class,
		// nama file termasuk ekstensinya
		string $namaFile
	)
	

	return response()->downloadExcel(new DataToExport(), 'namaFile.xls');