Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
El-khamisi committed Sep 26, 2021
0 parents commit 29f605b
Show file tree
Hide file tree
Showing 107 changed files with 39,558 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.example
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.idea
/.vscode
14 changes: 14 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
php:
preset: laravel
version: 8
disabled:
- no_unused_imports
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Introduction:
This is a simple website for Movies. The website allows authorized
users to add new movies and delete the old ones if needed. The
website uses MySQL as a database provider to manipulate data and
allow the users to add movies with the title, brief descriptions,
thumbnails photos, and rating of the movie.
## Directory Structure:
The project has a standard structure of laravel framework 8 .x with
some customization just to make it simple.
* The app/Http/Controllers directory </br>
The directory contains controllers to handle requests
entering the project.
* The database/migrations directory </br>
The directory contains database migration scripts for
schema database tables. The migrations scripts also has
some data for demo Purposes.
* The public directory </br>
The directory contains the index.php file, which is the entry
point for all requests entering the project and configures
autoloading. This directory also houses the assets such as
images, JavaScript, and CSS.
* The public/images directory </br>
The directory contains movies thumbnails that have been
uploaded and the file path will be added to the database.* The resources directory
The directory contains the views as well as the raw,
un-compiled assets such as SCSS or JavaScript. This directory
also houses all development-stage files.
* The routes directory </br>
The routes directory contains all of the route definitions for
the project.
* The package.json file </br>
The file contains all npm scripts and Dependencies.
* The webpack.mix.js file </br>
The file contains all mix API configurations.
## ERD Diagrams :
![ERD Digrams] (public/images/ERD.png)


## Basic Directory Structure:
```
.
|
|__app
| |__Http
| |__Controllers
|__database
| |__migrations
|__public
| |__images
|__resources
|__routes
|__package.json
|__webpack.mix.js
```
41 changes: 41 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Console;

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

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* 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');
}
}
41 changes: 41 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Exceptions;

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

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
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) {
//
});
}
}
13 changes: 13 additions & 0 deletions 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;
}
55 changes: 55 additions & 0 deletions app/Http/Controllers/movies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;


class movies extends Controller
{
/*
*Indexing Function to Handling Home Page Route
*/
function index()
{

$records = DB::table('movies')->get();

return view('welcome', ['records'=>$records]);
}

/*
*Function to handling addMovie Route
*/
function addMovie(Request $request)
{

if(is_null($request->input('movie_title')) && $request->hasFile('thumb') && $request->thumb->isValid()){

$imgName = $request->input('movie_title').'.'.$request->thumb->extension();
$path = $request->thumb->storeAs('images', $imgName);

DB::table('movies')->insert([
'movie_title' => $request->input('movie_title'),
'descriptio' => $request->input('descriptio'),
'filepath' => $path,
'rating' =>$request->rating
]);
return back()->with('Success', 'login successfully');;
}else {
echo "<script>
alert('The new movie has some missing data');
</script>";
}
}

/*
*Function to Handling delete-Movie Route
*/
function dltMovie(Request $request){

DB::table('movies')->where('movie_title', $request->input('movie_title'))->delete();
return back()->with('Success', 'login successfully');
}
}
53 changes: 53 additions & 0 deletions app/Http/Controllers/users.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\DB;


class users extends Controller
{
//index function to handle get request
function index(){
return view('layouts/auth');
}

/*login funciton checks username and password
* to give a permission to delete movies
*/
function login(Request $request){

if(is_null($request->username) || is_null($request->password)){
return back()->with('error', "All field are required...!!!");
}

$rec = DB::table('users')->where('username', $request->username)->get();


if($rec->isEmpty() || $rec[0]->password != $request->password){
return back()->with('error', "User NOT FOUND.");
}

return redirect('/')->with('Success', 'login successfully');
}


/*
*Signup function to deal with new Useres
*/
function signup(Request $request){

if(is_null($request->username) || is_null($request->password)){
return back()->with('error', "All field are required...!!!");
}

DB::table('users')->insert([
'username' => $request->input('username'),
'password' => $request->input('password')
]);

return back()->with('Success', "User has been registered successfully Now you can SignIn");
}
}
67 changes: 67 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\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
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],

'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];

/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
}
21 changes: 21 additions & 0 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}
Loading

0 comments on commit 29f605b

Please sign in to comment.