Skip to content
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
9 changes: 8 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ MAIL_PASSWORD=aggrshtusbqwjbhl
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=menghafalitumudahofficial@gmail.com
MAIL_FROM_NAME="${APP_NAME}"

# MAIL_MAILER=smtp
# MAIL_HOST=sandbox.smtp.mailtrap.io
# MAIL_PORT=2525
# MAIL_USERNAME=35b7f2172f90cb
# MAIL_PASSWORD=169fb4552c3aea
# MAIL_ENCRYPTION=tls
# MAIL_FROM_ADDRESS="hello@example.com"
# MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
Expand Down
50 changes: 50 additions & 0 deletions app/Http/Controllers/API/BacaanSholatController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Http\Controllers\API;

use App\Http\Controllers\Controller;
use App\Models\BacaanSholat;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class BacaanSholatController extends Controller
{
public function createBacaan(Request $request){
$validator = Validator::make($request->all(), [
'arab' => 'required',
'latin' => 'required',
'terjemahan' => 'required',
'voice_arab' => 'required',
'voice_terjemahan' => 'required',
]);

if($validator->fails()){
response()->json([
'Error' => true,
'Massage' => $validator->errors()
]);
}

$bacaan = BacaanSholat::create([
'arab' => $request->arab,
'latin' => $request->latin,
'terjemahan' => $request->terjemahan,
'voice_arab' => $request->voice_arab,
'voice_terjemahan' => $request->voice_terjemahan,
]);

response()->json([
'Error' => true,
'Massage' => $bacaan
]);

}

public function showBacaan(){
$bacaan = BacaanSholat::all();

return response()->json([
'Massage' => $bacaan
]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Konten/AmalYaumiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function createAmal(Request $request){
'user_id' =>$user,
'hari' => Carbon::now()->toDateString(),
'subuh' =>$request->subuh,
'zuhur' =>$request->zuhur ,
'zuhur' =>$request->zuhur,
'ashar'=>$request->ashar,
'maghrib'=>$request->maghrib,
'isya'=>$request->isya,
Expand Down
64 changes: 58 additions & 6 deletions app/Http/Controllers/Konten/ArtikelDakwahController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers\Konten;

use Hashids\Hashids;
use Illuminate\Http\Request;
use App\Models\ArtikelDakwah;
use App\Http\Controllers\Controller;
Expand All @@ -22,38 +23,89 @@ public function createArtikel(Request $request){
return response()->json([
'Error' => true,
'Massage' => $validator->errors()
]);
], 402);
}

$uploadedImage = Cloudinary::upload($request->file('gambar')->getRealPath(), [
'folder' => 'MIM/ArtikelDakwah'
]);

$artikel = ArtikelDakwah::create([
$artikels = ArtikelDakwah::create([
'judul' => $request->judul,
'gambar' => $uploadedImage->getSecurePath(),
'deskripsi' => $request->deskripsi,
'author' => $request->author
]);

$hashids = new Hashids('your-secret-salt', 10);
$hashedId = $hashids->encode($artikels->id);
$artikel = $artikels->toArray();
$artikel['id'] = $hashedId;
return response()->json([
'Massage' => 'artikelCreatedSuccessfully',
'Artikel' => $artikel
]);
}

public function showArtikel(){
$artikels = ArtikelDakwah::orderBy('created_at', 'desc')->paginate(8);
$hashids = new Hashids('your-secret-salt', 10);

$transformedData = $artikels->getCollection()->map(function($article) use ($hashids) {
$array = $article->toArray();
$encodedId = $hashids->encode($article->id);
if ($encodedId) {
$array['id'] = $encodedId;
} else {
return response()->json([
'Data User' => 'Id Tidak Bisa DIHash'
]);
}
return $array;
})->toArray();

$artikel = ArtikelDakwah::all();
$artikels->setCollection(collect($transformedData));

return response()->json([
'Artikel' => $artikels
]);

}

public function showOneArtikel($id){
$hashids = new Hashids('your-secret-salt', 10);
$artikels = ArtikelDakwah::where('id', $hashids->decode($id))->first();

if(!$artikels){
return response()->json([
'Artikel' => null, 'Not Found'
], 204);
}
$artikel = $artikels->toArray();
$encodedId = $hashids->encode($artikels->id);
if ($encodedId) {
$artikel['id'] = $encodedId ;
} else {
return response()->json([
'Data User' => 'Id Tidak Bisa DIHash'
]);
}
return response()->json([
'Artikel' => $artikel
]);
}

public function updateArtikel(Request $request, $id){
$artikel = ArtikelDakwah::find($id);
$hashids = new Hashids('your-secret-salt', 10);
$artikel = ArtikelDakwah::find($hashids->decode($id)[0]);

if (!$artikel) {
return response()->json([
'Error' => true,
'Message' => 'Artikel tidak ditemukan'
], 404);
}

$validator = Validator::make($request->all(), [
'judul' => ['required', 'string'],
'gambar'=>['required', 'mimes:jpeg,jpg,png,svg,webp','max:2048', 'image'],
Expand Down Expand Up @@ -98,8 +150,8 @@ public function updateArtikel(Request $request, $id){
}

public function deleteArtikel($id){

ArtikelDakwah::destroy($id);
$hashids = new Hashids('your-secret-salt', 10);
ArtikelDakwah::destroy($hashids->decode($id));

return response()->json([
'Massage' => 'artikelDeletedSuccessfully',
Expand Down
67 changes: 59 additions & 8 deletions app/Http/Controllers/Konten/InfoKajianController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Konten;

use Carbon\Carbon;
use Hashids\Hashids;
use App\Models\InfoKajian;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
Expand All @@ -28,14 +29,18 @@ public function createKajian(Request $request){
$uploadedImage = Cloudinary::upload($request->file('gambar')->getRealPath(), [
'folder' => 'MIM/thumnail_infokajian'
]);
$konten = InfoKajian::create([
$kontens = InfoKajian::create([
'judul' => $request->judul,
'gambar' => $uploadedImage->getSecurePath(),
'waktu'=> $request->waktu,
'tanggal' => Carbon::createFromFormat('l, d-F-Y', $request->tanggal)->format('Y-m-d'),
'link'=> $request->link
]);

$hashids = new Hashids('your-secret-salt', 10);
$hashedId = $hashids->encode($kontens->id);
$konten = $kontens->toArray();
$konten['id'] = $hashedId;
return response()->json([
'Massage' => 'ContentCreatedSuccessfully',
'user' => $konten
Expand All @@ -44,15 +49,61 @@ public function createKajian(Request $request){

public function showKajian(){

$konten = InfoKajian::all();
$infoKajian = InfoKajian::orderBy('created_at', 'desc')->paginate(8);
$hashids = new Hashids('your-secret-salt', 10);

$transformedData = $infoKajian->getCollection()->map(function($infokajians) use ($hashids) {
$array = $infokajians->toArray();
$encodedId = $hashids->encode($infokajians->id);
if ($encodedId) {
$array['id'] = $encodedId;
} else {
return response()->json([
'Data User' => 'Id Tidak Bisa DIHash'
]);
}
return $array;
})->toArray();

$infoKajian->setCollection(collect($transformedData));

return response()->json([
'data' => $konten
'Artikel' => $infoKajian
]);
}

public function updateKajian(Request $request, $id){
public function showOneKajian($id){
$hashids = new Hashids('your-secret-salt', 10);
$kontens = InfoKajian::where('id', $hashids->decode($id))->first();

if(!$kontens){
return response()->json([
'Kajian' => null, 'Not Found'
], 204);
}
$konten = $kontens->toArray();
$encodedId = $hashids->encode($kontens->id);
if ($encodedId) {
$konten['id'] = $encodedId ;
} else {
return response()->json([
'Data User' => 'Id Tidak Bisa DIHash'
]);
}

$konten = InfoKajian::find($id);
return response()->json([
'Artikel' => $konten
]);
}

public function updateKajian(Request $request, $id){
$hashids = new Hashids('your-secret-salt', 10);
$konten = InfoKajian::find($hashids->decode($id)[0]);
if (!$konten) {
return response()->json([
'message' => 'Kajian tidak ditemukan'
], 404);
}

$validator = Validator::make($request->all(),[
'judul' => 'required|string',
Expand All @@ -71,7 +122,7 @@ public function updateKajian(Request $request, $id){

if ($request->hasFile('gambar')) {
// Menghapus foto lama jika ada
if ($konten->poto) {
if ($konten->gambar) {
$publicId = pathinfo($konten->gambar, PATHINFO_FILENAME);
Cloudinary::destroy($publicId);
}
Expand All @@ -98,8 +149,8 @@ public function updateKajian(Request $request, $id){
}

public function deleteKajian($id){

InfoKajian::destroy($id);
$hashids = new Hashids('your-secret-salt', 10);
InfoKajian::destroy($hashids->decode($id));

return response()->json([
'Artikel' => 'Kajian Ini Berhasil DiHapus'
Expand Down
35 changes: 27 additions & 8 deletions app/Http/Controllers/Konten/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Controllers\Konten;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use App\Models\ArtikelDakwah;
use App\Models\InfoKajian;
Expand Down Expand Up @@ -32,19 +31,39 @@ public function searchKonten(Request $request)
'ArtikelDakwah' => $artikelDakwahResults
];

return response()->json($results);
return response()->json(["DataSearch" => $results]);
}

public function searchUser(Request $request){
$query = $request->get('Search');

$results = User::where('name', 'like', "%{$query}%")
->orWhere('email', 'like', "%{$query}%")
->orWhere('tempat_lahir', 'like', "%{$query}%")
->orWhere('no_telp', 'like', "%{$query}%")
->get();
$results = User::where('role', 'user')
->where(function($q) use ($query) {
$q->where('name', 'like', "%{$query}%")
->orWhere('email', 'like', "%{$query}%")
->orWhere('tempat_lahir', 'like', "%{$query}%")
->orWhere('no_telp', 'like', "%{$query}%");
})->get();

return response()->json($results);


return response()->json(["DataSearch" => $results]);
}

public function searchAdmin(Request $request){
$query = $request->get('Search');

$results = User::where('role', 'admin')
->where(function($q) use ($query) {
$q->where('name', 'like', "%{$query}%")
->orWhere('email', 'like', "%{$query}%")
->orWhere('tempat_lahir', 'like', "%{$query}%")
->orWhere('no_telp', 'like', "%{$query}%");
})->get();



return response()->json(["DataSearch" => $results]);
}

}
Expand Down
Loading