Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review code #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions app/Http/Controllers/LaporanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace App\Http\Controllers;

use App\ManagePengeluaran;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class LaporanController extends Controller
{
public function index()
{
return view('Laporan.index');
return view('laporan.index');
}

public function cari(Request $request)
Expand All @@ -30,15 +31,9 @@ public function cari(Request $request)
// ->join('pemasukan as s', 'p.sumber_pemasukan', '=', 's.id')
// ->whereBetween('tanggal', [$dari, $sampai])->sum('nominal');

$pengeluaran = ManagePengeluaran::whereBetween('tanggal', [$dari, $sampai])->get();
$total_pengeluaran = ManagePengeluaran::whereBetween('tanggal', [$dari, $sampai])->sum('nominal');

$pengeluaran = DB::table('manage_pengeluaran')
->whereBetween('tanggal', [$dari, $sampai])->get();

$total_pengeluaran = DB::table('manage_pengeluaran')
->whereBetween('tanggal', [$dari, $sampai])->sum('nominal');

return view('Laporan.index', compact('pengeluaran','total_pengeluaran'));
return view('laporan.index', compact('pengeluaran', 'total_pengeluaran'));
}


}
51 changes: 27 additions & 24 deletions app/Http/Controllers/ManagePemasukanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@

namespace App\Http\Controllers;

use Faker\Provider\Uuid;
use App\ManagePemasukan;
use App\Pemasukan;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Webpatser\Uuid\Uuid;
use Yajra\Datatables\Facades\Datatables;

class ManagePemasukanController extends Controller
{
public function index()
{
$data = \DB::table('manage_pemasukan as a')->join('pemasukan as b', 'a.sumber_pemasukan', '=', 'b.id')->get();
return view('Pemasukan.index', compact('data'));
$data = DB::table('manage_pemasukan as a')->join('pemasukan as b', 'a.sumber_pemasukan', '=', 'b.id')->get();
return view('pemasukan.index', compact('data'));
}

public function add()
{
$sumbers = DB::table('pemasukan')->get();
return view('Pemasukan.add', compact('sumbers'));
$sumbers = Pemasukan::get();
return view('pemasukan.add', compact('sumbers'));
}

public function store(Request $request)
Expand All @@ -30,8 +32,8 @@ public function store(Request $request)
'keterangan' => 'required',
]);

