Skip to content

Commit 1710b2f

Browse files
committed
init commit
1 parent 13ba5c5 commit 1710b2f

File tree

118 files changed

+151334
-2
lines changed

Some content is hidden

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

118 files changed

+151334
-2
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+
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

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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_DISK=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="[email protected]"
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_HOST=
50+
PUSHER_PORT=443
51+
PUSHER_SCHEME=https
52+
PUSHER_APP_CLUSTER=mt1
53+
54+
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
55+
VITE_PUSHER_HOST="${PUSHER_HOST}"
56+
VITE_PUSHER_PORT="${PUSHER_PORT}"
57+
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
58+
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
11+
.styleci.yml export-ignore

.gitignore

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

README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
# elasticsearch-laravel-react
2-
How to integrate elastic search in laravel and how to work with elastic search DB inside laravel
1+
## About The Project
2+
3+
1. First you need to set .env and php 8.1 apache2 server for run this project
4+
2. Inside the terminal run => composer install
5+
3. Inside the terminal run => npm install && npm run dev ( npm run dev for react js compilation )
6+
Note : Please start your elastic search server and update the config host,port,username,password in config\elasticsearch.php file.
7+
- Also you need to add index inside elastic search before add entry inside elastic search. For that execute => php artisan elasticsearch:create-book-index
8+
4. Inside the terminal run => php artisan db:seed --class=BooksSeeder ( for fake data insert inside the DB. Every time you will get 15000 records during seed)
9+
Note : You don't need to add entries inside elastic search index because during model entry creation time automatically entry is created inside elastic search also.
10+
5. Inside the terminal run => php artisan serve ( for generate live url like => 127.0.0.1:8000 )
11+
6. You can see on the home page there is books listing with functionality of search records of book and with pagination api call
12+
7. Also for book full details you can click on Full Details button.
13+
8. On the Header there are two Links
14+
1. User Listing => For local user or public view of book store URL => (http://127.0.0.1:8000/)
15+
2. Admin Listing => For Admin user add/update/delete/list records. URL => (http://127.0.0.1:8000/allListing)
16+
17+
Note : React Js code is inside of Component folder in resources directory.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Elastic\Elasticsearch\ClientBuilder;
6+
use Illuminate\Console\Command;
7+
use Illuminate\Support\Facades\Config;
8+
9+
class CreateBookIndexCommand extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'elasticsearch:create-book-index';
17+
18+
private $client;
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Initial command for index old data of Book';
26+
27+
/**
28+
* Create a new command instance.
29+
*
30+
* @return void
31+
*/
32+
public function __construct(ClientBuilder $builder)
33+
{
34+
parent::__construct();
35+
36+
$this->client = $builder::fromConfig(
37+
Config::get('elasticsearch')
38+
);
39+
}
40+
41+
/**
42+
* Execute the console command.
43+
*
44+
* @return int
45+
*/
46+
public function handle()
47+
{
48+
$params = [
49+
'index' => 'books',
50+
'body' => [
51+
'mappings' => [
52+
'properties' => [
53+
'id' => [
54+
'type' => 'long',
55+
],
56+
'title' => [
57+
'type' => 'text',
58+
],
59+
'author' => [
60+
'type' => 'text',
61+
],
62+
'genre' => [
63+
'type' => 'text',
64+
],
65+
'description' => [
66+
'type' => 'text',
67+
],
68+
'isbn' => [
69+
'type' => 'long',
70+
],
71+
'published' => [
72+
'type' => 'date',
73+
],
74+
'publisher' => [
75+
'type' => 'text',
76+
]
77+
],
78+
],
79+
],
80+
];
81+
82+
$this->client->indices()->create($params);
83+
}
84+
}

app/Console/Kernel.php

+32
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/Exceptions/Handler.php

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
* @return void
43+
*/
44+
public function register()
45+
{
46+
$this->reportable(function (Throwable $e) {
47+
//
48+
});
49+
}
50+
}

0 commit comments

Comments
 (0)