Postingan lainnya
Eksport PDF berdasarkan dua tanggal di Laravel 8
Controller
public function periodeee (Request $request)
  {
    $tgl_mulai = date('Y-m-d',strtotime($request->tgl_mulai));
    $tgl_selesai = date('Y-m-d',strtotime($request->tgl_selesai));
    $bm = BMarketing::whereBetween('tanggal',[$tgl_mulai,$tgl_selesai])->get();
    $ak = akun::all();
    return view('bmarketing',compact('bm','ak'));
  }
Models
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class BMarketing extends Model
{
  // use HasFactory;
  protected $table = "bmarketings";
  protected $guarded = [
  ];
  public function akun()
  {
    return $this->hasMany(Akun::class,'kode_akun', 'kode_akun');
  }
}
View
<div class="container mt-1">
    @if (auth()->user()->role=="Admin")
    <a href="/tambahdatabm" class="btn btn-primary mb-3 mt-3">Tambah Data</a>
    @endif
    <a href="/exporttpdf" target="_blank" class="btn btn-info mb-3 mt-3">Export PDF </a>
    <a href="/cetakform" class="btn btn-info mb-3 mt-3">Export PDF Per Tgl </a>
    <a href="/exporttexcel" target="_blank" class="btn btn-info mb-3 mt-3">Export Excel </a>
    <a href="/bmarketing" class="btn btn-info mb-3 mt-3">Refresh</a>
    <div class="container row col-lg-6 md-4 ms-auto">
      <form action="/periodeee" method="get" class="d-flex">
        <input type="date" name="tgl_mulai" id="tgl_mulai" class="form-control datpicker mb-2 ">
        <input type="date" name="tgl_selesai" id="tgl_selesai" class="form-control datpicker ms-2 mb-2 ">
        <button type="submit" name="filter_tgl" class="btn btn-success datpicker ms-2 mb-2 ">Filter</button>
      </form>
    </div>
</div>
Route
//Filter Tanggal
  Route::get('/periodeee', [BmarketingController::class, 'periodeee'])->name('periodeee')->middleware('auth');
Tanggapan
Pertanyaan kamu tidak jelas, coba dijelaskan lebih baik
- rapikan kode kamu, coba lihat di atas
- Apa pertanyaannya
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban