PHP code example of ismailnakkar / laravel-listing
1. Go to this page and download the library: Download ismailnakkar/laravel-listing 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/ */
ismailnakkar / laravel-listing example snippets
use App\Enums\OrderStatus;
use App\Models\Order;
use Illuminate\Http\Request;
use Listing\Listing;
final class OrderController
{
public function index(Request $request)
{
$orders = Order::query()
->join('customers', 'customers.id', '=', 'orders.customer_id')
->select('orders.*', 'customers.name as customer_name');
$listing = Listing::for($orders, $request)
->enum('status', OrderStatus::class)
->flag('paid')
->search('q', ['orders.reference', 'customers.email'])
->date('from', 'orders.created_at', '>=')
->date('to', 'orders.created_at', '<=')
->sorts('reference', 'total', 'created_at', customer: 'customer_name')
->defaultSort('-created_at');
return view('orders.index', ['orders' => $listing->paginate(), 'listing' => $listing]);
}
}