Skip to content

Commit 808dcf5

Browse files
first commit
0 parents  commit 808dcf5

File tree

281 files changed

+89784
-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.

281 files changed

+89784
-0
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
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+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
11+
DB_CONNECTION=mysql
12+
DB_HOST=127.0.0.1
13+
DB_PORT=3306
14+
DB_DATABASE=laravel
15+
DB_USERNAME=root
16+
DB_PASSWORD=
17+
18+
BROADCAST_DRIVER=log
19+
CACHE_DRIVER=file
20+
FILESYSTEM_DRIVER=local
21+
QUEUE_CONNECTION=sync
22+
SESSION_DRIVER=file
23+
SESSION_LIFETIME=120
24+
25+
MEMCACHED_HOST=127.0.0.1
26+
27+
REDIS_HOST=127.0.0.1
28+
REDIS_PASSWORD=null
29+
REDIS_PORT=6379
30+
31+
MAIL_MAILER=smtp
32+
MAIL_HOST=mailhog
33+
MAIL_PORT=1025
34+
MAIL_USERNAME=null
35+
MAIL_PASSWORD=null
36+
MAIL_ENCRYPTION=null
37+
MAIL_FROM_ADDRESS=null
38+
MAIL_FROM_NAME="${APP_NAME}"
39+
40+
AWS_ACCESS_KEY_ID=
41+
AWS_SECRET_ACCESS_KEY=
42+
AWS_DEFAULT_REGION=us-east-1
43+
AWS_BUCKET=
44+
AWS_USE_PATH_STYLE_ENDPOINT=false
45+
46+
PUSHER_APP_ID=
47+
PUSHER_APP_KEY=
48+
PUSHER_APP_SECRET=
49+
PUSHER_APP_CLUSTER=mt1
50+
51+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
52+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
* text=auto
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

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
.env
7+
.env.backup
8+
.phpunit.result.cache
9+
docker-compose.override.yml
10+
Homestead.json
11+
Homestead.yaml
12+
npm-debug.log
13+
yarn-error.log
14+
/.idea
15+
/.vscode

.htaccess

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RewriteCond %{HTTP:Authorization} ^(.+)$
2+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

.styleci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
php:
2+
preset: laravel
3+
version: 8
4+
disabled:
5+
- no_unused_imports
6+
finder:
7+
not-name:
8+
- index.php
9+
- server.php
10+
js:
11+
finder:
12+
not-name:
13+
- webpack.mix.js
14+
css: true

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<h1 align="center">Laravel 8 Articles</h1>
2+
<p>Virtual Internship Experience (Investree) - Fullstack - Faqih Pratama Muhti</p>
3+
4+
## Author
5+
6+
Laravel 8 blog dibaut oleh :
7+
8+
- Github : <a href="https://github.com/programmerShinobi"> Faqih Pratama Muhti | programmerShinobi </a>
9+
10+
## Fitur
11+
12+
- Autentikasi JWT
13+
- CRUD REST-API (Categories & Posts)
14+
- Autentikasi Login
15+
- CRUD Categories
16+
- CRUD Posts
17+
18+
## User
19+
20+
**Admin**
21+
22+
- email: "matches the database in the users table"
23+
- Password: password
24+
25+
26+
## Run This Apps
27+
- Download the master branch in terminal
28+
> git clone https://github.com/programmerShinobi/task-5-fullstack.git
29+
- Install the composer dependencies in terminal
30+
> composer install
31+
- Make a file .env from .env.example and setting your config & create database name : articles_db
32+
> APP_URL=http://127.0.0.1:8000
33+
> ...
34+
> DB_CONNECTION=mysql
35+
> DB_HOST=127.0.0.1
36+
> DB_PORT=3306
37+
> DB_DATABASE=articles_db
38+
> DB_USERNAME=root
39+
> DB_PASSWORD=
40+
- Dont forget generate key from Laravel artisan in terminal
41+
> php artisan key:generate
42+
- Run composer update in terminal
43+
> composer update
44+
- Run Seed and faker in terminal
45+
> php artisan migrate:fresh --seed
46+
- Run passport in terminal
47+
> php artisan passport:install
48+
- Dont forget copy-paste the latest "Client ID" & "Client secret" to App/Http/Controllers/Api/Auth/LoginController.php
49+
> ...
50+
> 'client_id' => '...',
51+
> 'client_secret' => '...',
52+
> ...
53+
- Run serve in terminal
54+
> php artisan serve
55+
- Run apps in terminal
56+
> http://127.0.0.1:8000
57+
58+
59+
## If you have some suggestion ||~
60+
Just Contact Me At:
61+
- Email: [faqihpratamamuhti@gmail.com](mailto:faqihpratamamuhti@gmail.com)

