samedi 9 février 2019

How to get weekly and monthly report in laravel?

I want to get weekly reports and monthly reports on my application, but I don't know where to start.

I use Laravel 5.7, I have tried a number of experiments that I have searched for on the internet, but they don't work.

My table
Schema::create('surat_keluars', function (Blueprint $table) {
            $table->increments('id');
            $table->string('nomor_surat')->unique();
            $table->integer('instansi_id')->unsigned();
            $table->string('perihal');
            $table->date('tanggal_surat');
            $table->date('tanggal_kirim');
            $table->string('lampiran');
            $table->timestamps();
            $table->foreign('instansi_id')->references('id')->on('instansis');
        });

My model
class SuratKeluar extends Model
{
protected $fillable = [
        'nomor_surat', 'instansi_id', 'perihal', 'tanggal_surat', 'tanggal_kirim', 'lampiran'
];


public function instansi()
{
        return $this->belongsTo('App\Instansi');
}
}

And and I have tried using this controller, but I don't know how to display it in view blade
 public function day()
{

   $data= SuratKeluar::select('id', 'nomor_surat', 'created_at')
        ->get()
        ->groupBy(function($val) {
        return Carbon::parse($val->created_at)->format('m');
 });
        
}

I hope someone can help me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire