Skip to content

Commit

Permalink
layers
Browse files Browse the repository at this point in the history
  • Loading branch information
thaerfayyad committed Mar 12, 2021
1 parent 72b7a40 commit 69885da
Show file tree
Hide file tree
Showing 26 changed files with 871 additions and 351 deletions.
27 changes: 26 additions & 1 deletion app/Http/Controllers/Site/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace App\Http\Controllers\Site;

use App\Http\Controllers\Controller;
use App\Models\Attachment;
use App\Models\Post;
use App\User;

use Illuminate\Http\Request;

class HomeController extends Controller
Expand Down Expand Up @@ -34,5 +35,29 @@ public function about()
{
return view('site.about.index');
}
public function create() // create attachment page
{
return view('site.attachment.create');
}
public function store(Request $request)
{
$request->validate([
'title' => 'required|max:255',
'type' => 'required',
'description' => 'required',
'bookFile' => 'required|mimes:doc,pdf,docx,zip'

]);

if( $request->bookFile != Null) {

$attch = $request->file('bookFile');
$attch_new_name = time() . "-" . $attch->getClientOriginalName();
$attch->storeAs('uploads/attachment', $attch_new_name);
$attch->bookFile = $attch_new_name;
}
Attachment::create($request->except('_token'));
return redirect()->route('attachment.create')->with('success','the attachment uploaded successfully');
}

}
27 changes: 16 additions & 11 deletions app/Http/Controllers/admin/bookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,24 @@ public function store(Request $request)
'semester' => 'required',
'library' => 'required',
'book' => 'required',
'bookFile' => 'mimes:doc,pdf,docx,zip'
'bookFile' => 'required|mimes:doc,pdf,docx,zip'
]);

if( $request->bookFile != Null) {

$book = $request->file('bookFile');
$book_new_name = time() . "-" . $book->getClientOriginalName();
$book->storeAs('uploads/books', $book_new_name);
$book->bookFile = $book_new_name;
$book = new Book();
if( $request->bookFile != Null){
$bookName = $book->id.'_book'.time().'.'.request()->bookFile->getClientOriginalExtension();
$request->bookFile->move('uploads/books',$bookName);
$book->bookFile = $bookName;
}

Book::create($request->except('_token'));

$book->name = $request->name ;
$book->details = $request->details ;
$book->author = $request->author ;
$book->year = $request->year ;
$book->semester = $request->semester ;
$book->library = $request->library ;
$book->book = $request->book ;
$book->bookFile = $request->bookFile ;
$book->status = '1' ;
$book->save();
return redirect()->back();
}

Expand Down
148 changes: 148 additions & 0 deletions app/Http/Controllers/admin/layersController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?php

namespace App\Http\Controllers\admin;

use App\Http\Controllers\Controller;
use App\Models\admin\Book;
use App\Models\admin\Layers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Storage;

class layersController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$items = Layers::all();
return view('admin.layers.home',
[
'items' =>$items,
]);
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('admin.layers.create');
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
// dd($request->all());
$request->validate([
'title_threats' => 'required|max:255',
'layer' => 'required',
'descriptions_threats' => 'required',
'img_threats' => 'required |image|mimes:jpg,png',
'title_protocol' => 'required',
'descriptions_protocol' => 'required|',
]);
$layer = new Layers();
$layer->title_threats =$request->title_threats ;
$layer->layer =$request->layer;
$layer->descriptions_threats =$request->descriptions_threats ;
$layer->img_threats =$request->img_threats ;
$layer->title_protocol =$request->title_protocol ;
$layer->descriptions_protocol =$request->descriptions_protocol ;

if( $request->img_threats != Null){
$imgName = $layer->id.'_layer'.time().'.'.request()->img_threats->getClientOriginalExtension();

$request->img_threats->move('uploads/images/layers',$imgName);


$layer->img_threats = $imgName;
}

$layer->save();

return redirect()->back();
}

/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$layer = Layers::findOrFail($id);

return view('admin.layers.edit' , compact('layer'));
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// dd($request->all());

$layer = Layers::findOrFail($id);
$layer->title_threats =$request->title_threats ;
$layer->layer =$request->layer;
$layer->descriptions_threats =$request->descriptions_threats ;
$layer->img_threats =$request->img_threats ;
$layer->title_protocol =$request->title_protocol ;
$layer->descriptions_protocol =$request->descriptions_protocol ;

if( $request->img_threats != Null){
$imgName = $layer->id.'_layer'.time().'.'.request()->img_threats->getClientOriginalExtension();

$request->img_threats->move('uploads/images/layers',$imgName);


$layer->img_threats = $imgName;
}

$layer->save();

return redirect()->route('layers.index')
->with('success', 'Layers updated successfully');

}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
Book::findOrFail($id)->delete();
return redirect()->route('books.index')
->with('success', 'Book Deleted Successfully');
}
}
31 changes: 31 additions & 0 deletions app/Models/admin/Layers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Models\admin;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Layers extends Model
{
use SoftDeletes;
protected $table = 'layers';
protected $guarded =[];
protected $hidden = ['created_at',' updated_at','deleted_at'];
public function getLayer(){
if ($this -> layer == 1 )
return 'Application Layer' ;
elseif ($this -> layer == 2)
return 'Presentation Layer';
elseif ($this -> layer == 3)
return 'Session Layer';
elseif ($this -> layer == 4)
return 'Transport Layer';
elseif ($this -> layer == 5)
return 'Network Layer';
elseif ($this -> layer == 6)
return 'Data Link Layer';
else
return 'Physical Layer' ;
}

}
Binary file added public/uploads/books/_book1615576921.pdf
Binary file not shown.
Binary file added public/uploads/books/_book1615576937.pdf
Binary file not shown.
Binary file added public/uploads/books/_book1615576970.pdf
Binary file not shown.
Binary file added public/uploads/books/_book1615576988.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/uploads/images/layers/_layer1615583201.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 69885da

Please sign in to comment.