Skip to content

Commit 6184673

Browse files
laravel add project
0 parents  commit 6184673

File tree

92 files changed

+12520
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+12520
-0
lines changed

.DS_Store

10 KB
Binary file not shown.

README.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
2+
3+
<p align="center">
4+
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
5+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
6+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
7+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
8+
</p>
9+
10+
## About Laravel
11+
12+
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
13+
14+
- [Simple, fast routing engine](https://laravel.com/docs/routing).
15+
- [Powerful dependency injection container](https://laravel.com/docs/container).
16+
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
17+
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
18+
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
19+
- [Robust background job processing](https://laravel.com/docs/queues).
20+
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
21+
22+
Laravel is accessible, powerful, and provides tools required for large, robust applications.
23+
24+
## Learning Laravel
25+
26+
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
27+
28+
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
29+
30+
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
31+
32+
## Laravel Sponsors
33+
34+
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
35+
36+
### Premium Partners
37+
38+
- **[Vehikl](https://vehikl.com/)**
39+
- **[Tighten Co.](https://tighten.co)**
40+
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
41+
- **[64 Robots](https://64robots.com)**
42+
- **[Cubet Techno Labs](https://cubettech.com)**
43+
- **[Cyber-Duck](https://cyber-duck.co.uk)**
44+
- **[Many](https://www.many.co.uk)**
45+
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
46+
- **[DevSquad](https://devsquad.com)**
47+
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
48+
- **[OP.GG](https://op.gg)**
49+
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
50+
- **[Lendio](https://lendio.com)**
51+
52+
## Contributing
53+
54+
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
55+
56+
## Code of Conduct
57+
58+
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
59+
60+
## Security Vulnerabilities
61+
62+
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.
63+
64+
## License
65+
66+
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

app/Console/Kernel.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* Define the application's command schedule.
12+
*/
13+
protected function schedule(Schedule $schedule): void
14+
{
15+
// $schedule->command('inspire')->hourly();
16+
}
17+
18+
/**
19+
* Register the commands for the application.
20+
*/
21+
protected function commands(): void
22+
{
23+
$this->load(__DIR__.'/Commands');
24+
25+
require base_path('routes/console.php');
26+
}
27+
}

app/Exceptions/Handler.php

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* A list of exception types with their corresponding custom log levels.
12+
*
13+
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
14+
*/
15+
protected $levels = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the exception types that are not reported.
21+
*
22+
* @var array<int, class-string<\Throwable>>
23+
*/
24+
protected $dontReport = [
25+
//
26+
];
27+
28+
/**
29+
* A list of the inputs that are never flashed to the session on validation exceptions.
30+
*
31+
* @var array<int, string>
32+
*/
33+
protected $dontFlash = [
34+
'current_password',
35+
'password',
36+
'password_confirmation',
37+
];
38+
39+
/**
40+
* Register the exception handling callbacks for the application.
41+
*/
42+
public function register(): void
43+
{
44+
$this->reportable(function (Throwable $e) {
45+
//
46+
});
47+
}
48+
}

app/Http/Controllers/Controller.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
6+
use Illuminate\Foundation\Validation\ValidatesRequests;
7+
use Illuminate\Routing\Controller as BaseController;
8+
9+
class Controller extends BaseController
10+
{
11+
use AuthorizesRequests, ValidatesRequests;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\LoginSystem;
4+
5+
use App\Models\User;
6+
use Illuminate\Http\Request;
7+
use App\Jobs\SendEmailVerifyJob;
8+
use Illuminate\Support\Facades\URL;
9+
use App\Http\Controllers\Controller;
10+
use Illuminate\Support\Facades\Hash;
11+
use Illuminate\Support\Facades\Validator;
12+
13+
class AuthController extends Controller
14+
{
15+
public function register(Request $request){
16+
$validate = Validator::make($request->all(), [
17+
'name' => 'required|string|max:255',
18+
'email' => 'required|string|email|max:255|unique:users',
19+
'password' => 'required|string|confirmed|min:6',
20+
]);
21+
if ($validate->fails()) {
22+
return response()->json([
23+
'error'=>true,
24+
'message'=>$validate->errors()
25+
]);
26+
}
27+
$users = User::create([
28+
'name' => $request->name,
29+
'email' => $request->email,
30+
'role' => 'user',
31+
'password' => Hash::make($request->password),
32+
]);
33+
34+
$verification = URL::temporarySignedRoute(
35+
'verification.verify',
36+
now()->addMinutes(60),
37+
['id' => $users->id, 'hash' => sha1($users->getEmailForVerification())]
38+
);
39+
40+
$SendEmailVerifyJob = new SendEmailVerifyJob($users, $verification);
41+
dispatch($SendEmailVerifyJob);
42+
43+
return response()->json([
44+
'Massage' => 'userCreatedSuccessfully',
45+
'user' => $users
46+
]);
47+
}
48+
49+
50+
51+
public function registerAdmin(Request $request){
52+
$validate = Validator::make($request->all(), [
53+
'name' => 'required|string|max:255',
54+
'email' => 'required|string|max:255|unique:users,email',
55+
'password' => 'required|string|confirmed|min:6',
56+
]);
57+
58+
if ($validate->fails()) {
59+
return response()->json([
60+
'error'=>true,
61+
'message'=>$validate->errors()
62+
]);
63+
}
64+
$users = User::create([
65+
'name' => $request->name,
66+
'email' => $request->email,
67+
'password' => Hash::make($request->password),
68+
'role' => 'admin'
69+
70+
]);
71+
72+
$verification = URL::temporarySignedRoute(
73+
'verification.verify',
74+
now()->addMinutes(60),
75+
['id' => $users->id, 'hash' => sha1($users->getEmailForVerification())]
76+
);
77+
78+
$SendEmailVerifyJob = new SendEmailVerifyJob($users, $verification);
79+
dispatch($SendEmailVerifyJob);
80+
81+
return response()->json([
82+
'Massage' => 'userCreatedSuccessfully',
83+
]);
84+
}
85+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\LoginSystem;
4+
5+
use App\Models\User;
6+
use App\Jobs\SendOtpJob;
7+
use Illuminate\Support\Str;
8+
use Illuminate\Http\Request;
9+
use App\Http\Controllers\Controller;
10+
use Illuminate\Support\Facades\Hash;
11+
use Illuminate\Support\Facades\Validator;
12+
13+
class AuthMobileController extends Controller
14+
{
15+
16+
public function registerMobile(Request $request){
17+
$validator = Validator::make($request->all(), [
18+
'name' => 'required|string',
19+
'email' => 'required|unique:users,email',
20+
'password' => 'required|confirmed|min:6'
21+
]);
22+
23+
if ($validator->fails()) {
24+
return response()->json([
25+
'message' => 'Validation Fails',
26+
'errors' => $validator->errors()
27+
]);
28+
}
29+
30+
$verificationOtp = Str::random(1000, 9999);
31+
$users = new User();
32+
$users->name = $request->name;
33+
$users->email = $request->email;
34+
$users->otp_code = $verificationOtp;
35+
$users->password = Hash::make($request->password);
36+
$users->role = 'user';
37+
$users->save();
38+
39+
$SendEmailVerifyJob = new SendOtpJob($users, $verificationOtp);
40+
dispatch($SendEmailVerifyJob);
41+
42+
return response()->json([
43+
'Massage' => 'userCreatedSuccessfully',
44+
]);
45+
}
46+
47+
public function regiseterMobileAdmin(Request $request){
48+
$validator = Validator::make($request->all(), [
49+
'name' => 'required|string',
50+
'email' => 'required|unique:users,email',
51+
'password' => 'required|confirmed|min:6'
52+
]);
53+
54+
if ($validator->fails()) {
55+
return response()->json([
56+
'message' => 'Validation Fails',
57+
'errors' => $validator->errors()
58+
]);
59+
}
60+
61+
$verificationOtp = Str::random(1000, 9999);
62+
$users = new User();
63+
$users->name = $request->name;
64+
$users->email = $request->email;
65+
$users->otp_code = $verificationOtp;
66+
$users->password = Hash::make($request->password);
67+
$users->role = 'admin';
68+
$users->save();
69+
70+
$SendEmailVerifyJob = new SendOtpJob($users, $verificationOtp);
71+
dispatch($SendEmailVerifyJob);
72+
73+
return response()->json([
74+
'Massage' => 'userCreatedSuccessfully',
75+
]);
76+
}
77+
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\LoginSystem;
4+
5+
use Illuminate\Http\Request;
6+
use App\Http\Controllers\Controller;
7+
use Illuminate\Support\Facades\Auth;
8+
9+
class LoginController extends Controller
10+
{
11+
public function login(Request $request)
12+
{
13+
$credentials = $request->only('email', 'password');
14+
15+
// Coba otentikasi sebagai pengguna
16+
if (Auth::attempt($credentials)) {
17+
// Otentikasi pengguna berhasil
18+
$user = Auth::user();
19+
20+
// Periksa status verifikasi email
21+
if ($user->email_verified_at) {
22+
if ($user->role === 'admin') {
23+
$token = $user->createToken('AdminToken')->accessToken;
24+
return response()->json(['token' => $token, 'role' => 'admin'], 200);
25+
} else {
26+
$token = $user->createToken('UserToken')->accessToken;
27+
return response()->json(['token' => $token, 'role' => 'user'], 200);
28+
}
29+
} else {
30+
Auth::logout();
31+
return response()->json(['message' => 'Email not verified, Please Verify Your Email'], 401);
32+
}
33+
}
34+
35+
// Otentikasi gagal
36+
return response()->json(['message' => 'Email or password is incorrect.'], 401);
37+
}
38+
39+
public function logout(Request $request)
40+
{
41+
$request->user()->tokens()->delete();
42+
return response()->json(
43+
[
44+
'message' => 'Logged out'
45+
]
46+
);
47+
}
48+
}

0 commit comments

Comments
 (0)