This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add blades * feat: add * fix: refactor routing * feat: add editor and remove tests * feat: cleaning * fix: after review * fix: cleaning * fix: after review and dump error * fix: remove files * Update resources/css/app.css Co-authored-by: Kamil Piech <[email protected]> * fix: after review * fix: after review * fix: remove purifier * fix: after review * feat: update routing and fixed bug * fix: after review * fix: after review * fix: change chmod * fix: eslint run Co-authored-by: Kamil Piech <[email protected]> Co-authored-by: aleksander.kowalski <[email protected]>
- Loading branch information
1 parent
30fa3ed
commit b24753d
Showing
23 changed files
with
261 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ storage/redis/dump.rdb | |
/storage/src/* | ||
composer.lock | ||
package-lock.json | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
database/migrations/2022_03_18_195003_create_news_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class() extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create("news", function (Blueprint $table): void { | ||
$table->id(); | ||
$table->foreignId("author_id")->constrained()->onDelete("cascade"); | ||
$table->string("title"); | ||
$table->longText("text"); | ||
$table->string("slug")->unique(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists("news"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
use Blumilk\Meetup\Core\Models\User; | ||
use Illuminate\Database\Seeder; | ||
use Illuminate\Support\Carbon; | ||
use Illuminate\Support\Facades\Hash; | ||
|
||
class DummyDataSeeder extends Seeder | ||
{ | ||
|
@@ -20,7 +19,7 @@ public function run(): void | |
$user = User::factory([ | ||
"name" => "Admin", | ||
"email" => "[email protected]", | ||
"password" => Hash::make("password"), | ||
"password" => "password", | ||
"email_verified_at" => Carbon::createFromDate(2022, 01, 01), | ||
])->create(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
css/* | ||
js/* | ||
css/* |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
<div> | ||
<div> | ||
<h1>Create News</h1> | ||
@auth | ||
<form action="{{ route('news.store') }}" method="post" id="createNews"> | ||
@csrf | ||
<div> | ||
<label for="title">Title:</label> | ||
<input type="text" id="title" name="title" value="{{ old('title') }}"> | ||
<x-input-error for="title"/> | ||
</div> | ||
<label for="editor">Content:</label> | ||
<div class="flex flex-col space-y-2"> | ||
<div id="editor" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm"></div> | ||
</div> | ||
<x-input-error for="editor"/> | ||
<input type="hidden" name="text" id="text"> | ||
<div> | ||
<button type="submit">Post</button> | ||
</div> | ||
</form> | ||
@endauth | ||
</div> | ||
</div> | ||
<script src="{{ asset('static/js/app.js') }}"></script> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
<div> | ||
<div> | ||
<h1>Edit News</h1> | ||
@auth | ||
<form method="post" action="{{ route('news.update', $news) }}" id="editNews"> | ||
@method('PUT') | ||
@csrf | ||
<div> | ||
<label for="name">Title:</label> | ||
<input type="text" id="title" name="title" value="{{ old('title', $news->title) }}"> | ||
<x-input-error for="name"/> | ||
</div> | ||
<label for="editor">Content:</label> | ||
<div class="flex flex-col space-y-2"> | ||
<div id="editor" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm"></div> | ||
</div> | ||
<x-input-error for="editor"/> | ||
<input type="hidden" id="oldText" value="{{ $news->text }}"> | ||
<input type="hidden" name="text" id="text"> | ||
<div> | ||
<button type="submit">Update</button> | ||
</div> | ||
</form> | ||
@endauth | ||
</div> | ||
</div> | ||
<script src="{{ asset('static/js/app.js') }}"></script> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
<div> | ||
<div> | ||
<h1>News</h1> | ||
@auth | ||
<a href="{{ route('news.create') }}">Create new news</a> | ||
@endauth | ||
@if ($news->count()) | ||
@foreach ($news as $singleNews) | ||
<div> | ||
{{ $singleNews->title }} | ||
{!! Str::markdown($singleNews->text) !!} | ||
{{ $singleNews->author }} | ||
|
||
<a href="{{ route('news.edit', $singleNews) }}">Edit</a> | ||
<form action="{{ route('news.destroy', $singleNews) }}"> | ||
@csrf | ||
@method('DELETE') | ||
<button type="submit" onclick="return confirm('Delete News? This operation is irreversible.')">Delete</button> | ||
</form> | ||
</div> | ||
@endforeach | ||
@else | ||
<p>There are no news</p> | ||
@endif | ||
</div> | ||
</div> | ||
@endsection |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\Meetup\Core\Http\Controllers; | ||
|
||
use Blumilk\Meetup\Core\Http\Requests\News\NewsRequest; | ||
use Blumilk\Meetup\Core\Models\News; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Http\RedirectResponse; | ||
|
||
class NewsController extends Controller | ||
{ | ||
public function index(): View | ||
{ | ||
$news = News::query()->orderBy("date")->paginate(20); | ||
|
||
return view("news.index") | ||
->with("news", $news); | ||
} | ||
|
||
public function create(): View | ||
{ | ||
return view("news.create"); | ||
} | ||
|
||
public function store(NewsRequest $request): RedirectResponse | ||
{ | ||
$input = $request->validated(); | ||
|
||
$request->user()->news()->create($input); | ||
|
||
return redirect()->route("news"); | ||
} | ||
|
||
public function edit(News $news): View | ||
{ | ||
return view("news.edit") | ||
->with("news", $news); | ||
} | ||
|
||
public function update(NewsRequest $request, News $news): RedirectResponse | ||
{ | ||
$news->update($request->validated()); | ||
|
||
return redirect()->route("news"); | ||
} | ||
|
||
public function destroy(News $news): RedirectResponse | ||
{ | ||
$news->delete(); | ||
|
||
return back(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\Meetup\Core\Http\Requests\News; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class NewsRequest extends FormRequest | ||
{ | ||
public function rules(): array | ||
{ | ||
return [ | ||
"title" => "required|string", | ||
"text" => "required|string", | ||
]; | ||
} | ||
|
||
protected function prepareForValidation(): void | ||
{ | ||
$this->merge([ | ||
"text" => strip_tags($this->text), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters