Skip to content

Commit 4339948

Browse files
complete curd with authentication in laravel and graphql
0 parents  commit 4339948

Some content is hidden

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

73 files changed

+14517
-0
lines changed

.editorconfig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.env.example

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_TIMEZONE=UTC
6+
APP_URL=http://localhost
7+
8+
APP_LOCALE=en
9+
APP_FALLBACK_LOCALE=en
10+
APP_FAKER_LOCALE=en_US
11+
12+
APP_MAINTENANCE_DRIVER=file
13+
# APP_MAINTENANCE_STORE=database
14+
15+
PHP_CLI_SERVER_WORKERS=4
16+
17+
BCRYPT_ROUNDS=12
18+
19+
LOG_CHANNEL=stack
20+
LOG_STACK=single
21+
LOG_DEPRECATIONS_CHANNEL=null
22+
LOG_LEVEL=debug
23+
24+
DB_CONNECTION=sqlite
25+
# DB_HOST=127.0.0.1
26+
# DB_PORT=3306
27+
# DB_DATABASE=laravel
28+
# DB_USERNAME=root
29+
# DB_PASSWORD=
30+
31+
SESSION_DRIVER=database
32+
SESSION_LIFETIME=120
33+
SESSION_ENCRYPT=false
34+
SESSION_PATH=/
35+
SESSION_DOMAIN=null
36+
37+
BROADCAST_CONNECTION=log
38+
FILESYSTEM_DISK=local
39+
QUEUE_CONNECTION=database
40+
41+
CACHE_STORE=database
42+
CACHE_PREFIX=
43+
44+
MEMCACHED_HOST=127.0.0.1
45+
46+
REDIS_CLIENT=phpredis
47+
REDIS_HOST=127.0.0.1
48+
REDIS_PASSWORD=null
49+
REDIS_PORT=6379
50+
51+
MAIL_MAILER=log
52+
MAIL_SCHEME=null
53+
MAIL_HOST=127.0.0.1
54+
MAIL_PORT=2525
55+
MAIL_USERNAME=null
56+
MAIL_PASSWORD=null
57+
MAIL_FROM_ADDRESS="[email protected]"
58+
MAIL_FROM_NAME="${APP_NAME}"
59+
60+
AWS_ACCESS_KEY_ID=
61+
AWS_SECRET_ACCESS_KEY=
62+
AWS_DEFAULT_REGION=us-east-1
63+
AWS_BUCKET=
64+
AWS_USE_PATH_STYLE_ENDPOINT=false
65+
66+
VITE_APP_NAME="${APP_NAME}"

