update api scramble telescope
This commit is contained in:
@@ -11,6 +11,8 @@ use Illuminate\Support\Facades\Hash;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Profile;
|
use App\Models\Profile;
|
||||||
|
|
||||||
|
use App\Http\Resources\UserResource;
|
||||||
|
|
||||||
class AuthController extends Controller
|
class AuthController extends Controller
|
||||||
{
|
{
|
||||||
public function login(Request $request): JSONResponse
|
public function login(Request $request): JSONResponse
|
||||||
@@ -41,7 +43,7 @@ class AuthController extends Controller
|
|||||||
{
|
{
|
||||||
$credentials = $request->validate([
|
$credentials = $request->validate([
|
||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
'email' => ['required', 'email'],
|
'email' => ['required', 'email', 'max:255', 'unique:users'],
|
||||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||||
'role' => ['string'],
|
'role' => ['string'],
|
||||||
]);
|
]);
|
||||||
@@ -58,6 +60,8 @@ class AuthController extends Controller
|
|||||||
'email' => $credentials['email'],
|
'email' => $credentials['email'],
|
||||||
'role' => $credentials['role'],
|
'role' => $credentials['role'],
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
|
'created_by' => $user->id,
|
||||||
|
'updated_by' => $user->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!Auth::attempt($credentials)) {
|
if (!Auth::attempt($credentials)) {
|
||||||
@@ -79,7 +83,7 @@ class AuthController extends Controller
|
|||||||
|
|
||||||
public function me(Request $request): JSONResponse
|
public function me(Request $request): JSONResponse
|
||||||
{
|
{
|
||||||
return response()->json($request->user());
|
return response()->json(new UserResource($request->user()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logout(Request $request): JSONResponse
|
public function logout(Request $request): JSONResponse
|
||||||
|
|||||||
@@ -6,40 +6,55 @@ use App\Http\Controllers\Controller;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Wilayah\DesaKelurahan;
|
use App\Models\Wilayah\DesaKelurahan;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
|
use App\Http\Resources\Wilayah\DesaKelurahanResource;
|
||||||
|
use App\Http\Resources\Wilayah\DesaKelurahanCollectionResource;
|
||||||
|
|
||||||
class DesaKelurahanController extends Controller
|
class DesaKelurahanController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*/
|
*/
|
||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): AnonymousResourceCollection
|
||||||
{
|
{
|
||||||
$size = +$request->get('size') ?: 10;
|
$size = $request->integer('size') ?: 10;
|
||||||
|
|
||||||
$master = DesaKelurahan::query();
|
$master = DesaKelurahan::with('kecamatan')
|
||||||
|
->when($request->search, function ($q, $search) {
|
||||||
|
$search = strtolower($search);
|
||||||
|
$q->where(function ($query) use ($search) {
|
||||||
|
$query->whereRaw('lower(kode) like ?', ["%{$search}%"])
|
||||||
|
->orWhereRaw('lower(nama) like ?', ["%{$search}%"]);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($request->kecamatan_id, fn($q,$v) => $q->where('kecamatan_id',$v))
|
||||||
|
->when($request->kabupaten_kota_id, fn ($q, $v) =>
|
||||||
|
$q->whereHas('kecamatan', fn ($k) =>
|
||||||
|
$k->where('kabupaten_kota_id', $v)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->when($request->provinsi_id, fn ($q, $v) =>
|
||||||
|
$q->whereHas('kecamatan.kabupatenkota', fn ($k) =>
|
||||||
|
$k->where('provinsi_id', $v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if ($request->has('search')) {
|
if ($request->filled('sort')) {
|
||||||
$s = $request->get('search');
|
$dir = str_starts_with($request->sort, '-') ? 'desc' : 'asc';
|
||||||
$s = strtolower($s);
|
$column = ltrim($request->sort, '-');
|
||||||
$master->where(function($query) use ($s) {
|
|
||||||
$query->whereRaw('lower(kode) like (?)',["%{$s}%"])
|
$allowed = ['id', 'kode', 'nama'];
|
||||||
->orWhereRaw('lower(nama) like (?)',["%{$s}%"]);
|
|
||||||
});
|
if (in_array($column, $allowed)) {
|
||||||
}
|
$master->orderBy($column, $dir);
|
||||||
if ($request->has('sort')) {
|
}
|
||||||
$order = $request->get('sort');
|
} else {
|
||||||
$d = substr($order, 0, 1);
|
$master->orderBy('kode', 'asc');
|
||||||
$dir = $d === '-' ? 'desc' : 'asc';
|
|
||||||
$order = $d === '-' ? substr($order, 1) : $order;
|
|
||||||
$master->orderBy($order, $dir);
|
|
||||||
}
|
|
||||||
if ($request->has('kecamatan_id')) {
|
|
||||||
$master->where('kecamatan_id', $request->get('kecamatan_id'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$masterList = $master->paginate($size);
|
$masterList = $master->paginate($size);
|
||||||
|
|
||||||
return response()->json($masterList);
|
return DesaKelurahanResource::collection($masterList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +78,7 @@ class DesaKelurahanController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(string $id): JsonResponse
|
public function show(string $id): JsonResponse
|
||||||
{
|
{
|
||||||
return response()->json(DesaKelurahan::findOrFail($id));
|
return response()->json(DesaKelurahanResource::make(DesaKelurahan::with('kecamatan')->findOrFail($id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,40 +6,49 @@ use App\Http\Controllers\Controller;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Wilayah\Kecamatan;
|
use App\Models\Wilayah\Kecamatan;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
|
use App\Http\Resources\Wilayah\KecamatanResource;
|
||||||
|
|
||||||
class KecamatanController extends Controller
|
class KecamatanController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*/
|
*/
|
||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): AnonymousResourceCollection
|
||||||
{
|
{
|
||||||
$size = +$request->get('size') ?: 10;
|
$size = $request->get('size') ?: 10;
|
||||||
|
|
||||||
$master = Kecamatan::query();
|
$master = Kecamatan::with('kabupatenKota')
|
||||||
|
->when($request->search, function ($q, $search) {
|
||||||
|
$search = strtolower($search);
|
||||||
|
$q->where(function ($query) use ($search) {
|
||||||
|
$query->whereRaw('lower(kode) like ?', ["%{$search}%"])
|
||||||
|
->orWhereRaw('lower(nama) like ?', ["%{$search}%"]);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($request->kabupaten_kota_id, fn($q,$v) => $q->where('kabupaten_kota_id',$v))
|
||||||
|
->when($request->provinsi_id, fn ($q, $v) =>
|
||||||
|
$q->whereHas('kabupatenKota.provinsi', fn ($k) =>
|
||||||
|
$k->where('provinsi_id', $v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if ($request->has('search')) {
|
if ($request->filled('sort')) {
|
||||||
$s = $request->get('search');
|
$dir = str_starts_with($request->sort, '-') ? 'desc' : 'asc';
|
||||||
$s = strtolower($s);
|
$column = ltrim($request->sort, '-');
|
||||||
$master->where(function($query) use ($s) {
|
|
||||||
$query->whereRaw('lower(kode) like (?)',["%{$s}%"])
|
$allowed = ['id', 'kode', 'nama'];
|
||||||
->orWhereRaw('lower(nama) like (?)',["%{$s}%"]);
|
|
||||||
});
|
if (in_array($column, $allowed)) {
|
||||||
}
|
$master->orderBy($column, $dir);
|
||||||
if ($request->has('sort')) {
|
}
|
||||||
$order = $request->get('sort');
|
} else {
|
||||||
$d = substr($order, 0, 1);
|
$master->orderBy('kode', 'asc');
|
||||||
$dir = $d === '-' ? 'desc' : 'asc';
|
|
||||||
$order = $d === '-' ? substr($order, 1) : $order;
|
|
||||||
$master->orderBy($order, $dir);
|
|
||||||
}
|
|
||||||
if ($request->has('kabupaten_kota_id')) {
|
|
||||||
$master->where('kabupaten_kota_id', $request->get('kabupaten_kota_id'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$masterList = $master->paginate($size);
|
$masterList = $master->paginate($size);
|
||||||
|
|
||||||
return response()->json($masterList);
|
return KecamatanResource::collection($masterList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +72,7 @@ class KecamatanController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(string $id): JsonResponse
|
public function show(string $id): JsonResponse
|
||||||
{
|
{
|
||||||
return response()->json(Kecamatan::findOrFail($id));
|
return response()->json(KecamatanResource::make(Kecamatan::with('kabupatenKota')->findOrFail($id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ use App\Http\Controllers\Controller;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Profile;
|
use App\Models\Profile;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|
||||||
|
use App\Http\Resources\ProfileResource;
|
||||||
|
|
||||||
class ProfileController extends Controller
|
class ProfileController extends Controller
|
||||||
{
|
{
|
||||||
@@ -36,10 +41,10 @@ class ProfileController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*/
|
*/
|
||||||
public function show()
|
public function show(string $id): JSONResponse
|
||||||
{
|
{
|
||||||
$profile = Profile::where('user_id', Auth::id())->first();
|
$profile = Profile::with('desaKelurahan')->where('user_id', Auth::id())->first();
|
||||||
return response()->json($profile);
|
return response()->json(new ProfileResource($profile));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,19 +58,44 @@ class ProfileController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*/
|
*/
|
||||||
public function update(Request $request)
|
public function update(Request $request, string $id): JSONResponse
|
||||||
{
|
{
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'nama' => ['required', 'string', 'max:255'],
|
'nama' => ['required', 'string', 'max:255'],
|
||||||
'email' => ['required', 'email'],
|
'email' => ['required', 'email', 'max:255', 'unique:users,email,' . Auth::id()],
|
||||||
'telepon' => ['nullable', 'string'],
|
'telepon' => ['nullable', 'string'],
|
||||||
'alamat' => ['nullable', 'string'],
|
'alamat' => ['nullable', 'string'],
|
||||||
'kk' => ['nullable', 'string'],
|
'kk' => ['nullable', 'string'],
|
||||||
'ktp' => ['nullable', 'string']
|
'ktp' => ['nullable', 'string'],
|
||||||
|
'file_kk' => ['nullable', 'file', 'mimes:jpg,jpeg,png,pdf', 'max:2048'],
|
||||||
|
'file_ktp' => ['nullable', 'file', 'mimes:jpg,jpeg,png,pdf', 'max:2048'],
|
||||||
|
'desa_kelurahan_id' => ['nullable', 'exists:master_desa_kelurahan,id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$profile = Profile::where('user_id', Auth::id())->first();
|
$profile = Profile::where('user_id', Auth::id())->first();
|
||||||
$profile->update($validated);
|
|
||||||
|
if ($request->hasFile('file_kk')) {
|
||||||
|
$validated['file_kk'] = $request->file('file_kk')->getClientOriginalName();
|
||||||
|
$kkPath = $request->file('file_kk')->store('uploads/profile/' . $profile->id, 'public');
|
||||||
|
$validated['path_kk'] = $kkPath;
|
||||||
|
}
|
||||||
|
if ($request->hasFile('file_ktp')) {
|
||||||
|
$validated['file_ktp'] = $request->file('file_ktp')->getClientOriginalName();
|
||||||
|
$ktpPath = $request->file('file_ktp')->store('uploads/profile/' . $profile->id, 'public');
|
||||||
|
$validated['path_ktp'] = $ktpPath;
|
||||||
|
}
|
||||||
|
$validated['updated_by'] = Auth::id();
|
||||||
|
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
DB::transaction(function () use ($profile, $user, $validated) {
|
||||||
|
$profile->update($validated);
|
||||||
|
$user->update([
|
||||||
|
'name' => $validated['nama'],
|
||||||
|
'email' => $validated['email'],
|
||||||
|
'updated_by' => $user->id,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
return response()->json($profile);
|
return response()->json($profile);
|
||||||
}
|
}
|
||||||
@@ -77,4 +107,21 @@ class ProfileController extends Controller
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function downloadFile(string $id, string $type): JsonResponse | BinaryFileResponse
|
||||||
|
{
|
||||||
|
$profile = Profile::where('user_id', Auth::id())->first();
|
||||||
|
|
||||||
|
if (!$profile) {
|
||||||
|
return response()->json(['message' => 'Profile tidak ditemukan'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type === 'kk' && $profile->path_kk) {
|
||||||
|
return response()->file(storage_path('app/public/' . $profile->path_kk));
|
||||||
|
} elseif ($type === 'ktp' && $profile->path_ktp) {
|
||||||
|
return response()->file(storage_path('app/public/' . $profile->path_ktp));
|
||||||
|
} else {
|
||||||
|
return response()->json(['message' => 'File tidak ditemukan'], 404);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ class KecamatanController extends Controller
|
|||||||
|
|
||||||
$provinsi = Provinsi::all();
|
$provinsi = Provinsi::all();
|
||||||
|
|
||||||
$kecamatan = Kecamatan::with('kabupatenkota')
|
$kecamatan = Kecamatan::with('kabupatenKota')
|
||||||
->where('nama', 'like', "%$search%")
|
->where('nama', 'like', "%$search%")
|
||||||
->orWhere('kode', 'like', "%$search%")
|
->orWhere('kode', 'like', "%$search%")
|
||||||
->orWhereHas('kabupatenkota', function($query) use ($search) {
|
->orWhereHas('kabupatenKota', function($query) use ($search) {
|
||||||
$query->where('nama', 'like', "%$search%");
|
$query->where('nama', 'like', "%$search%");
|
||||||
})
|
})
|
||||||
->orderBy('kode', 'asc')
|
->orderBy('kode', 'asc')
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
use App\Http\Resources\Wilayah\DesaKelurahanResource;
|
||||||
|
use App\Http\Resources\UserResource;
|
||||||
|
|
||||||
|
class ProfileResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'user_id' => $this->user_id,
|
||||||
|
'nama' => $this->nama,
|
||||||
|
'email' => $this->email,
|
||||||
|
'telepon' => $this->telepon,
|
||||||
|
'alamat' => $this->alamat,
|
||||||
|
'ktp' => $this->ktp,
|
||||||
|
'kk' => $this->kk,
|
||||||
|
// 'file_ktp' => $this->file_ktp,
|
||||||
|
// 'file_kk' => $this->file_kk,
|
||||||
|
'desa_kelurahan_id' => $this->desa_kelurahan_id,
|
||||||
|
'desa_kelurahan' => $this->desaKelurahan ? new DesaKelurahanResource($this->desaKelurahan) : null,
|
||||||
|
'user' => $this->user ? new UserResource($this->user) : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class UserResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'email' => $this->email,
|
||||||
|
'email_verified_at' => $this->email_verified_at,
|
||||||
|
'role' => $this->role,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources\Wilayah;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class DesaKelurahanResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'nama' => $this->nama,
|
||||||
|
'kode' => $this->kode,
|
||||||
|
'kecamatan' => $this->kecamatan ? new KecamatanResource($this->kecamatan) : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources\Wilayah;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
use App\Http\Resources\Wilayah\ProvinsiResource;
|
||||||
|
|
||||||
|
class KabupatenKotaResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'nama' => $this->nama,
|
||||||
|
'kode' => $this->kode,
|
||||||
|
'provinsi' => $this->provinsi ? new ProvinsiResource($this->provinsi) : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources\Wilayah;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
use App\Http\Resources\Wilayah\KabupatenKotaResource;
|
||||||
|
|
||||||
|
class KecamatanResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'nama' => $this->nama,
|
||||||
|
'kode' => $this->kode,
|
||||||
|
'kabupatenKota' => $this->kabupatenKota ? new KabupatenKotaResource($this->kabupatenKota) : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources\Wilayah;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class ProvinsiResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'nama' => $this->nama,
|
||||||
|
'kode' => $this->kode,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,10 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use App\Models\Wilayah\User;
|
|
||||||
|
use App\Models\User;
|
||||||
use App\Models\Wilayah\DesaKelurahan;
|
use App\Models\Wilayah\DesaKelurahan;
|
||||||
|
|
||||||
class Profile extends Model
|
class Profile extends Model
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
@@ -31,7 +33,7 @@ class Profile extends Model
|
|||||||
'deleted_by'
|
'deleted_by'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function desakelurahan()
|
public function desaKelurahan()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(DesaKelurahan::class, 'desa_kelurahan_id');
|
return $this->belongsTo(DesaKelurahan::class, 'desa_kelurahan_id');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ class Kecamatan extends Model
|
|||||||
'kabupaten_kota_id',
|
'kabupaten_kota_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function kabupatenkota() {
|
public function kabupatenKota() {
|
||||||
return $this->belongsTo(KabupatenKota::class, 'kabupaten_kota_id');
|
return $this->belongsTo(KabupatenKota::class, 'kabupaten_kota_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function desakelurahan()
|
public function desaKelurahan()
|
||||||
{
|
{
|
||||||
return $this->hasMany(DesaKelurahan::class, 'kecamatan_id');
|
return $this->hasMany(DesaKelurahan::class, 'kecamatan_id');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ use App\Models\User;
|
|||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
|
|
||||||
|
use Dedoc\Scramble\Scramble;
|
||||||
|
use Dedoc\Scramble\Support\Generator\OpenApi;
|
||||||
|
use Dedoc\Scramble\Support\Generator\SecurityScheme;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -23,6 +27,13 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
|
Scramble::configure()
|
||||||
|
->withDocumentTransformers(function (OpenApi $openApi) {
|
||||||
|
$openApi->secure(
|
||||||
|
SecurityScheme::http('bearer')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
if (config('app.env') === 'production') {
|
if (config('app.env') === 'production') {
|
||||||
URL::forceScheme('https');
|
URL::forceScheme('https');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Laravel\Telescope\IncomingEntry;
|
||||||
|
use Laravel\Telescope\Telescope;
|
||||||
|
use Laravel\Telescope\TelescopeApplicationServiceProvider;
|
||||||
|
|
||||||
|
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
// Telescope::night();
|
||||||
|
|
||||||
|
$this->hideSensitiveRequestDetails();
|
||||||
|
|
||||||
|
$isLocal = $this->app->environment('local');
|
||||||
|
|
||||||
|
Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
|
||||||
|
return $isLocal ||
|
||||||
|
$entry->isReportableException() ||
|
||||||
|
$entry->isFailedRequest() ||
|
||||||
|
$entry->isFailedJob() ||
|
||||||
|
$entry->isScheduledTask() ||
|
||||||
|
$entry->hasMonitoredTag();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent sensitive request details from being logged by Telescope.
|
||||||
|
*/
|
||||||
|
protected function hideSensitiveRequestDetails(): void
|
||||||
|
{
|
||||||
|
if ($this->app->environment('local')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Telescope::hideRequestParameters(['_token']);
|
||||||
|
|
||||||
|
Telescope::hideRequestHeaders([
|
||||||
|
'cookie',
|
||||||
|
'x-csrf-token',
|
||||||
|
'x-xsrf-token',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the Telescope gate.
|
||||||
|
*
|
||||||
|
* This gate determines who can access Telescope in non-local environments.
|
||||||
|
*/
|
||||||
|
protected function gate(): void
|
||||||
|
{
|
||||||
|
Gate::define('viewTelescope', function (User $user) {
|
||||||
|
return in_array($user->email, [
|
||||||
|
//
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
App\Providers\AppServiceProvider::class,
|
App\Providers\AppServiceProvider::class,
|
||||||
|
App\Providers\TelescopeServiceProvider::class,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -10,8 +10,10 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
|
"dedoc/scramble": "^0.13.15",
|
||||||
"laravel/framework": "^12.0",
|
"laravel/framework": "^12.0",
|
||||||
"laravel/sanctum": "^4.0",
|
"laravel/sanctum": "^4.0",
|
||||||
|
"laravel/telescope": "^5.18",
|
||||||
"laravel/tinker": "^2.10.1"
|
"laravel/tinker": "^2.10.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|||||||
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Dedoc\Scramble\Http\Middleware\RestrictedDocsAccess;
|
||||||
|
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
* Your API path. By default, all routes starting with this path will be added to the docs.
|
||||||
|
* If you need to change this behavior, you can add your custom routes resolver using `Scramble::routes()`.
|
||||||
|
*/
|
||||||
|
'api_path' => 'api',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Your API domain. By default, app domain is used. This is also a part of the default API routes
|
||||||
|
* matcher, so when implementing your own, make sure you use this config if needed.
|
||||||
|
*/
|
||||||
|
'api_domain' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The path where your OpenAPI specification will be exported.
|
||||||
|
*/
|
||||||
|
'export_path' => 'api.json',
|
||||||
|
|
||||||
|
'info' => [
|
||||||
|
/*
|
||||||
|
* API version.
|
||||||
|
*/
|
||||||
|
'version' => env('API_VERSION', '0.0.1'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Description rendered on the home page of the API documentation (`/docs/api`).
|
||||||
|
*/
|
||||||
|
'description' => '',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Customize Stoplight Elements UI
|
||||||
|
*/
|
||||||
|
'ui' => [
|
||||||
|
/*
|
||||||
|
* Define the title of the documentation's website. App name is used when this config is `null`.
|
||||||
|
*/
|
||||||
|
'title' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define the theme of the documentation. Available options are `light`, `dark`, and `system`.
|
||||||
|
*/
|
||||||
|
'theme' => 'system',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hide the `Try It` feature. Enabled by default.
|
||||||
|
*/
|
||||||
|
'hide_try_it' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hide the schemas in the Table of Contents. Enabled by default.
|
||||||
|
*/
|
||||||
|
'hide_schemas' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* URL to an image that displays as a small square logo next to the title, above the table of contents.
|
||||||
|
*/
|
||||||
|
'logo' => '',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use to fetch the credential policy for the Try It feature. Options are: omit, include (default), and same-origin
|
||||||
|
*/
|
||||||
|
'try_it_credentials_policy' => 'include',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There are three layouts for Elements:
|
||||||
|
* - sidebar - (Elements default) Three-column design with a sidebar that can be resized.
|
||||||
|
* - responsive - Like sidebar, except at small screen sizes it collapses the sidebar into a drawer that can be toggled open.
|
||||||
|
* - stacked - Everything in a single column, making integrations with existing websites that have their own sidebar or other columns already.
|
||||||
|
*/
|
||||||
|
'layout' => 'responsive',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The list of servers of the API. By default, when `null`, server URL will be created from
|
||||||
|
* `scramble.api_path` and `scramble.api_domain` config variables. When providing an array, you
|
||||||
|
* will need to specify the local server URL manually (if needed).
|
||||||
|
*
|
||||||
|
* Example of non-default config (final URLs are generated using Laravel `url` helper):
|
||||||
|
*
|
||||||
|
* ```php
|
||||||
|
* 'servers' => [
|
||||||
|
* 'Live' => 'api',
|
||||||
|
* 'Prod' => 'https://scramble.dedoc.co/api',
|
||||||
|
* ],
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
'servers' => null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines how Scramble stores the descriptions of enum cases.
|
||||||
|
* Available options:
|
||||||
|
* - 'description' – Case descriptions are stored as the enum schema's description using table formatting.
|
||||||
|
* - 'extension' – Case descriptions are stored in the `x-enumDescriptions` enum schema extension.
|
||||||
|
*
|
||||||
|
* @see https://redocly.com/docs-legacy/api-reference-docs/specification-extensions/x-enum-descriptions
|
||||||
|
* - false - Case descriptions are ignored.
|
||||||
|
*/
|
||||||
|
'enum_cases_description_strategy' => 'description',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines how Scramble stores the names of enum cases.
|
||||||
|
* Available options:
|
||||||
|
* - 'names' – Case names are stored in the `x-enumNames` enum schema extension.
|
||||||
|
* - 'varnames' - Case names are stored in the `x-enum-varnames` enum schema extension.
|
||||||
|
* - false - Case names are not stored.
|
||||||
|
*/
|
||||||
|
'enum_cases_names_strategy' => false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When Scramble encounters deep objects in query parameters, it flattens the parameters so the generated
|
||||||
|
* OpenAPI document correctly describes the API. Flattening deep query parameters is relevant until
|
||||||
|
* OpenAPI 3.2 is released and query string structure can be described properly.
|
||||||
|
*
|
||||||
|
* For example, this nested validation rule describes the object with `bar` property:
|
||||||
|
* `['foo.bar' => ['required', 'int']]`.
|
||||||
|
*
|
||||||
|
* When `flatten_deep_query_parameters` is `true`, Scramble will document the parameter like so:
|
||||||
|
* `{"name":"foo[bar]", "schema":{"type":"int"}, "required":true}`.
|
||||||
|
*
|
||||||
|
* When `flatten_deep_query_parameters` is `false`, Scramble will document the parameter like so:
|
||||||
|
* `{"name":"foo", "schema": {"type":"object", "properties":{"bar":{"type": "int"}}, "required": ["bar"]}, "required":true}`.
|
||||||
|
*/
|
||||||
|
'flatten_deep_query_parameters' => true,
|
||||||
|
|
||||||
|
'middleware' => [
|
||||||
|
'web',
|
||||||
|
RestrictedDocsAccess::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'extensions' => [],
|
||||||
|
];
|
||||||
@@ -0,0 +1,212 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Laravel\Telescope\Http\Middleware\Authorize;
|
||||||
|
use Laravel\Telescope\Watchers;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Telescope Master Switch
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option may be used to disable all Telescope watchers regardless
|
||||||
|
| of their individual configuration, which simply provides a single
|
||||||
|
| and convenient way to enable or disable Telescope data storage.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'enabled' => env('TELESCOPE_ENABLED', true),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Telescope Domain
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This is the subdomain where Telescope will be accessible from. If the
|
||||||
|
| setting is null, Telescope will reside under the same domain as the
|
||||||
|
| application. Otherwise, this value will be used as the subdomain.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'domain' => env('TELESCOPE_DOMAIN'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Telescope Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This is the URI path where Telescope will be accessible from. Feel free
|
||||||
|
| to change this path to anything you like. Note that the URI will not
|
||||||
|
| affect the paths of its internal API that aren't exposed to users.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'path' => env('TELESCOPE_PATH', 'telescope'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Telescope Storage Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This configuration options determines the storage driver that will
|
||||||
|
| be used to store Telescope's data. In addition, you may set any
|
||||||
|
| custom options as needed by the particular driver you choose.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'driver' => env('TELESCOPE_DRIVER', 'database'),
|
||||||
|
|
||||||
|
'storage' => [
|
||||||
|
'database' => [
|
||||||
|
'connection' => env('DB_CONNECTION', 'mysql'),
|
||||||
|
'chunk' => 1000,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Telescope Queue
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This configuration options determines the queue connection and queue
|
||||||
|
| which will be used to process ProcessPendingUpdate jobs. This can
|
||||||
|
| be changed if you would prefer to use a non-default connection.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'queue' => [
|
||||||
|
'connection' => env('TELESCOPE_QUEUE_CONNECTION'),
|
||||||
|
'queue' => env('TELESCOPE_QUEUE'),
|
||||||
|
'delay' => env('TELESCOPE_QUEUE_DELAY', 10),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Telescope Route Middleware
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These middleware will be assigned to every Telescope route, giving you
|
||||||
|
| the chance to add your own middleware to this list or change any of
|
||||||
|
| the existing middleware. Or, you can simply stick with this list.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'middleware' => [
|
||||||
|
'web',
|
||||||
|
Authorize::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Allowed / Ignored Paths & Commands
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following array lists the URI paths and Artisan commands that will
|
||||||
|
| not be watched by Telescope. In addition to this list, some Laravel
|
||||||
|
| commands, like migrations and queue commands, are always ignored.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'only_paths' => [
|
||||||
|
// 'api/*'
|
||||||
|
],
|
||||||
|
|
||||||
|
'ignore_paths' => [
|
||||||
|
'livewire*',
|
||||||
|
'nova-api*',
|
||||||
|
'pulse*',
|
||||||
|
'_boost*',
|
||||||
|
'.well-known*',
|
||||||
|
],
|
||||||
|
|
||||||
|
'ignore_commands' => [
|
||||||
|
//
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Telescope Watchers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following array lists the "watchers" that will be registered with
|
||||||
|
| Telescope. The watchers gather the application's profile data when
|
||||||
|
| a request or task is executed. Feel free to customize this list.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'watchers' => [
|
||||||
|
Watchers\BatchWatcher::class => env('TELESCOPE_BATCH_WATCHER', true),
|
||||||
|
|
||||||
|
Watchers\CacheWatcher::class => [
|
||||||
|
'enabled' => env('TELESCOPE_CACHE_WATCHER', true),
|
||||||
|
'hidden' => [],
|
||||||
|
'ignore' => [],
|
||||||
|
],
|
||||||
|
|
||||||
|
Watchers\ClientRequestWatcher::class => [
|
||||||
|
'enabled' => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true),
|
||||||
|
'ignore_hosts' => [],
|
||||||
|
],
|
||||||
|
|
||||||
|
Watchers\CommandWatcher::class => [
|
||||||
|
'enabled' => env('TELESCOPE_COMMAND_WATCHER', true),
|
||||||
|
'ignore' => [],
|
||||||
|
],
|
||||||
|
|
||||||
|
Watchers\DumpWatcher::class => [
|
||||||
|
'enabled' => env('TELESCOPE_DUMP_WATCHER', true),
|
||||||
|
'always' => env('TELESCOPE_DUMP_WATCHER_ALWAYS', false),
|
||||||
|
],
|
||||||
|
|
||||||
|
Watchers\EventWatcher::class => [
|
||||||
|
'enabled' => env('TELESCOPE_EVENT_WATCHER', true),
|
||||||
|
'ignore' => [],
|
||||||
|
],
|
||||||
|
|
||||||
|
Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true),
|
||||||
|
|
||||||
|
Watchers\GateWatcher::class => [
|
||||||
|
'enabled' => env('TELESCOPE_GATE_WATCHER', true),
|
||||||
|
'ignore_abilities' => [],
|
||||||
|
'ignore_packages' => true,
|
||||||
|
'ignore_paths' => [],
|
||||||
|
],
|
||||||
|
|
||||||
|
Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
|
||||||
|
|
||||||
|
Watchers\LogWatcher::class => [
|
||||||
|
'enabled' => env('TELESCOPE_LOG_WATCHER', true),
|
||||||
|
'level' => 'error',
|
||||||
|
],
|
||||||
|
|
||||||
|
Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true),
|
||||||
|
|
||||||
|
Watchers\ModelWatcher::class => [
|
||||||
|
'enabled' => env('TELESCOPE_MODEL_WATCHER', true),
|
||||||
|
'events' => ['eloquent.*'],
|
||||||
|
'hydrations' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true),
|
||||||
|
|
||||||
|
Watchers\QueryWatcher::class => [
|
||||||
|
'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
|
||||||
|
'ignore_packages' => true,
|
||||||
|
'ignore_paths' => [],
|
||||||
|
'slow' => 100,
|
||||||
|
],
|
||||||
|
|
||||||
|
Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true),
|
||||||
|
|
||||||
|
Watchers\RequestWatcher::class => [
|
||||||
|
'enabled' => env('TELESCOPE_REQUEST_WATCHER', true),
|
||||||
|
'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64),
|
||||||
|
'ignore_http_methods' => [],
|
||||||
|
'ignore_status_codes' => [],
|
||||||
|
],
|
||||||
|
|
||||||
|
Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true),
|
||||||
|
Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true),
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return config('telescope.storage.database.connection');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$schema = Schema::connection($this->getConnection());
|
||||||
|
|
||||||
|
$schema->create('telescope_entries', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('sequence');
|
||||||
|
$table->uuid('uuid');
|
||||||
|
$table->uuid('batch_id');
|
||||||
|
$table->string('family_hash')->nullable();
|
||||||
|
$table->boolean('should_display_on_index')->default(true);
|
||||||
|
$table->string('type', 20);
|
||||||
|
$table->longText('content');
|
||||||
|
$table->dateTime('created_at')->nullable();
|
||||||
|
|
||||||
|
$table->unique('uuid');
|
||||||
|
$table->index('batch_id');
|
||||||
|
$table->index('family_hash');
|
||||||
|
$table->index('created_at');
|
||||||
|
$table->index(['type', 'should_display_on_index']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$schema->create('telescope_entries_tags', function (Blueprint $table) {
|
||||||
|
$table->uuid('entry_uuid');
|
||||||
|
$table->string('tag');
|
||||||
|
|
||||||
|
$table->primary(['entry_uuid', 'tag']);
|
||||||
|
$table->index('tag');
|
||||||
|
|
||||||
|
$table->foreign('entry_uuid')
|
||||||
|
->references('uuid')
|
||||||
|
->on('telescope_entries')
|
||||||
|
->cascadeOnDelete();
|
||||||
|
});
|
||||||
|
|
||||||
|
$schema->create('telescope_monitoring', function (Blueprint $table) {
|
||||||
|
$table->string('tag')->primary();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
$schema = Schema::connection($this->getConnection());
|
||||||
|
|
||||||
|
$schema->dropIfExists('telescope_entries_tags');
|
||||||
|
$schema->dropIfExists('telescope_entries');
|
||||||
|
$schema->dropIfExists('telescope_monitoring');
|
||||||
|
}
|
||||||
|
};
|
||||||
+4
-2
@@ -18,8 +18,10 @@ Route::middleware('auth:sanctum')
|
|||||||
Route::get('/me', [\App\Http\Controllers\Api\AuthController::class, 'me']);
|
Route::get('/me', [\App\Http\Controllers\Api\AuthController::class, 'me']);
|
||||||
Route::post('/logout', [\App\Http\Controllers\Api\AuthController::class, 'logout']);
|
Route::post('/logout', [\App\Http\Controllers\Api\AuthController::class, 'logout']);
|
||||||
|
|
||||||
Route::get('/profile', [\App\Http\Controllers\Api\ProfileController::class, 'show']);
|
// Route::get('/profile', [\App\Http\Controllers\Api\ProfileController::class, 'show']);
|
||||||
Route::put('/profile/{id}', [\App\Http\Controllers\Api\ProfileController::class, 'update']);
|
// Route::put('/profile/{id}', [\App\Http\Controllers\Api\ProfileController::class, 'update']);
|
||||||
|
Route::get('/profile/{id}/download/{type}', [\App\Http\Controllers\Api\ProfileController::class, 'downloadFile']);
|
||||||
|
Route::apiResource('/profile', \App\Http\Controllers\Api\ProfileController::class)->only(['show', 'update']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware('auth:sanctum')
|
Route::middleware('auth:sanctum')
|
||||||
|
|||||||
Reference in New Issue
Block a user