Skip to content

Commit 94cf02f

Browse files
committed
initial commit
0 parents  commit 94cf02f

File tree

95 files changed

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

95 files changed

+13015
-0
lines changed

README.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<p align="center">
2+
<img src="https://github.com/beyondscript/Laravel-Eloquent-ORM/blob/main/public/images/icons/favicon.webp" width="60" height="60" margin-left="auto" margin-right="auto" alt="Logo">
3+
<br>
4+
Laravel Eloquent ORM
5+
</p>
6+
7+
## About Laravel Eloquent ORM
8+
9+
Laravel Eloquent ORM is a web application which was designed by using HTML, CSS and JavaScript and developed by using PHP and Laravel framework.
10+
11+
This website was built for learning Laravel Eloquent ORM.
12+
13+
## How to use?
14+
15+
<strong>Step - 1:</strong>
16+
<br>
17+
Download or clone the repository
18+
19+
<strong>Step - 2:</strong>
20+
<br>
21+
Intall all the dependencies by running these commands "composer update" and "npm install"
22+
23+
<strong>Step - 3:</strong>
24+
<br>
25+
Copy the .env.example file from root directory to root directory then rename the copied file to .env
26+
27+
<strong>Step - 4:</strong>
28+
<br>
29+
Generate new application key by running the command "php artisan key:generate"
30+
31+
<strong>Step - 5:</strong>
32+
<br>
33+
Create a new database and import the laraveleloquentorm.sql file
34+
35+
<strong>Step - 6:</strong>
36+
<br>
37+
Add the database details in the .env file by editing the .env file like below:
38+
39+
DB_DATABASE=database_name
40+
<br>
41+
DB_USERNAME=database_user_name
42+
<br>
43+
DB_PASSWORD=database_user_password
44+
45+
<strong>Step - 7:</strong>
46+
<br>
47+
Add the application name in the .env file by editing the .env file like below:
48+
49+
APP_NAME="your_app_name"
50+
51+
<strong>Step - 8:</strong>
52+
<br>
53+
Add the application url in the .env file by editing the .env file like below:
54+
55+
APP_URL=your_application_url
56+
57+
<strong>Step - 9:</strong>
58+
<br>
59+
Build the assets by running the command "npm run build"
60+
61+
<strong>Step - 10:</strong>
62+
<br>
63+
Delete the node_modules folder from the root directory
64+
65+
## When a problem is found?
66+
67+
Do not hesitate to message me when you found any problem.
68+
<br>
69+
<a href="https://www.facebook.com/engrmdnafiulislam/">Facebook</a>
70+
<br>
71+
<a href="https://www.instagram.com/engrmdnafiulislam/">Instagram</a>

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

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
$this->renderable(function (\Exception $e) {
51+
if ($e->getPrevious() instanceof \Illuminate\Session\TokenMismatchException) {
52+
return redirect()->back()->with('error','Something went wrong');
53+
}
54+
});
55+
}
56+
}

app/Http/Controllers/Controller.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
6+
use Illuminate\Foundation\Bus\DispatchesJobs;
7+
use Illuminate\Foundation\Validation\ValidatesRequests;
8+
use Illuminate\Routing\Controller as BaseController;
9+
10+
class Controller extends BaseController
11+
{
12+
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
13+
}

