CommissionHistoryController.php 966 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Http\Controllers\Seller;
  3. use Illuminate\Http\Request;
  4. use App\Models\CommissionHistory;
  5. use Auth;
  6. class CommissionHistoryController extends Controller
  7. {
  8. public function index(Request $request) {
  9. $seller_id = null;
  10. $date_range = null;
  11. $commission_history = CommissionHistory::where('seller_id', Auth::user()->id)->orderBy('created_at', 'desc');
  12. if ($request->date_range) {
  13. $date_range = $request->date_range;
  14. $date_range1 = explode(" / ", $request->date_range);
  15. $commission_history = $commission_history->where('created_at', '>=', $date_range1[0]);
  16. $commission_history = $commission_history->where('created_at', '<=', $date_range1[1]);
  17. }
  18. $commission_history = $commission_history->paginate(10);
  19. return view('seller.commission_history.index', compact('commission_history', 'seller_id', 'date_range'));
  20. }
  21. }