diff --git a/TODO.md b/TODO.md
index cb4fb3d..a383b78 100644
--- a/TODO.md
+++ b/TODO.md
@@ -2,12 +2,12 @@
### Admin
+- [x] CRUD Info
+- [ ] CRUD Banner
+- [ ] CRUD Rekening / Account
+- [ ] CRUD Customer
- [ ] CRUD Voucher
- [ ] Import Voucher
-- [ ] CRUD Customer
-- [ ] CRUD Rekening / Account
-- [ ] CRUD Info
-- [ ] CRUD Banner
- [ ] Deposit Menu (view daftar histori deposit)
- [ ] Manual Approve Deposit
- [ ] Setting Web (enable affilate, amount bonus affilate)
diff --git a/app/Http/Controllers/Customer/AuthController.php b/app/Http/Controllers/Customer/AuthController.php
index eb24631..21c8261 100644
--- a/app/Http/Controllers/Customer/AuthController.php
+++ b/app/Http/Controllers/Customer/AuthController.php
@@ -15,6 +15,17 @@ use SocialiteProviders\Manager\Config;
class AuthController extends Controller
{
+ private $config;
+
+ public function __construct()
+ {
+ $this->config = new Config(
+ env('GOOGLE_CLIENT_ID'),
+ env('GOOGLE_CLIENT_SECRET'),
+ route('customer.login.callback_google')
+ );
+ }
+
public function login()
{
return inertia('Home/Auth/Login');
@@ -38,27 +49,22 @@ class AuthController extends Controller
public function signin_google()
{
- $config = new Config(
- env('GOOGLE_CLIENT_ID'),
- env('GOOGLE_CLIENT_SECRET'),
- route('customer.login.callback_google')
- );
-
return Socialite::driver('google')
- ->setConfig($config)
+ ->setConfig($this->config)
->redirect();
}
public function callback_google()
{
- $config = new Config(
- env('GOOGLE_CLIENT_ID'),
- env('GOOGLE_CLIENT_SECRET'),
- route('customer.login.callback_google')
- );
- $user = Socialite::driver('google')
- ->setConfig($config)
- ->user();
+ try {
+ $user = Socialite::driver('google')
+ ->setConfig($this->config)
+ ->user();
+ } catch (\Exception $e) {
+ return redirect()->route('customer.login')
+ ->with('message', ['type' => 'error', 'message' => 'something went wrong']);
+ }
+
$customer = Customer::where('google_id', $user->id)->first();
if ($customer == null) {
DB::beginTransaction();
diff --git a/app/Http/Controllers/Customer/HomeController.php b/app/Http/Controllers/Customer/HomeController.php
index f51b472..10756c3 100644
--- a/app/Http/Controllers/Customer/HomeController.php
+++ b/app/Http/Controllers/Customer/HomeController.php
@@ -3,11 +3,16 @@
namespace App\Http\Controllers\Customer;
use App\Http\Controllers\Controller;
+use App\Models\Info;
class HomeController extends Controller
{
public function index()
{
- return inertia('Home/Index/Index');
+ $infos = Info::where('is_publish', 1)->orderBy('updated_at', 'desc')->get();
+
+ return inertia('Home/Index/Index', [
+ 'infos' => $infos,
+ ]);
}
}
diff --git a/app/Http/Controllers/Customer/ProfileController.php b/app/Http/Controllers/Customer/ProfileController.php
index 99e3966..704ba51 100644
--- a/app/Http/Controllers/Customer/ProfileController.php
+++ b/app/Http/Controllers/Customer/ProfileController.php
@@ -26,7 +26,7 @@ class ProfileController extends Controller
'name' => 'string|required',
'address' => 'string|required',
'phone' => 'string|required|numeric',
- 'username' => 'string|required|min:5|alpha_dash|unique:customers,username,' . $customer->id,
+ 'username' => 'string|required|min:5|alpha_dash|unique:customers,username,'.$customer->id,
'password' => 'nullable|string|min:8|confirmed',
'image' => 'nullable|image',
]);
@@ -48,7 +48,7 @@ class ProfileController extends Controller
'phone' => $request->phone,
'username' => $request->username,
'image' => $customer->image,
- 'password' => $customer->password
+ 'password' => $customer->password,
]);
redirect()->route('customer.profile.show')
diff --git a/app/Http/Controllers/InfoController.php b/app/Http/Controllers/InfoController.php
new file mode 100644
index 0000000..f13e6a0
--- /dev/null
+++ b/app/Http/Controllers/InfoController.php
@@ -0,0 +1,55 @@
+ $query,
+ ]);
+ }
+
+ public function store(Request $request)
+ {
+ $request->validate([
+ 'info' => 'required|string',
+ 'is_publish' => 'required|in:0,1',
+ ]);
+
+ Info::create([
+ 'title' => $request->info,
+ 'is_publish' => $request->is_publish,
+ ]);
+
+ session()->flash('message', ['type' => 'success', 'message' => 'Item has beed saved']);
+ }
+
+ public function update(Request $request, Info $info)
+ {
+ $request->validate([
+ 'info' => 'required|string',
+ 'is_publish' => 'required|in:0,1',
+ ]);
+
+ $info->update([
+ 'title' => $request->info,
+ 'is_publish' => $request->is_publish,
+ ]);
+
+ session()->flash('message', ['type' => 'success', 'message' => 'Item has beed updated']);
+ }
+
+ public function destroy(Info $info)
+ {
+ $info->delete();
+
+ session()->flash('message', ['type' => 'success', 'message' => 'Item has beed deleted']);
+ }
+}
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index 07492de..a826c51 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -14,7 +14,7 @@ class Authenticate extends Middleware
*/
protected function redirectTo($request)
{
- if (!$request->expectsJson()) {
+ if (! $request->expectsJson()) {
return route('customer.login');
}
}
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 6c85709..2143e73 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -2,7 +2,6 @@
namespace App\Models;
-
class Account extends Model
{
protected $fillable = [
diff --git a/app/Models/Customer.php b/app/Models/Customer.php
index 617528b..bf70725 100644
--- a/app/Models/Customer.php
+++ b/app/Models/Customer.php
@@ -29,12 +29,12 @@ class Customer extends Authenticatable
'identity_verified',
'identity_image',
'customer_level_id',
- 'google_oauth_response'
+ 'google_oauth_response',
];
protected $hidden = [
'password',
- 'google_oauth_reponse'
+ 'google_oauth_reponse',
];
protected $appends = [
@@ -49,6 +49,7 @@ class Customer extends Authenticatable
get: function () {
if ($this->google_id != null && $this->image == null) {
$user = json_decode($this->google_oauth_response);
+
return $user?->avatar;
}
@@ -61,7 +62,6 @@ class Customer extends Authenticatable
);
}
-
public function displayDeposit(): Attribute
{
return Attribute::make(get: function () {
@@ -69,7 +69,6 @@ class Customer extends Authenticatable
});
}
-
public function displayCoin(): Attribute
{
return Attribute::make(get: function () {
diff --git a/app/Models/DepositHistory.php b/app/Models/DepositHistory.php
index 0fbd67d..425c263 100644
--- a/app/Models/DepositHistory.php
+++ b/app/Models/DepositHistory.php
@@ -5,7 +5,9 @@ namespace App\Models;
class DepositHistory extends Model
{
const VALID = 0;
+
const WAIT = 1;
+
const INVALID = 2;
protected $fillable = [
@@ -16,6 +18,6 @@ class DepositHistory extends Model
'related_type',
'related_id',
'is_valid',
- 'image_prove'
+ 'image_prove',
];
}
diff --git a/app/Models/Info.php b/app/Models/Info.php
index cf7afc3..dd8d54c 100644
--- a/app/Models/Info.php
+++ b/app/Models/Info.php
@@ -2,11 +2,10 @@
namespace App\Models;
-use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Model;
-
class Info extends Model
{
+ const TYPE_URL = 'URL';
+
protected $fillable = [
'title',
'destination',
diff --git a/app/Models/Sale.php b/app/Models/Sale.php
index 585980c..0108872 100644
--- a/app/Models/Sale.php
+++ b/app/Models/Sale.php
@@ -5,8 +5,11 @@ namespace App\Models;
class Sale extends Model
{
const PAYED_WITH_MIDTRANS = 'midtrans';
+
const PAYED_WITH_MANUAL = 'manual';
+
const PAYED_WITH_DEPOSIT = 'deposit';
+
const PAYED_WITH_COIN = 'coin';
protected $fillable = [
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index e35f00b..89bd599 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -19,7 +19,7 @@ class EventServiceProvider extends ServiceProvider
SendEmailVerificationNotification::class,
],
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
- \SocialiteProviders\Google\GoogleExtendSocialite::class . '@handle',
+ \SocialiteProviders\Google\GoogleExtendSocialite::class.'@handle',
],
];
diff --git a/config/filesystems.php b/config/filesystems.php
index f676a1d..5b8c281 100644
--- a/config/filesystems.php
+++ b/config/filesystems.php
@@ -39,7 +39,7 @@ return [
'public' => [
'driver' => 'local',
'root' => base_path('public'),
- 'url' => env('APP_URL') . '/upload',
+ 'url' => env('APP_URL').'/upload',
'visibility' => 'public',
'throw' => false,
],
diff --git a/config/services.php b/config/services.php
index 7675b6a..adf0929 100644
--- a/config/services.php
+++ b/config/services.php
@@ -34,6 +34,6 @@ return [
'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
- 'redirect' => env('APP_URL') . '/login/callback_google',
+ 'redirect' => env('APP_URL').'/login/callback_google',
],
];
diff --git a/database/seeders/DummySeeder.php b/database/seeders/DummySeeder.php
index 96dceb3..7e028ae 100644
--- a/database/seeders/DummySeeder.php
+++ b/database/seeders/DummySeeder.php
@@ -2,6 +2,7 @@
namespace Database\Seeders;
+use App\Models\Info;
use Illuminate\Database\Seeder;
class DummySeeder extends Seeder
@@ -13,5 +14,14 @@ class DummySeeder extends Seeder
*/
public function run()
{
+ $this->info();
+ }
+
+ public function info()
+ {
+ Info::create([
+ 'title' => 'Welcome to our new site',
+ 'is_publish' => 1,
+ ]);
}
}
diff --git a/database/seeders/InstallationSeed.php b/database/seeders/InstallationSeed.php
index 8bf8e82..6d7ad00 100644
--- a/database/seeders/InstallationSeed.php
+++ b/database/seeders/InstallationSeed.php
@@ -27,7 +27,7 @@ class InstallationSeed extends Seeder
['key' => 'MIDTRANS_CLIENT_KEY', 'value' => 'SB-Mid-client-xqqkspzoZOM10iUG', 'type' => 'text'],
['key' => 'MIDTRANS_MERCHANT_ID', 'value' => 'G561244367', 'type' => 'text'],
- //
+ //
];
foreach ($settings as $setting) {
diff --git a/resources/js/Layouts/Partials/routes.js b/resources/js/Layouts/Partials/routes.js
index 53f09b7..c393f96 100644
--- a/resources/js/Layouts/Partials/routes.js
+++ b/resources/js/Layouts/Partials/routes.js
@@ -1,4 +1,5 @@
import { HiChartPie, HiUser, HiUsers, HiUserGroup } from 'react-icons/hi'
+import { HiQuestionMarkCircle } from 'react-icons/hi2'
export default [
{
@@ -9,6 +10,14 @@ export default [
active: 'dashboard',
permission: 'view-dashboard',
},
+ {
+ name: 'Info',
+ show: true,
+ icon: HiQuestionMarkCircle,
+ route: route('info.index'),
+ active: 'info.index',
+ permission: 'view-info',
+ },
{
name: 'User',
show: true,
diff --git a/resources/js/Pages/Home/Index/Index.jsx b/resources/js/Pages/Home/Index/Index.jsx
index 6dfc507..efdd939 100644
--- a/resources/js/Pages/Home/Index/Index.jsx
+++ b/resources/js/Pages/Home/Index/Index.jsx
@@ -29,12 +29,7 @@ const GuestBanner = () => {
)
}
-export default function Index({ status }) {
- const {
- props: {
- auth: { user },
- },
- } = usePage()
+export default function Index({ auth: { user }, infos }) {
return (
+ Info + | ++ Publish + | ++ |
---|---|---|
+ {info.title} + | ++ {info.is_publish === 1 + ? 'Yes' + : 'No'} + | +
+
+
+
+ Ubah
+
+
+
+
+ Hapus
+
+ |
+
+ | Name | -+ | Role | -+ | |
---|---|---|---|---|---|
+ {data.map((user) => ( + | |||||
{user.name} | - {user.role === null ? 'System' : user.role?.name} + {user.role === null + ? 'System' + : user.role?.name} |
- Ubah
+
+
+ Ubah
+
- Hapus
+
+
+ Hapus
+
|