.gitattributes

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto eol=lf
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/.phpunit.cache
2+
/node_modules
3+
/public/build
4+
/public/hot
5+
/public/storage
6+
/storage/*.key
7+
/storage/pail
8+
/vendor
9+
.env
10+
.env.backup
11+
.env.production
12+
.phpactor.json
13+
.phpunit.result.cache
14+
Homestead.json
15+
Homestead.yaml
16+
auth.json
17+
npm-debug.log
18+
yarn-error.log
19+
/.fleet
20+
/.idea
21+
/.nova
22+
/.vscode
23+
/.zed

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 thousands of 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 Partners program](https://partners.laravel.com).
35+
36+
### Premium Partners
37+
38+
- **[Vehikl](https://vehikl.com/)**
39+
- **[Tighten Co.](https://tighten.co)**
40+
- **[WebReinvent](https://webreinvent.com/)**
41+
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
42+
- **[64 Robots](https://64robots.com)**
43+
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
44+
- **[Cyber-Duck](https://cyber-duck.co.uk)**
45+
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
46+
- **[Jump24](https://jump24.co.uk)**
47+
- **[Redberry](https://redberry.international/laravel/)**
48+
- **[Active Logic](https://activelogic.com)**
49+
- **[byte5](https://byte5.de)**
50+
- **[OP.GG](https://op.gg)**
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).

_lighthouse_ide_helper.php

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?php declare(strict_types=1);
2+
3+
# File generated by "php artisan lighthouse:ide-helper".
4+
# Do not edit this file directly.
5+
# This file should be ignored by git as it can be autogenerated.
6+
7+
namespace Illuminate\Testing;
8+
9+
use Mockery\MockInterface;
10+
use Nuwave\Lighthouse\Subscriptions\Contracts\Broadcaster;
11+
use PHPUnit\Framework\TestCase;
12+
13+
class TestResponse
14+
{
15+
/**
16+
* Assert the response contains an error with a matching message.
17+
*
18+
* @param \Throwable $error the expected error
19+
*
20+
* @return $this
21+
*/
22+
public function assertGraphQLError(\Throwable $error): self
23+
{
24+
return $this;
25+
}
26+
27+
/**
28+
* Assert the response contains an error with the given message.
29+
*
30+
* @param string $message the expected error message
31+
*
32+
* @return $this
33+
*/
34+
public function assertGraphQLErrorMessage(string $message): self
35+
{
36+
return $this;
37+
}
38+
39+
/**
40+
* Assert the response contains an error with the given debug message.
41+
*
42+
* Requires the config `lighthouse.debug` to include the option \GraphQL\Error\DebugFlag::INCLUDE_DEBUG_MESSAGE.
43+
*
44+
* @param string $message the expected debug message
45+
*
46+
* @return $this
47+
*/
48+
public function assertGraphQLDebugMessage(string $message): self
49+
{
50+
return $this;
51+
}
52+
53+
/**
54+
* Assert the response contains no errors.
55+
*
56+
* @return $this
57+
*/
58+
public function assertGraphQLErrorFree(): self
59+
{
60+
return $this;
61+
}
62+
63+
/**
64+
* Assert the returned result contains exactly the given validation keys.
65+
*
66+
* @param array<string> $keys the validation keys the result should have
67+
*
68+
* @return $this
69+
*/
70+
public function assertGraphQLValidationKeys(array $keys): self
71+
{
72+
return $this;
73+
}
74+
75+
/**
76+
* Assert a given validation error is present in the response.
77+
*
78+
* @param string $key the validation key that should be present
79+
* @param string $message the expected validation message
80+
*
81+
* @return $this
82+
*/
83+
public function assertGraphQLValidationError(string $key, string $message): self
84+
{
85+
return $this;
86+
}
87+
88+
/**
89+
* Assert no validation errors are present in the response.
90+
*
91+
* @return $this
92+
*/
93+
public function assertGraphQLValidationPasses(): self
94+
{
95+
return $this;
96+
}
97+
98+
/**
99+
* Assert current user is authorized to join a subscription.
100+
*
101+
* @param TestCase $testClassInstance usually $this when calling this from a test class
102+
*
103+
* @return $this
104+
*/
105+
public function assertGraphQLSubscriptionAuthorized(TestCase $testClassInstance): self
106+
{
107+
return $this;
108+
}
109+
110+
/**
111+
* Assert current user is NOT authorized to join a subscription.
112+
*
113+
* @param TestCase $testClassInstance usually $this when calling this from a test class
114+
*
115+
* @return $this
116+
*/
117+
public function assertGraphQLSubscriptionNotAuthorized(TestCase $testClassInstance): self
118+
{
119+
return $this;
120+
}
121+
122+
/**
123+
* For cases where you need more control over your broadcast assertions.
124+
*
125+
* @see \Nuwave\Lighthouse\Testing\TestResponseMixin::assertGraphQLBroadcasted
126+
* @see \Nuwave\Lighthouse\Testing\TestResponseMixin::assertGraphQLNotBroadcasted
127+
*
128+
* @return \Mockery\MockInterface&\Nuwave\Lighthouse\Subscriptions\Contracts\Broadcaster
129+
*/
130+
public function graphQLSubscriptionMock() // @phpstan-ignore-line invalid return type?
131+
{
132+
$mock = \Mockery::mock(Broadcaster::class);
133+
assert($mock instanceof Broadcaster && $mock instanceof MockInterface);
134+
135+
return $mock;
136+
}
137+
138+
/** Get the channel name from a subscription query. */
139+
public function graphQLSubscriptionChannelName(): string
140+
{
141+
return '';
142+
}
143+
144+
/**
145+
* Assert the subscription received the given broadcasts.
146+
*
147+
* @param array<int, array<string, mixed>> $data the broadcast pattern that you are expecting
148+
*
149+
* @return $this
150+
*/
151+
public function assertGraphQLBroadcasted(array $data): self
152+
{
153+
return $this;
154+
}
155+
156+
/**
157+
* Assert the subscription received no broadcast.
158+
*
159+
* @return $this
160+
*/
161+
public function assertGraphQLNotBroadcasted(): self
162+
{
163+
return $this;
164+
}
165+
}
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace App\GraphQL\Mutations;
4+
5+
use App\Models\Category;
6+
use Illuminate\Support\Facades\Validator;
7+
8+
final readonly class CreateCategories
9+
{
10+
/** @param array{} $args */
11+
public function __invoke(null $_, array $args)
12+
{
13+
$validator = Validator::make($args['input'], [
14+
'name' => ['required', 'string', 'unique:categories,name']
15+
]);
16+
17+
if ($validator->fails()) {
18+
return [
19+
'success' => false,
20+
'messages' => $validator->errors()->all(),
21+
'data' => null
22+
];
23+
}
24+
25+
Category::create([
26+
'name' => $args['input']['name']
27+
]);
28+
29+
return [
30+
'success' => true,
31+
'messages' => ['Category create successfully'],
32+
'category' => null,
33+
];
34+
}
35+
}

0 commit comments

Comments
 (0)