app/Http/Controllers/Inputtest.php

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
use App\Models\Testinput;
7+
use App\Models\Secondtestinput;
8+
use Image;
9+
10+
class Inputtest extends Controller
11+
{
12+
public function add(Request $req){
13+
$validatedData = $req->validate([
14+
'text' => ['required', 'string', 'max:255'],
15+
'number' => ['required', 'integer', 'min:1'],
16+
'image' => ['image', 'max:2048'],
17+
],
18+
[
19+
'text.required' => 'Text is required',
20+
'text.string' => 'Text must be a string',
21+
'text.max' =>'Text must not be greater than 255 characters',
22+
'number.required' => 'Number is required',
23+
'number.integer' => 'Number must be an integer',
24+
'number.min' => 'Number must be at least 1',
25+
'image.image' => 'Image must be an image',
26+
]);
27+
28+
$testinput = new Testinput;
29+
$image = request()->file('image');
30+
if($image){
31+
$name = hexdec(uniqid());
32+
$fullname = $name.'.webp';
33+
$path = 'images/testinputs/images/';
34+
$url = $path.$fullname;
35+
$resize_image=Image::make($image->getRealPath());
36+
$resize_image->resize(300,300);
37+
$resize_image->save('images/testinputs/images/'.$fullname);
38+
$testinput -> text = $req -> text;
39+
$testinput -> number = $req -> number;
40+
$testinput -> image = $url;
41+
$testinput -> save();
42+
return redirect()->route('welcome')->with('message','Data successfully added');
43+
}
44+
else{
45+
$testinput -> text = $req -> text;
46+
$testinput -> number = $req -> number;
47+
$testinput -> save();
48+
return redirect()->route('welcome')->with('message','Data successfully added');
49+
}
50+
}
51+
public function view(){
52+
$views = Testinput::orderBy('text', 'ASC')->get();
53+
return view('view', compact('views'));
54+
}
55+
public function update($id){
56+
$update = Testinput::findorfail($id);
57+
return view('update', ['update' => $update]);
58+
}
59+
public function update2(Request $req){
60+
$validatedData = $req->validate([
61+
'text' => ['required', 'string', 'max:255'],
62+
'number' => ['required', 'integer', 'min:1'],
63+
'image' => ['image', 'max:2048'],
64+
],
65+
[
66+
'text.required' => 'Text is required',
67+
'text.string' => 'Text must be a string',
68+
'text.max' =>'Text must not be greater than 255 characters',
69+
'number.required' => 'Number is required',
70+
'number.integer' => 'Number must be an integer',
71+
'number.min' => 'Number must be at least 1',
72+
'image.image' => 'Image must be an image',
73+
]);
74+
75+
$testinput = Testinput::findorfail($req->id);
76+
$image = request()->file('image');
77+
if($image){
78+
$old_image=$testinput->image;
79+
if(file_exists($old_image)){
80+
unlink($old_image);
81+
}
82+
$name = hexdec(uniqid());
83+
$fullname = $name.'.webp';
84+
$path = 'images/testinputs/images/';
85+
$url = $path.$fullname;
86+
$resize_image=Image::make($image->getRealPath());
87+
$resize_image->resize(300,300);
88+
$resize_image->save('images/testinputs/images/'.$fullname);
89+
$testinput -> text = $req -> text;
90+
$testinput -> number = $req -> number;
91+
$testinput -> image = $url;
92+
$testinput -> save();
93+
return redirect()->route('view')->with('message','Data successfully updated');
94+
}
95+
else{
96+
$testinput -> text = $req -> text;
97+
$testinput -> number = $req -> number;
98+
$testinput -> save();
99+
return redirect()->route('view')->with('message','Data successfully updated');
100+
}
101+
}
102+
public function delete(Request $req){
103+
$delete = Testinput::findorfail($req->id);
104+
$image = $delete->image;
105+
if(file_exists($image)){
106+
unlink($image);
107+
}
108+
$delete->delete();
109+
return redirect()->route('view')->with('error','Data successfully deleted');
110+
}
111+
public function add2(){
112+
$first_tables=Testinput::orderBy('text', 'ASC')->get();
113+
return view('add', ['first_tables' => $first_tables]);
114+
}
115+
public function add3(Request $req){
116+
$validatedData = $req->validate([
117+
'text2' => ['required', 'string', 'max:255'],
118+
'ti_id' => ['required'],
119+
],
120+
[
121+
'text2.required' => 'Text is required',
122+
'text2.string' => 'Text must be a string',
123+
'text2.max' =>'Text must not be greater than 255 characters',
124+
'ti_id.required' => 'Text is required'
125+
]);
126+
127+
$secondtestinput = new Secondtestinput;
128+
$secondtestinput -> text2 = $req -> text2;
129+
$secondtestinput -> ti_id = $req -> ti_id;
130+
$secondtestinput->save();
131+
return redirect()->route('add2')->with('message','Data successfully added');
132+
}
133+
public function view2(){
134+
$views = Secondtestinput::orderBy('text2', 'ASC')->get();
135+
return view('view2', ['views' => $views]);
136+
}
137+
public function update3($id){
138+
$update = Secondtestinput::findorfail($id);
139+
$first_tables = Testinput::all();
140+
return view('update2', ['update' => $update, 'first_tables' => $first_tables]);
141+
}
142+
public function update4(Request $req){
143+
$validatedData = $req->validate([
144+
'text2' => ['required', 'string', 'max:255'],
145+
'ti_id' => ['required'],
146+
],
147+
[
148+
'text2.required' => 'Text is required',
149+
'text2.string' => 'Text must be a string',
150+
'text2.max' =>'Text must not be greater than 255 characters',
151+
'ti_id.required' => 'Text is required'
152+
]);
153+
154+
$secondtestinput = Secondtestinput::findorfail($req->id);
155+
$secondtestinput -> text2 = $req -> text2;
156+
$secondtestinput -> ti_id = $req -> ti_id;
157+
$secondtestinput -> save();
158+
return redirect()->route('view2')->with('message','Data successfully updated');
159+
}
160+
public function delete2(Request $req){
161+
Secondtestinput::findorfail($req->id)->delete();
162+
return redirect()->route('view2')->with('error','Data successfully deleted');
163+
}
164+
}

0 commit comments

Comments
 (0)