Compare commits
No commits in common. "78f1287b59227d93183eba5818d086859a850daf" and "7a9569e429f2083356c32597f712e86b21112de1" have entirely different histories.
78f1287b59
...
7a9569e429
|
|
@ -1,46 +0,0 @@
|
|||
name: Auto Deploy Mancontani
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Deployment Logic Mancontani
|
||||
run: |
|
||||
cd /www/wwwroot/mancontani
|
||||
|
||||
# 1. Ambil ID commit lama untuk deteksi perubahan
|
||||
OLD_COMMIT=$(git rev-parse HEAD)
|
||||
|
||||
# 2. Tarik kode terbaru
|
||||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/sayasilvi/web-pertanian.git
|
||||
git fetch -4 --all
|
||||
git reset --hard origin/main
|
||||
|
||||
# 3. Ambil ID commit baru
|
||||
NEW_COMMIT=$(git rev-parse HEAD)
|
||||
|
||||
# 4. Build dependencies (Container temporary)
|
||||
docker run --rm -v $(pwd):/app -w /app composer:2 install --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-reqs
|
||||
|
||||
# 5. Perbaikan permission untuk user www/docker (PUID 33)
|
||||
# Sekalian fix untuk storage dan cache biar aman
|
||||
chown -R 33:33 vendor/ storage/ bootstrap/cache/
|
||||
chmod -R 775 storage/ bootstrap/cache/
|
||||
|
||||
# 6. Refresh cache Laravel
|
||||
# REVISI: Menggunakan docker exec langsung ke nama container yang sedang jalan
|
||||
docker exec mancontani-php-container php artisan optimize:clear
|
||||
|
||||
# 7. Deteksi otomatis migrasi database
|
||||
if [ "$OLD_COMMIT" != "$NEW_COMMIT" ] && git diff --name-only $OLD_COMMIT $NEW_COMMIT | grep -q "^database/migrations/"; then
|
||||
echo "🚀 Perubahan database terdeteksi! Menjalankan migrate..."
|
||||
docker exec mancontani-php-container php artisan migrate --force
|
||||
else
|
||||
echo "✅ Tidak ada file migrasi baru. Skip migrate."
|
||||
fi
|
||||
32
Dockerfile
32
Dockerfile
|
|
@ -1,32 +0,0 @@
|
|||
FROM php:8.2-fpm
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev \
|
||||
zip \
|
||||
unzip \
|
||||
libzip-dev \
|
||||
libicu-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libfreetype6-dev \
|
||||
gnupg \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||
&& apt-get install -y nodejs \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip intl
|
||||
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
COPY . /var/www
|
||||
|
||||
RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache
|
||||
|
||||
EXPOSE 9000
|
||||
CMD ["php-fpm"]
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
</p>
|
||||
|
||||
<h1 align="center">Tani Desa</h1>
|
||||
Test CI/CD 123
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public function dashboard()
|
|||
$labelHarga = $hargaStabil->pluck('tanggal')->map(function($date) {
|
||||
return \Carbon\Carbon::parse($date)->format('d M');
|
||||
});
|
||||
$dataHarga = $hargaStabil->pluck('rata_harga');//isi grafik
|
||||
$dataHarga = $hargaStabil->pluck('rata_harga');
|
||||
|
||||
return view('admin.dashboard', compact(
|
||||
'totalPetani', 'totalProduk', 'totalTransaksi', 'transaksiTerbaru',
|
||||
|
|
|
|||
|
|
@ -16,11 +16,10 @@ public function index()
|
|||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'nik' => 'required|unique:gapoktans,nik|digits:16',
|
||||
'nik' => 'required|unique:gapoktans,nik|max:16',
|
||||
'nama' => 'required|string|max:255',
|
||||
], [
|
||||
'nik.unique' => 'NIK ini sudah terdaftar di sistem.',
|
||||
'nik.digits' => 'NIK wajib berisi tepat 16 digit angka.',
|
||||
]);
|
||||
|
||||
Gapoktan::create([
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ public function index(Request $request)
|
|||
if ($request->has('kategori') && $request->kategori != '' && $request->kategori != 'Semua') {
|
||||
$slug = $request->kategori;
|
||||
|
||||
$query->whereHas('kategori', function ($q) use ($slug) {//filter berdasarkan relasi kategori
|
||||
$q->where('slug', $slug);//ambil produk dgn slug tertentu
|
||||
$query->whereHas('kategori', function ($q) use ($slug) {
|
||||
$q->where('slug', $slug);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -45,8 +45,8 @@ public function shop(Request $request)
|
|||
|
||||
// --- FILTER LOKASI ---
|
||||
if ($request->filled('provinsi')) {
|
||||
$query->whereHas('petani', function($q) use ($request) {// filter data produk berdasarkan relasi petani
|
||||
$q->where('provinsi_code', $request->provinsi);// mengambil data produk sesuai dengan provinsi yang dipilih
|
||||
$query->whereHas('petani', function($q) use ($request) {
|
||||
$q->where('provinsi_code', $request->provinsi);
|
||||
});
|
||||
}
|
||||
if ($request->filled('kota')) {
|
||||
|
|
@ -71,10 +71,10 @@ public function shop(Request $request)
|
|||
}
|
||||
|
||||
// Filter Kategori
|
||||
if ($request->has('kategori') && $request->kategori != '') {//memastikan user memilih kategori
|
||||
$slug = $request->kategori;//ambil kategori berdasarkan slug yg diinptkan
|
||||
if ($request->has('kategori') && $request->kategori != '') {
|
||||
$slug = $request->kategori;
|
||||
$query->whereHas('kategori', function ($q) use ($slug) {
|
||||
$q->where('slug', $slug);//ambil produk dhn slug tertentu
|
||||
$q->where('slug', $slug);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ public function detail($id)
|
|||
$produk_terkait = Produk::where('kategori_id', $produk->kategori_id)
|
||||
->where('id', '!=', $produk->id)
|
||||
->where('stok', '>', 0)
|
||||
->inRandomOrder()//mengacak urutan data
|
||||
->inRandomOrder()
|
||||
->take(4)
|
||||
->get();
|
||||
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@ private function getChatList($user)
|
|||
$q->where('pengirim_id', $user->id)->where('pengirim_type', get_class($user));
|
||||
})->orWhere(function ($q) use ($user) {
|
||||
$q->where('penerima_id', $user->id)->where('penerima_type', get_class($user));
|
||||
})->orderBy('created_at', 'desc')->get();//baru ke lama
|
||||
})->orderBy('created_at', 'desc')->get();
|
||||
|
||||
$conversations = $allMessages->groupBy(function ($pesan) use ($user) {
|
||||
if ($pesan->pengirim_id == $user->id && $pesan->pengirim_type == get_class($user)) {
|
||||
return $pesan->penerima_type . '_' . $pesan->penerima_id;//grup bedasarkan penerima(lawan chat)
|
||||
return $pesan->penerima_type . '_' . $pesan->penerima_id;
|
||||
} else {
|
||||
return $pesan->pengirim_type . '_' . $pesan->pengirim_id;//grup berdasarkan pengirim
|
||||
return $pesan->pengirim_type . '_' . $pesan->pengirim_id;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ private function getChatList($user)
|
|||
});
|
||||
}
|
||||
|
||||
public function index()//detail chat
|
||||
public function index()
|
||||
{
|
||||
$user = $this->getAuthenticatedUser();
|
||||
$isPetani = Auth::guard('petani')->check();
|
||||
|
|
@ -66,29 +66,29 @@ public function index()//detail chat
|
|||
return view($view, compact('chatList'));
|
||||
}
|
||||
|
||||
public function show($id)//isi chat
|
||||
public function show($id)
|
||||
{
|
||||
$user = $this->getAuthenticatedUser();
|
||||
$isPetani = Auth::guard('petani')->check();
|
||||
|
||||
// Ambil daftar chat (untuk Sidebar Kiri)
|
||||
// Ambil List Chat juga (untuk Sidebar Kiri)
|
||||
$chatList = $this->getChatList($user);
|
||||
|
||||
// Logika Detail Chat (Kanan)
|
||||
$lawanType = $isPetani ? Pembeli::class : Petani::class;//menentukan lawan chat
|
||||
$lawan = $lawanType::findOrFail($id);//ambil data lawan chat (id)
|
||||
$lawanType = $isPetani ? Pembeli::class : Petani::class;
|
||||
$lawan = $lawanType::findOrFail($id);
|
||||
|
||||
$chats = Pesan::where(function ($q) use ($user, $lawan, $lawanType) {
|
||||
$q->where('pengirim_id', $user->id)->where('pengirim_type', get_class($user))//ambil pesan yg kirim user
|
||||
->where('penerima_id', $lawan->id)->where('penerima_type', $lawanType);//tujuan pesan merupakan lawan chat
|
||||
$q->where('pengirim_id', $user->id)->where('pengirim_type', get_class($user))
|
||||
->where('penerima_id', $lawan->id)->where('penerima_type', $lawanType);
|
||||
})->orWhere(function ($q) use ($user, $lawan, $lawanType) {
|
||||
$q->where('pengirim_id', $lawan->id)->where('pengirim_type', $lawanType)//pesan dikirim oleh lawan
|
||||
$q->where('pengirim_id', $lawan->id)->where('pengirim_type', $lawanType)
|
||||
->where('penerima_id', $user->id)->where('penerima_type', get_class($user));
|
||||
})->orderBy('created_at', 'asc')->get();
|
||||
|
||||
// Tandai dibaca
|
||||
Pesan::where('pengirim_id', $lawan->id)->where('pengirim_type', $lawanType)//ambil pesan yg dikirim oleh lawan
|
||||
->where('penerima_id', $user->id)->update(['sudah_dibaca' => true]);//dimana penerima adalah user yg sedang login
|
||||
Pesan::where('pengirim_id', $lawan->id)->where('pengirim_type', $lawanType)
|
||||
->where('penerima_id', $user->id)->update(['sudah_dibaca' => true]);
|
||||
|
||||
$view = $isPetani ? 'petani.pesan.show' : 'landing.pesan.show';
|
||||
|
||||
|
|
|
|||
|
|
@ -82,12 +82,12 @@ public function edit($id)
|
|||
$produk = Produk::with('images')->where('id', $id)->where('petani_id', Auth::guard('petani')->id())->firstOrFail();
|
||||
$kategoris = Kategori::all();
|
||||
|
||||
// $provinsis = Province::all();
|
||||
// $kotas = City::where('province_code', $produk->provinsi_code)->get();
|
||||
// $kecamatans = District::where('city_code', $produk->kota_code)->get();
|
||||
// $desas = Village::where('district_code', $produk->kecamatan_code)->get();
|
||||
$provinsis = Province::all();
|
||||
$kotas = City::where('province_code', $produk->provinsi_code)->get();
|
||||
$kecamatans = District::where('city_code', $produk->kota_code)->get();
|
||||
$desas = Village::where('district_code', $produk->kecamatan_code)->get();
|
||||
|
||||
return view('petani.produk.edit', compact('produk', 'kategoris'));
|
||||
return view('petani.produk.edit', compact('produk', 'kategoris', 'provinsis', 'kotas', 'kecamatans', 'desas'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public function editPetani()
|
|||
$user = Auth::guard('petani')->user();
|
||||
|
||||
$provinsis = Province::all();
|
||||
$kotas = $user->provinsi_code ? City::where('province_code', $user->provinsi_code)->get() : [];//memastikan user sdh memilih provinsi, lalu menampilkan semua kota sesuai provinsi
|
||||
$kotas = $user->provinsi_code ? City::where('province_code', $user->provinsi_code)->get() : [];
|
||||
$kecamatans = $user->kota_code ? District::where('city_code', $user->kota_code)->get() : [];
|
||||
$desas = $user->kecamatan_code ? Village::where('district_code', $user->kecamatan_code)->get() : [];
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ public function updatePetani(Request $request)
|
|||
$user->link_maps = $request->link_maps;
|
||||
|
||||
if ($request->filled('password')) {
|
||||
$user->password = Hash::make($request->password);// hash untuk enkripsi pw
|
||||
$user->password = Hash::make($request->password);
|
||||
}
|
||||
|
||||
if ($request->hasFile('foto')) {
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ public function checkoutPage(Request $request)
|
|||
}
|
||||
|
||||
// LOGIKA CHECKOUT DARI KERANJANG (Database)
|
||||
$cartIds = $request->query('cart_ids');//MENGAMBIL PARAMETER CARD_IDS DARI URL
|
||||
$cartIds = $request->query('cart_ids');
|
||||
|
||||
if (!$cartIds) {//mengecek apakah produk pada keranjang ada yg dipilih
|
||||
if (!$cartIds) {
|
||||
return redirect()->route('cart')->with('error', 'Pilih minimal satu produk di keranjang untuk dicheckout.');
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ public function prosesCheckout(Request $request)
|
|||
'subtotal' => $total_harga,
|
||||
]);
|
||||
|
||||
$produk->decrement('stok', $request->jumlah);//mengurangi stok
|
||||
$produk->decrement('stok', $request->jumlah);
|
||||
|
||||
} else {
|
||||
// --- LOGIKA KERANJANG (DATABASE) ---
|
||||
|
|
@ -124,19 +124,19 @@ public function prosesCheckout(Request $request)
|
|||
throw new \Exception("ID keranjang tidak ditemukan.");
|
||||
}
|
||||
|
||||
$cartIds = explode(',', $request->cart_ids);//ubah teks menjadi array
|
||||
$cartIds = explode(',', $request->cart_ids);
|
||||
|
||||
$cartItems = Cart::with('produk')
|
||||
->whereIn('id', $cartIds)//ambil data cart dengan id
|
||||
->where('pembeli_id', $pembeli_id)//hanya ambil cart milik user yg sedang login
|
||||
->whereIn('id', $cartIds)
|
||||
->where('pembeli_id', $pembeli_id)
|
||||
->get();
|
||||
|
||||
$groupedByPetani = [];//membuat array kosong untuk menyimpan data
|
||||
foreach ($cartItems as $item) {//melakukan perulangan dengan memproses item satu persatu
|
||||
$groupedByPetani[$item->produk->petani_id][] = $item;//mengambil id petani dari produk kemudian dikelompokkan (itek dikelompokkan)
|
||||
$groupedByPetani = [];
|
||||
foreach ($cartItems as $item) {
|
||||
$groupedByPetani[$item->produk->petani_id][] = $item;
|
||||
}
|
||||
|
||||
foreach ($groupedByPetani as $petani_id => $items) {//memproses data per petani satu persatu berdasarkan id petani
|
||||
foreach ($groupedByPetani as $petani_id => $items) {
|
||||
$transaksi = Transaksi::create([
|
||||
'pembeli_id' => $pembeli_id,
|
||||
'petani_id' => $petani_id,
|
||||
|
|
@ -160,7 +160,7 @@ public function prosesCheckout(Request $request)
|
|||
'subtotal' => $total_per_item,
|
||||
]);
|
||||
|
||||
$item->produk->decrement('stok', $item->quantity);//mengurangi stok
|
||||
$item->produk->decrement('stok', $item->quantity);
|
||||
}
|
||||
|
||||
// Update total harga transaksi per petani
|
||||
|
|
@ -233,7 +233,7 @@ public function updateStatus(Request $request, $id)
|
|||
// Jika dibatalkan, kembalikan stok produk
|
||||
if ($request->status == 'batal') {
|
||||
foreach ($transaksi->detailTransaksis as $detail) {
|
||||
$detail->produk->increment('stok', $detail->jumlah);//menambah atau mengembalikan stok
|
||||
$detail->produk->increment('stok', $detail->jumlah);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ public function pesananDetail($id)
|
|||
{
|
||||
$petaniId = Auth::guard('petani')->id();
|
||||
|
||||
$pesanan = Transaksi::whereHas('detailTransaksis.produk', function ($q) use ($petaniId) {//ambil data transaksi yang hanya dimiliki petani yg sedang login
|
||||
$pesanan = Transaksi::whereHas('detailTransaksis.produk', function ($q) use ($petaniId) {
|
||||
$q->where('petani_id', $petaniId);
|
||||
})
|
||||
->with(['pembeli', 'detailTransaksis.produk'])
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -20,8 +19,6 @@ public function register(): void
|
|||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
if (config('app.env') === 'production') {
|
||||
URL::forceScheme('https');
|
||||
}
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
mancontani_php:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: mancontani-app
|
||||
container_name: mancontani-php-container
|
||||
restart: unless-stopped
|
||||
working_dir: /var/www
|
||||
volumes:
|
||||
- .:/var/www
|
||||
networks:
|
||||
- mancontani-network
|
||||
- laravel-network
|
||||
|
||||
mancontani_nginx:
|
||||
image: nginx:alpine
|
||||
container_name: mancontani-nginx-container
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8093:80"
|
||||
volumes:
|
||||
- .:/var/www
|
||||
- ./nginx/conf.d:/etc/nginx/conf.d
|
||||
networks:
|
||||
- mancontani-network
|
||||
depends_on:
|
||||
- mancontani_php
|
||||
|
||||
networks:
|
||||
mancontani-network:
|
||||
driver: bridge
|
||||
|
||||
laravel-network:
|
||||
external: true
|
||||
name: bpbd_laravel-network
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name mancontani.web.id;
|
||||
|
||||
root /var/www/public;
|
||||
index index.php index.html;
|
||||
|
||||
access_log /var/log/nginx/mancontani_access.log;
|
||||
error_log /var/log/nginx/mancontani_error.log;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass mancontani_php:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
}
|
||||
}
|
||||
|
|
@ -179,8 +179,8 @@
|
|||
type: 'bar',
|
||||
|
||||
data: {
|
||||
labels: labelMultiline, //nama produk(x)
|
||||
datasets: [{//isi grafik(y)
|
||||
labels: labelMultiline,
|
||||
datasets: [{
|
||||
label: 'Total Terjual',
|
||||
data: dataTerlaris,
|
||||
backgroundColor: 'rgba(129, 196, 8, 0.8)',
|
||||
|
|
@ -227,10 +227,10 @@
|
|||
new Chart(ctxHarga, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: {!! json_encode($labelHarga) !!},// sumbu x (tanggal)
|
||||
labels: {!! json_encode($labelHarga) !!},
|
||||
datasets: [{
|
||||
label: 'Rata-rata Harga',
|
||||
data: {!! json_encode($dataHarga) !!},//sumbu y (daftar harga)
|
||||
data: {!! json_encode($dataHarga) !!},
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.1)',
|
||||
borderColor: '#36A2EB',
|
||||
borderWidth: 2,
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@
|
|||
@csrf
|
||||
<div class="form-group mb-3">
|
||||
<label>NIK</label>
|
||||
<input type="text" name="nik" class="form-control" required
|
||||
placeholder="Masukkan 16 digit NIK"
|
||||
minlength="16" maxlength="16"
|
||||
oninput="this.value = this.value.replace(/[^0-9]/g, '')">
|
||||
<input type="number" name="nik" class="form-control" required
|
||||
placeholder="Masukkan 16 digit NIK">
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label>Nama Petani / Kelompok</label>
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class="badge bg-primary bg-opacity-10 px-3 py-2 rounded-pill fw-bold border bord
|
|||
class="btn btn-light border-danger text-danger border fw-bold mb-4 w-100 text-start shadow-sm"
|
||||
style="border-radius: 10px;">
|
||||
<i class="fas fa-map-marker-alt me-2 fs-5 align-middle"></i>
|
||||
Lihat Lokasi di Google Lahan Maps
|
||||
Lihat Lokasi Lahan di Google Maps
|
||||
<i class="fas fa-external-link-alt float-end mt-1 text-muted opacity-50"></i>
|
||||
</a>
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 69a3234d0b18b39ba9bf6c2d3a6313cdc925373c
|
||||
Loading…
Reference in New Issue