\DB::table('manage_pemasukan')->insert([
'pemasukan_id' => \Uuid::generate(4),
ManagePemasukan::insert([
'pemasukan_id' => Uuid::generate(4),
'sumber_pemasukan' => $request->sumber,
'nominal' => $request->nominal,
'tanggal' => date('Y-m-d', strtotime($request->tanggal)),
Expand All @@ -43,9 +45,9 @@ public function store(Request $request)

public function edit($id)
{
$sumbers = DB::table('pemasukan')->get();
$data = DB::table('manage_pemasukan')->where('pemasukan_id', $id)->first();
return view('Pemasukan.edit', compact('data', 'sumbers'));
$sumbers = Pemasukan::get();
$data = ManagePemasukan::where('pemasukan_id', $id)->first();
return view('pemasukan.edit', compact('data', 'sumbers'));
}

public function update(Request $request, $id)
Expand All @@ -57,7 +59,7 @@ public function update(Request $request, $id)
'keterangan' => 'required',
]);

\DB::table('manage_pemasukan')->where('pemasukan_id', $id)->update([
ManagePemasukan::where('pemasukan_id', $id)->update([
'sumber_pemasukan' => $request->sumber,
'nominal' => $request->nominal,
'tanggal' => date('Y-m-d', strtotime($request->tanggal)),
Expand All @@ -69,37 +71,38 @@ public function update(Request $request, $id)

public function delete($id)
{
DB::table('manage_pemasukan')->where('pemasukan_id', $id)->delete();
return redirect(route('manage.pemasukan'));
ManagePemasukan::where('pemasukan_id', $id)->delete();
return redirect(route('manage.pemasukan'));
}

public function yajra(Request $request)
{
DB::statement(DB::raw('set @rownum=0'));
$pemasukan = \DB::table('manage_pemasukan as a')->join('pemasukan as b', 'a.sumber_pemasukan', '=', 'b.id')->select([
$pemasukan = DB::table('manage_pemasukan as a')->join('pemasukan as b', 'a.sumber_pemasukan', '=', 'b.id')->select([
DB::raw('@rownum := @rownum + 1 AS rownum'),
'a.pemasukan_id',
'a.sumber_pemasukan',
'b.nama',
'a.nominal',
'a.tanggal',
'a.keterangan']);
'a.keterangan'
]);
$datatables = Datatables::of($pemasukan)
->addColumn('action', function ($ps) {
$url_edit = route('pemasukan.edit', $ps->pemasukan_id);
$url_delete = route('pemasukan.delete', $ps->pemasukan_id);
return '<a href="' . $url_edit . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>
<a href="' . $url_delete . '" class="btn btn-xs btn-danger"><i class="glyphicon glyphicon-delete"></i> Hapus</a>';
})->editColumn('nominal', function ($ps) {
$nominal = $ps->nominal;
$nominal = 'Rp ' . number_format($nominal, 0);
$nominal = str_replace(',', '.', $nominal);
return $nominal;
})->editColumn('tanggal', function ($ps) {
$tanggal = $ps->tanggal;
$tanggal = date('d M Y', strtotime($tanggal));
return $tanggal;
});
$nominal = $ps->nominal;
$nominal = 'Rp ' . number_format($nominal, 0);
$nominal = str_replace(',', '.', $nominal);
return $nominal;
})->editColumn('tanggal', function ($ps) {
$tanggal = $ps->tanggal;
$tanggal = date('d M Y', strtotime($tanggal));
return $tanggal;
});

if ($keyword = $request->get('search')['value']) {
$datatables->filterColumn('rownum', 'whereRaw', '@rownum + 1 like ?', ["%{$keyword}%"]);
Expand Down
24 changes: 11 additions & 13 deletions app/Http/Controllers/ManagePengeluaranController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

namespace App\Http\Controllers;

use App\ManagePengeluaran;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Uuid;
use Webpatser\Uuid\Uuid;

class ManagePengeluaranController extends Controller
{
public function index()
{
$data = DB::table('manage_pengeluaran')->get();
return view('Pengeluaran.index', compact('data'));
$data = ManagePengeluaran::all();
return view('pengeluaran.index', compact('data'));
}

public function add()
{
return view('Pengeluaran.add');
return view('pengeluaran.add');
}

public function store(Request $request)
Expand All @@ -27,8 +27,8 @@ public function store(Request $request)
'keterangan' => 'required',
]);

DB::table('manage_pengeluaran')->insert([
'pengeluaran_id' => \Uuid::generate(4),
ManagePengeluaran::insert([
'pengeluaran_id' => Uuid::generate(4),
'nominal' => $request->nominal,
'tanggal' => date('Y-m-d', strtotime($request->tanggal)),
'keterangan' => $request->keterangan,
Expand All @@ -39,32 +39,30 @@ public function store(Request $request)

public function edit($id)
{
$data = DB::table('manage_pengeluaran')->where('pengeluaran_id', $id)->first();
return view('Pengeluaran.edit', compact('data'));
$data = ManagePengeluaran::where('pengeluaran_id', $id)->first();
return view('pengeluaran.edit', compact('data'));
}

public function update(Request $request, $id)
{

$this->validate($request, [
'nominal' => 'required',
'tanggal' => 'required',
'keterangan' => 'required',
]);

DB::table('manage_pengeluaran')->where('pengeluaran_id', $id)->update([
ManagePengeluaran::where('pengeluaran_id', $id)->update([
'nominal' => $request->nominal,
'tanggal' => date('Y-m-d', strtotime($request->tanggal)),
'keterangan' => $request->keterangan,
]);

return redirect(route('pengeluaran.index'));

}

public function delete($id)
{
DB::table('manage_pengeluaran')->where('pengeluaran_id', $id)->delete();
ManagePengeluaran::where('pengeluaran_id', $id)->delete();
return redirect(route('pengeluaran.index'));
}
}
24 changes: 10 additions & 14 deletions app/Http/Controllers/PemasukanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace App\Http\Controllers;

use App\Pemasukan;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Webpatser\Uuid\Uuid;

class PemasukanController extends Controller
{
public function index()
{
$data = \DB::table('pemasukan')->get();
$data = Pemasukan::all();
return view('sumber.index', compact('data'));
}

Expand All @@ -24,11 +25,9 @@ public function store(Request $request)
'nama' => 'required',
]);

$nama = $request->nama;

\DB::table('pemasukan')->insert([
'id' => \Uuid::generate(4),
'nama' => $nama,
Pemasukan::insert([
'id' => Uuid::generate(4),
'nama' => $request->nama,
'created_at' => date('Y-m-d-H:i:s'),
'updated_at' => date('Y-m-d-H:i:s'),
]);
Expand All @@ -38,7 +37,7 @@ public function store(Request $request)

public function edit($id)
{
$data = \DB::table('pemasukan')->where('id', $id)->first();
$data = Pemasukan::where('id', $id)->first();
return view('sumber.edit', compact('data'));
}

Expand All @@ -48,20 +47,17 @@ public function update(Request $request, $id)
'nama' => 'required',
]);

$nama = $request->nama;

\DB::table('pemasukan')->where('id', $id)->update([
'nama' => $nama,
Pemasukan::where('id', $id)->update([
'nama' => $request->nama,
'updated_at' => date('Y-m-d-H:i:s'),
]);

return redirect(route('sumber.pemasukan'));

}

public function delete($id)
{
\DB::table('pemasukan')->where('id', $id)->delete();
Pemasukan::where('id', $id)->delete();
return redirect(route('sumber.pemasukan'));
}
}
12 changes: 12 additions & 0 deletions app/ManagePemasukan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class ManagePemasukan extends Model
{
protected $table = 'manage_pemasukan';

protected $guarded = [];
}
12 changes: 12 additions & 0 deletions app/ManagePengeluaran.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class ManagePengeluaran extends Model
{
protected $table = 'manage_pengeluaran';

protected $guarded = [];
}
12 changes: 12 additions & 0 deletions app/Pemasukan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Pemasukan extends Model
{
protected $table = 'pemasukan';

protected $guarded = [];
}