Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
65e112f
Create laravel project
davidccgarcia May 30, 2024
ebf91c4
Change timezone and locale
davidccgarcia May 30, 2024
a60821c
Create migrations and principles models
davidccgarcia May 30, 2024
eb5cb35
Install Laravel Breeze
davidccgarcia May 30, 2024
5a307b6
Create templates about and home
davidccgarcia May 31, 2024
b6875aa
Install flowbite
davidccgarcia May 31, 2024
36f1fee
Move includes files to includes folder and install admin template
davidccgarcia May 31, 2024
b7ccbb5
Move admin.blade.php file to admin folder
davidccgarcia May 31, 2024
b80d04d
Change links from navbar
davidccgarcia May 31, 2024
6f1af74
Move links and organize menu items
davidccgarcia May 31, 2024
68aa660
Organize sidebar items
davidccgarcia May 31, 2024
6d4093a
Get admin layout from edit profile page
davidccgarcia May 31, 2024
f8caeb6
Move PostController to Admin Controller folder
davidccgarcia May 31, 2024
8e8597d
Create category and tag controller and Category Model
davidccgarcia May 31, 2024
9f2f8e8
Validate if user is logged in to show differents links
davidccgarcia May 31, 2024
5127781
Add route links to sidebar items
davidccgarcia May 31, 2024
9164426
Add routes groups and routes for categories, tags and posts
davidccgarcia May 31, 2024
53cd1eb
Delete show method to controller, delete, update and store categories
davidccgarcia May 31, 2024
8cb4928
Indent content
davidccgarcia May 31, 2024
6e89a8b
Except show method/route
davidccgarcia May 31, 2024
89b59c7
Create index, create and edit views for categories
davidccgarcia May 31, 2024
3710043
Create Category Form Request
davidccgarcia May 31, 2024
05d7dd1
Use Category form request
davidccgarcia May 31, 2024
0b1f000
Add attributes that are mass assignable for Category Model
davidccgarcia May 31, 2024
8a42258
Create form to add new category
davidccgarcia May 31, 2024
0abcf57
Change semibold to normal font
davidccgarcia May 31, 2024
2d8d31d
CRUD Tags
davidccgarcia Jun 2, 2024
18d8d90
Add edit and delete functions to category module
davidccgarcia Jun 2, 2024
11a88fe
CRUD posts
davidccgarcia Jun 2, 2024
0fca836
Add HomeController to show posts and tags
davidccgarcia Jun 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
58 changes: 58 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1

VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
27 changes: 27 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Console;

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

class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*/
protected function schedule(Schedule $schedule): void
{
// $schedule->command('inspire')->hourly();
}

/**
* Register the commands for the application.
*/
protected function commands(): void
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
48 changes: 48 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace App\Exceptions;

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

class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];

/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];

/**
* Register the exception handling callbacks for the application.
*/
public function register(): void
{
$this->reportable(function (Throwable $e) {
//
});
}
}
66 changes: 66 additions & 0 deletions app/Http/Controllers/Admin/CategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\CategoryRequest;
use App\Models\Category;

class CategoryController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$categories = Category::paginate();

return view('admin.categories.index', compact('categories'));
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('admin.categories.create');
}

/**
* Store a newly created resource in storage.
*/
public function store(CategoryRequest $request)
{
Category::create($request->validated());

return redirect()->route('admin.categories.index');
}

/**
* Show the form for editing the specified resource.
*/
public function edit(Category $category)
{
return view('admin.categories.edit', compact('category'));
}

/**
* Update the specified resource in storage.
*/
public function update(CategoryRequest $request, Category $category)
{
$category->update($request->validated());

return redirect()->route('admin.categories.index');
}

/**
* Remove the specified resource from storage.
*/
public function destroy(Category $category)
{
$category->delete();

return redirect()->route('admin.categories.index');
}
}
113 changes: 113 additions & 0 deletions app/Http/Controllers/Admin/PostController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Models\Post;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\StorePostRequest;
use App\Models\Category;
use App\Models\Tag;
use Illuminate\Support\Facades\Storage;

class PostController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$posts = Post::paginate();

return view('admin.posts.index', compact('posts'));
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
$categories = Category::all();
$tags = Tag::all();

return view('admin.posts.create', compact('categories', 'tags'));
}

/**
* Store a newly created resource in storage.
*/
public function store(StorePostRequest $request)
{
// if request has image, upload it
if ($request->has('image')) {
$filename = time() . '_' . $request->file('image')->getClientOriginalName();
$request->file('image')->storeAs('uploads', $filename, 'public');
}

// Create post
$post = auth()->user()->posts()->create([
'category_id' => $request->category,
'title' => $request->title,
'content' => $request->content,
'image' => $filename ?? null
]);

// Attach tags to post
$post->tags()->attach($request->tags);

return redirect()->route('admin.posts.index');
}

/**
* Show the form for editing the specified resource.
*/
public function edit(Post $post)
{
$categories = Category::all();
$tags = Tag::all();

return view('admin.posts.edit', compact('post', 'categories', 'tags'));
}

/**
* Update the specified resource in storage.
*/
public function update(StorePostRequest $request, Post $post)
{
// If request has image, first delete it and upload new image.
if ($request->has('image')) {
Storage::delete('public/uploads/' . $post->image);

$filename = time() . '_' . $request->file('image')->getClientOriginalName();
$request->file('image')->storeAs('uploads', $filename, 'public');
}

// Update the post
$post->update([
'category_id' => $request->category,
'title' => $request->title,
'content' => $request->content,
'image' => $filename ?? null
]);

// Sync tags
$post->tags()->sync($request->tags);

return redirect()->route('admin.posts.index');
}

/**
* Remove the specified resource from storage.
*/
public function destroy(Post $post)
{
if ($post->image) {
Storage::delete('public/uploads/' . $post->image);
}

$post->tags()->detach();
$post->delete();

return redirect()->route('admin.posts.index');
}
}
Loading