Skip to content

Commit

Permalink
post operations, authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
toserjude committed Dec 11, 2018
1 parent 14967d1 commit 5ea0bf0
Show file tree
Hide file tree
Showing 2,773 changed files with 17,185 additions and 53 deletions.
28 changes: 28 additions & 0 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}

/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('home');
}
}
43 changes: 34 additions & 9 deletions app/Http/Controllers/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class PostController extends Controller
public function index()
{
// közvetlen SQL lekérdezéssel is lehet:
// $posts = DB::select('SELECT * FROM posts ORDER BY created_at DESC');
// $posts = Post::orderBy('created_at', 'desc')->get();
// $posts = Post::orderBy('created_at', 'desc')->take(1)->get();
$posts = Post::orderBy('created_at', 'desc')->paginate(10);
// $posts = DB::select('SELECT * FROM posts ORDER BY id DESC');
// $posts = Post::orderBy('id', 'desc')->get();
// $posts = Post::orderBy('id', 'desc')->take(1)->get();
$posts = Post::orderBy('id', 'desc')->paginate(10);
return view('post.index')->with('posts', $posts);
}

Expand All @@ -30,7 +30,7 @@ public function index()
*/
public function create()
{
//
return view('post.create');
}

/**
Expand All @@ -41,7 +41,18 @@ public function create()
*/
public function store(Request $request)
{
//
$this->validate($request, [
'title' => 'required',
'body' => 'required'
]);

// Create Post
$post = new Post;
$post->title = $request->input('title');
$post->body = $request->input('body');
$post-> save();

return redirect('/post')->with('success', 'Post successfully created');
}

/**
Expand All @@ -64,7 +75,8 @@ public function show($id)
*/
public function edit($id)
{
//
$post = Post::find($id);
return view('post.edit')->with('post', $post);
}

/**
Expand All @@ -76,7 +88,18 @@ public function edit($id)
*/
public function update(Request $request, $id)
{
//
$this->validate($request, [
'title' => 'required',
'body' => 'required'
]);

// Create Post
$post = Post::find($id);
$post->title = $request->input('title');
$post->body = $request->input('body');
$post-> save();

return redirect('/post')->with('success', 'Post successfully updated');
}

/**
Expand All @@ -87,6 +110,8 @@ public function update(Request $request, $id)
*/
public function destroy($id)
{
//
$post = Post::find($id);
$post->delete();
return redirect('/post')->with('success', 'Post successfully deleted');
}
}
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0"
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.4.0",
"unisharp/laravel-ckeditor": "^4.7"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
Expand Down
124 changes: 123 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
/*
* Package Service Providers...
*/
Collective\Html\HtmlServiceProvider::class,

/*
* Application Service Providers...
Expand All @@ -174,6 +175,7 @@
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Unisharp\Ckeditor\ServiceProvider::class,

],

Expand Down Expand Up @@ -223,7 +225,8 @@
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,

'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class
],

];
10 changes: 10 additions & 0 deletions public/vendor/unisharp/laravel-ckeditor/adapters/jquery.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5ea0bf0

Please sign in to comment.