app/Console/Kernel.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
14+
* @return void
15+
*/
16+
protected function schedule(Schedule $schedule)
17+
{
18+
// $schedule->command('inspire')->hourly();
19+
}
20+
21+
/**
22+
* Register the commands for the application.
23+
*
24+
* @return void
25+
*/
26+
protected function commands()
27+
{
28+
$this->load(__DIR__.'/Commands');
29+
30+
require base_path('routes/console.php');
31+
}
32+
}

app/DataTables/PostsDataTable.php

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
namespace App\DataTables;
4+
5+
use App\Models\Post;
6+
7+
use Yajra\DataTables\Html\Button;
8+
9+
use Yajra\DataTables\Html\Column;
10+
use Yajra\DataTables\Html\Editor\Editor;
11+
use Yajra\DataTables\Html\Editor\Fields;
12+
use Yajra\DataTables\Services\DataTable;
13+
14+
class PostsDataTable extends DataTable
15+
{
16+
/**
17+
* Build DataTable class.
18+
*
19+
* @param mixed $query Results from query() method.
20+
* @return \Yajra\DataTables\DataTableAbstract
21+
*/
22+
public function dataTable($query)
23+
{
24+
return datatables()
25+
->eloquent($query)
26+
->addColumn('action', 'postsdatatable.action');
27+
}
28+
29+
/**
30+
* Get query source of dataTable.
31+
*
32+
* @param \App\Models\PostsDataTable $model
33+
* @return \Illuminate\Database\Eloquent\Builder
34+
*/
35+
public function query(Post $model)
36+
{
37+
return $model->newQuery();
38+
}
39+
40+
/**
41+
* Optional method if you want to use html builder.
42+
*
43+
* @return \Yajra\DataTables\Html\Builder
44+
*/
45+
public function html()
46+
{
47+
return $this->builder()
48+
->setTableId('postsdatatable-table')
49+
->columns($this->getColumns())
50+
->minifiedAjax()
51+
->dom('Bfrtip')
52+
->orderBy(1)
53+
->buttons(
54+
Button::make('create'),
55+
Button::make('export'),
56+
Button::make('print'),
57+
Button::make('reset'),
58+
Button::make('reload')
59+
);
60+
}
61+
62+
/**
63+
* Get columns.
64+
*
65+
* @return array
66+
*/
67+
protected function getColumns()
68+
{
69+
return [
70+
Column::computed('action')
71+
->exportable(false)
72+
->printable(false)
73+
->width(60)
74+
->addClass('text-center'),
75+
Column::make('id'),
76+
Column::make('title'),
77+
Column::make('category_id'),
78+
Column::make('created_at'),
79+
Column::make('updated_at'),
80+
];
81+
}
82+
83+
/**
84+
* Get filename for export.
85+
*
86+
* @return string
87+
*/
88+
protected function filename()
89+
{
90+
return 'Posts_' . date('YmdHis');
91+
}
92+
}

app/Exceptions/Handler.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 the exception types that are not reported.
12+
*
13+
* @var array<int, class-string<Throwable>>
14+
*/
15+
protected $dontReport = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the inputs that are never flashed for validation exceptions.
21+
*
22+
* @var array<int, string>
23+
*/
24+
protected $dontFlash = [
25+
'current_password',
26+
'password',
27+
'password_confirmation',
28+
];
29+
30+
/**
31+
* Register the exception handling callbacks for the application.
32+
*
33+
* @return void
34+
*/
35+
public function register()
36+
{
37+
$this->reportable(function (Throwable $e) {
38+
//
39+
});
40+
}
41+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api\Auth;
4+
5+
use Illuminate\Support\Facades\Route;
6+
use App\Http\Controllers\Controller;
7+
use Illuminate\Http\Request;
8+
9+
class LoginController extends Controller
10+
{
11+
public function store(Request $request)
12+
{
13+
$request->validate([
14+
'username' => 'required|string',
15+
'password' => 'required|string',
16+
]);
17+
18+
$request->request->add([
19+
'grant_type' => 'password',
20+
'client_id' => 4,
21+
'client_secret' => 'I7kphD2DuTikXrkaqON2ilaZw1HhshHkAfLkYmBv',
22+
'username' => $request->username,
23+
'password' => $request->password,
24+
]);
25+
26+
$requestToken = Request::create(env('APP_URL') . '/oauth/token', 'post');
27+
return Route::dispatch($requestToken);
28+
}
29+
30+
public function destroy(Request $request)
31+
{
32+
$request->user()->token()->revoke();
33+
34+
return response()->noContent();
35+
}
36+
}

0 commit comments

Comments
 (0)