Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions laravel-crud/public/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
10 changes: 10 additions & 0 deletions laravel-crud/public/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* text=auto

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
CHANGELOG.md export-ignore
15 changes: 15 additions & 0 deletions laravel-crud/public/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.idea
/.vscode
12 changes: 12 additions & 0 deletions laravel-crud/public/.styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
php:
preset: laravel
disabled:
- no_unused_imports
finder:
not-name:
- index.php
js:
finder:
not-name:
- vite.config.js
css: true
64 changes: 64 additions & 0 deletions laravel-crud/public/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<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"></a></p>

<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>

## 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.

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.

## 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 [Patreon page](https://patreon.com/taylorotwell).

### Premium Partners

- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**

## 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).
32 changes: 32 additions & 0 deletions laravel-crud/public/app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
50 changes: 50 additions & 0 deletions laravel-crud/public/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];

/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];

/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}
146 changes: 146 additions & 0 deletions laravel-crud/public/app/Http/Controllers/ApiController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Auth;

use App\Models\Crud;
use App\Models\User;

use Illuminate\Support\Facades\DB;

class ApiController extends Controller
{
public function getAllCRUDS()
{
$cruds = Crud::get()->toJson(JSON_PRETTY_PRINT);
return response($cruds, 200);
//endpoint GET http://127.0.0.1:8000/api/cruds';

}

public function createCRUD(Request $request)
{

$cruds = new Crud;
$cruds->username = $request->username;
$cruds->password = $request->password;
$cruds->save();

return response()
->json(["message" => "user created"], 201);

//endpoint POST http://127.0.0.1:8000/api/cruds/create

}

public function getCRUD($id)
{
if (Crud::where('id', $id)->exists())
{
$cruds = Crud::where('id', $id)->get()
->toJson(JSON_PRETTY_PRINT);
return response($cruds, 200);
//endpoint GET http://127.0.0.1:8000/api/cruds/[id]';

}
else
{
return response()->json(["message" => "record not found"], 404);
}
}

public function updateCRUD(Request $request, $id)
{
if (Crud::where('id', $id)->exists())
{
$cruds = Crud::find($id);
$cruds->username = is_null($request->username) ? $cruds->username : $request->username;
$cruds->password = is_null($request->password) ? $cruds->password : $request->password;
$cruds->save();

return response()
->json(["message" => "records updated successfully"], 200);
}
else
{
return response()
->json(["message" => "record not found"], 404);

}
//endpoint PUT http://127.0.0.1:8000/api/cruds/[id]

}

public function deleteCRUD($id)
{
if (Crud::where('id', $id)->exists())
{
$cruds = Crud::find($id);
$cruds->delete();

return response()
->json(["message" => "records deleted"], 202);
}
else
{
return response()
->json(["message" => "record not found"], 404);
}
//endpoint DELETE http://127.0.0.1:8000/api/cruds/id

}

public function authenticate(Request $request)
{

$userExists = DB::table('cruds')->where('username', '=', $request->input('username'))
->exists();

$password = DB::table('cruds')->where('password', '=', $request->input('password'))
->exists();

//echo $request->input('username');
//if($request->input('username') == "admin") {
//echo "admin";


//}
if ($request->input('username') == "admin" && $request->input('password') == "@admin")
{

return response()
->json(["message" => "success"], 200);

}
else
{

if ($userExists)
{

if ($password)
{
//echo "Success";
return response()->json(["message" => "success"], 201);
}
else
{
return response()
->json(["message" => "not found"], 404);
//echo "wrong username or password";

}
}
else
{
//echo "wrong username or password";
return response()
->json(["message" => "not found"], 404);
}

}
}

}
13 changes: 13 additions & 0 deletions laravel-crud/public/app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
Loading