diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8f0de65 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 + +[docker-compose.yml] +indent_size = 4 diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..11c8600 --- /dev/null +++ b/.env.example @@ -0,0 +1,48 @@ +APP_NAME=Laravel +APP_ENV=local +APP_KEY= +APP_DEBUG=true +APP_URL=http://localhost + +LOG_CHANNEL=stack +LOG_DEPRECATIONS_CHANNEL=null +LOG_LEVEL=debug + +DB_CONNECTION=sqlite + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +FILESYSTEM_DISK=local +QUEUE_CONNECTION=sync +SESSION_DRIVER=file +SESSION_LIFETIME=120 + +MEMCACHED_HOST=127.0.0.1 + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_MAILER=log +MAIL_FROM_NAME="${APP_NAME}" + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= +AWS_USE_PATH_STYLE_ENDPOINT=false + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_HOST= +PUSHER_PORT=443 +PUSHER_SCHEME=https +PUSHER_APP_CLUSTER=mt1 + +VITE_APP_NAME="${APP_NAME}" +VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +VITE_PUSHER_HOST="${PUSHER_HOST}" +VITE_PUSHER_PORT="${PUSHER_PORT}" +VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" +VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fcb21d3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +* text=auto eol=lf + +*.blade.php diff=html +*.css diff=css +*.html diff=html +*.md diff=markdown +*.php diff=php + +/.github export-ignore +CHANGELOG.md export-ignore +.styleci.yml export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7fe978f --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +/.phpunit.cache +/node_modules +/public/build +/public/hot +/public/storage +/storage/*.key +/vendor +.env +.env.backup +.env.production +.phpunit.result.cache +Homestead.json +Homestead.yaml +auth.json +npm-debug.log +yarn-error.log +/.fleet +/.idea +/.vscode diff --git a/README.md b/README.md new file mode 100644 index 0000000..1a4c26b --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +
+ + + +## About Laravel + +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: + +- [Simple, fast routing engine](https://laravel.com/docs/routing). +- [Powerful dependency injection container](https://laravel.com/docs/container). +- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. +- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). +- Database agnostic [schema migrations](https://laravel.com/docs/migrations). +- [Robust background job processing](https://laravel.com/docs/queues). +- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). + +Laravel is accessible, powerful, and provides tools required for large, robust applications. + +## Learning Laravel + +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. + +You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. + +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. + +## Laravel Sponsors + +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). + +### Premium Partners + +- **[Vehikl](https://vehikl.com/)** +- **[Tighten Co.](https://tighten.co)** +- **[WebReinvent](https://webreinvent.com/)** +- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** +- **[64 Robots](https://64robots.com)** +- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** +- **[Cyber-Duck](https://cyber-duck.co.uk)** +- **[DevSquad](https://devsquad.com/hire-laravel-developers)** +- **[Jump24](https://jump24.co.uk)** +- **[Redberry](https://redberry.international/laravel/)** +- **[Active Logic](https://activelogic.com)** +- **[byte5](https://byte5.de)** +- **[OP.GG](https://op.gg)** + +## Contributing + +Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). + +## Code of Conduct + +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). + +## Security Vulnerabilities + +If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. + +## License + +The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php new file mode 100644 index 0000000..e6b9960 --- /dev/null +++ b/app/Console/Kernel.php @@ -0,0 +1,27 @@ +command('inspire')->hourly(); + } + + /** + * Register the commands for the application. + */ + protected function commands(): void + { + $this->load(__DIR__.'/Commands'); + + require base_path('routes/console.php'); + } +} diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php new file mode 100644 index 0000000..56af264 --- /dev/null +++ b/app/Exceptions/Handler.php @@ -0,0 +1,30 @@ + + */ + protected $dontFlash = [ + 'current_password', + 'password', + 'password_confirmation', + ]; + + /** + * Register the exception handling callbacks for the application. + */ + public function register(): void + { + $this->reportable(function (Throwable $e) { + // + }); + } +} diff --git a/app/Http/Controllers/BlogController.php b/app/Http/Controllers/BlogController.php new file mode 100644 index 0000000..26b0a91 --- /dev/null +++ b/app/Http/Controllers/BlogController.php @@ -0,0 +1,100 @@ + Blog::mostViewed() + ]); + } + + public function list() + { + return view('blog.list', [ + 'blogs' => Blog::mostRecent() + ]); + } + + public function single($id) + { + $blog = Blog::find($id); + if (!$blog) return response('', 404); + $blog->views += 1; + $blog->save(); + return view('blog.single', [ + 'blog' => $blog + ]); + } + + public function like($id) + { + $blog = Blog::find($id); + try { + $blog->likes()->attach(request()->user()->id); + } catch(QueryException $e) { + return response('', 400); + } + + return response('', 200); + } + + public function create() + { + return view('blog.create'); + } + + public function insert() + { + request()->validate([ + 'title' => 'required', + ]); + + $id = request()->user()->id; + $blog = Blog::create([ + 'title' => request('title'), + 'containt' => request('containt'), + 'epilog' => request('epilog'), + 'user_id' => $id, + ]); + + return redirect('/blog/' . $blog->id); + } + + public function delete($id) + { + $blog = Blog::find($id); + if (!$blog) return response('', 404); + if (request()->user()->id != $blog->user->id) return response('', 401); + $blog->delete(); + return response('', 200); + } + + public function update($id) + { + request()->validate([ + 'title' => 'required', + ]); + + $blog = Blog::find($id); + + if (!$blog) return response('', 404); + if (request()->user()->id != $blog->user->id) return response('', 401); + + $blog->title = request('title'); + $blog->containt = request('containt'); + $blog->epilog = request('epilog'); + $blog->save(); + + return response('', 200); + } +} diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php new file mode 100644 index 0000000..77ec359 --- /dev/null +++ b/app/Http/Controllers/Controller.php @@ -0,0 +1,12 @@ +validate([ + 'email' => 'required|email', + 'password' => 'required|min:4|max:20', + ]); + + if (auth()->attempt([ + 'email' => request('email'), + 'password' => request('password') + ])) { + return redirect()->intended('/'); + } + + return back()->withErrors([ + 'email' => 'The provided credentials do not match our records.', + ]); + } + + public function logout() + { + auth()->logout(); + return redirect('/login'); + } +} diff --git a/app/Http/Controllers/RegisterController.php b/app/Http/Controllers/RegisterController.php new file mode 100644 index 0000000..a093097 --- /dev/null +++ b/app/Http/Controllers/RegisterController.php @@ -0,0 +1,56 @@ +validate([ + 'username' => 'required|unique:users', + 'email' => 'required|email|unique:users', + 'password' => 'required|min:4|max:20', + ]); + + $user = User::create([ + 'username' => request('username'), + 'name' => request('name'), + 'email' => request('email'), + 'description' => request('description'), + 'password' => request('password'), + ]); + + event(new Registered($user)); + + Auth::login($user); + return redirect('/email/verify'); + } + + public function verifyEmail() + { + return view('auth.verify_email'); + } + + public function emailVerification(EmailVerificationRequest $request) + { + $request->fulfill(); + return redirect('/'); + } + + public function sendEmailVerification() + { + request()->user()->sendEmailVerificationNotification(); + return back()->withErrors([ 'messages' => 'Verification link sent!' ]); + } +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100644 index 0000000..61b3114 --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,62 @@ + $user + ]); + } + + public function myProfile() + { + return redirect('/profile/' . request()->user()->id); + } + + public function delete($id) + { + $user = User::find($id); + if (!$user) return response('', 404); + if (request()->user()->id != $user->id) return response('', 401); + $user->delete(); + return response('', 200); + } + + public function update($id) + { + request()->validate([ + 'username' => 'required', + ]); + $user = User::find($id); + if (!$user) return response('', 404); + if (request()->user()->id != $user->id) return response('', 401); + $user->username = request('username'); + $user->name = request('name'); + $user->description = request('description'); + $user->save(); + return response('', 200); + } + + public function follow($id) + { + $user = User::find($id); + if (!$user) return response('', 404); + if (request()->user()->id == $user->id) return response('', 400); + try { + $user->followed()->attach(request()->user()->id); + } catch(QueryException $e) { + return response($e, 400); + } + return response('', 200); + } +} + diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php new file mode 100644 index 0000000..494c050 --- /dev/null +++ b/app/Http/Kernel.php @@ -0,0 +1,68 @@ + + */ + protected $middleware = [ + // \App\Http\Middleware\TrustHosts::class, + \App\Http\Middleware\TrustProxies::class, + \Illuminate\Http\Middleware\HandleCors::class, + \App\Http\Middleware\PreventRequestsDuringMaintenance::class, + \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, + \App\Http\Middleware\TrimStrings::class, + \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, + ]; + + /** + * The application's route middleware groups. + * + * @var array{{ $blog->epilog }}
+Views : {{ $blog->views }}
+Likes : {{ $blog->likes()->count() }}
+ @if($blog->containt) +{{ $blog->views }}
+{{ $blog->likes()->count() }}
+{{ $blog->epilog }}
+{{ $error }}
+ @endforeach +Name : {{ $user->name }}
+Description {{ $user->description }}
+Contact : {{ $user->email }}
+Number of followers : {{ $user->followed->count() }}
+ @if(request()->user() && $user->id == request()->user()->id) + + + @include('user.modal_update') +{{ $follow->username }}
+ @endforeach +