connect to db
This commit is contained in:
parent
c3f01cee54
commit
9c430b9593
4
.env
4
.env
|
@ -1,4 +1,4 @@
|
||||||
APP_NAME=Laravel
|
APP_NAME=dym
|
||||||
APP_ENV=local
|
APP_ENV=local
|
||||||
APP_KEY=base64:/4iQMUGojyypXAMaOjvIRIHHG+a/cbY+2KLC2ToQYHQ=
|
APP_KEY=base64:/4iQMUGojyypXAMaOjvIRIHHG+a/cbY+2KLC2ToQYHQ=
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
|
@ -52,7 +52,7 @@ MAIL_PORT=2525
|
||||||
MAIL_USERNAME=null
|
MAIL_USERNAME=null
|
||||||
MAIL_PASSWORD=null
|
MAIL_PASSWORD=null
|
||||||
MAIL_ENCRYPTION=null
|
MAIL_ENCRYPTION=null
|
||||||
MAIL_FROM_ADDRESS="hello@example.com"
|
MAIL_FROM_ADDRESS="re@dym.sh"
|
||||||
MAIL_FROM_NAME="${APP_NAME}"
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
AWS_ACCESS_KEY_ID=
|
AWS_ACCESS_KEY_ID=
|
||||||
|
|
|
@ -26,6 +26,6 @@ class RegisteredUserController extends Controller
|
||||||
|
|
||||||
Auth::login( $user );
|
Auth::login( $user );
|
||||||
|
|
||||||
return redirect('/admin');
|
return redirect('/articles');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class SessionController extends Controller
|
||||||
|
|
||||||
request()->session()->regenerate();
|
request()->session()->regenerate();
|
||||||
|
|
||||||
return redirect('/dashboard');
|
return redirect('/articles');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy()
|
public function destroy()
|
||||||
|
|
|
@ -6,32 +6,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class Article //extends Model
|
class Article extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
protected $table = 'articles';
|
||||||
|
|
||||||
public static function all(): array {
|
use HasFactory;
|
||||||
return [
|
|
||||||
[ 'id' => 1,
|
|
||||||
'title' => 'First One',
|
|
||||||
'slug' => '1st',
|
|
||||||
'body' => 'First!!1<br>
|
|
||||||
lol',
|
|
||||||
],
|
|
||||||
[ 'id' => 2,
|
|
||||||
'title' => 'Second One',
|
|
||||||
'slug' => '2nd',
|
|
||||||
'body' => 'Second i do concour<br>
|
|
||||||
lmfao',
|
|
||||||
],
|
|
||||||
[ 'id' => 3,
|
|
||||||
'title' => 'Third One',
|
|
||||||
'slug' => '3rd',
|
|
||||||
'body' => 'Third indeed<br>
|
|
||||||
xD',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function find(string $slug): array
|
public static function find(string $slug): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@ use Closure;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\View\Component;
|
use Illuminate\View\Component;
|
||||||
|
|
||||||
class layout-admin extends Component
|
class layout_dashboard extends Component
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a new component instance.
|
* Create a new component instance.
|
||||||
|
@ -21,6 +21,6 @@ class layout-admin extends Component
|
||||||
*/
|
*/
|
||||||
public function render(): View|Closure|string
|
public function render(): View|Closure|string
|
||||||
{
|
{
|
||||||
return view('components.layout-admin');
|
return view('components.layout-dashboard');
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('articles', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('slug');
|
||||||
|
$table->string('title');
|
||||||
|
$table->text('body');
|
||||||
|
$table->integer('category');
|
||||||
|
$table->boolean('is_collection');
|
||||||
|
$table->integer('tag_1');
|
||||||
|
$table->integer('tag_2');
|
||||||
|
$table->integer('tag_3');
|
||||||
|
$table->integer('tag_4');
|
||||||
|
$table->integer('tag_5');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('articles');
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,4 +1,4 @@
|
||||||
<x-layout-admin>
|
<x-layout-dashboard>
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
@foreach($articles as $article)
|
@foreach($articles as $article)
|
||||||
|
@ -6,4 +6,6 @@
|
||||||
@endforeach
|
@endforeach
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
</x-layout-admin>
|
// todo other lists; stats
|
||||||
|
|
||||||
|
</x-layout-dashboard>
|
|
@ -1,3 +1,3 @@
|
||||||
<x-layout-admin>
|
<x-layout-dashboard>
|
||||||
|
|
||||||
</x-layout-admin>
|
</x-layout-dashboard>
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<x-layout>
|
<x-layout-dashboard>
|
||||||
|
|
||||||
|
</x-layout-dashboard>
|
||||||
|
|
||||||
|
|
||||||
<form class="col c" method="post" name="register_form" action="/register">
|
<form class="col c" method="post" name="register_form" action="/register">
|
||||||
@csrf
|
@csrf
|
||||||
|
@ -23,5 +26,3 @@
|
||||||
|
|
||||||
<button type="submit">Register</button>
|
<button type="submit">Register</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</x-layout>
|
|
||||||
|
|
|
@ -1,21 +1,47 @@
|
||||||
@if( 'hidden' !== $attributes['type'] )
|
@if( 'hidden' === $attributes['type'] )
|
||||||
|
|
||||||
<div class="x-input"
|
|
||||||
title="{{ $attributes['title'] ?? $slot }}"
|
|
||||||
>
|
|
||||||
<label
|
|
||||||
for="{{ $slot }}"
|
|
||||||
>{{ $attributes['title'] ?? $slot }}</label>
|
|
||||||
<input
|
<input
|
||||||
name="{{ $slot }}"
|
name="{{ $slot }}"
|
||||||
id="{{ $slot }}"
|
{{ $attributes->merge() }}
|
||||||
placeholder="{{ $attributes['title'] ?? $slot }}"
|
>
|
||||||
{{ $attributes->merge()->filter(fn ($value, $key) => !in_array($key, ['title'])) }}
|
|
||||||
>
|
|
||||||
|
|
||||||
@error( "$slot" )
|
@elseif( 'textarea' == $attributes['type'] )
|
||||||
<p class="error">{{ $message }}</p>
|
|
||||||
@enderror
|
<div class="x-input"
|
||||||
</div>
|
title="{{ $attributes['title'] ?? $slot }}"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
for="{{ $slot }}"
|
||||||
|
>{{ $attributes['title'] ?? $slot }}</label>
|
||||||
|
<textarea
|
||||||
|
name="{{ $slot }}"
|
||||||
|
id="{{ $slot }}"
|
||||||
|
placeholder="{{ $attributes['title'] ?? $slot }}"
|
||||||
|
{{ $attributes->merge()->filter(fn ($value, $key) => !in_array($key, ['title','value'])) }}
|
||||||
|
>{{ $attributes['value'] ?? '' }}</textarea>
|
||||||
|
|
||||||
|
@error( "$slot" )
|
||||||
|
<p class="error">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@else
|
||||||
|
|
||||||
|
<div class="x-input"
|
||||||
|
title="{{ $attributes['title'] ?? $slot }}"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
for="{{ $slot }}"
|
||||||
|
>{{ $attributes['title'] ?? $slot }}</label>
|
||||||
|
<input
|
||||||
|
name="{{ $slot }}"
|
||||||
|
id="{{ $slot }}"
|
||||||
|
placeholder="{{ $attributes['title'] ?? $slot }}"
|
||||||
|
{{ $attributes->merge()->filter(fn ($value, $key) => !in_array($key, ['title'])) }}
|
||||||
|
>
|
||||||
|
|
||||||
|
@error( "$slot" )
|
||||||
|
<p class="error">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
@endif
|
@endif
|
|
@ -3,7 +3,7 @@
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
<meta charset="utf8">
|
<meta charset="utf8">
|
||||||
<title>{{ request()->path() }}</title>
|
<title>{{ request()->path() }}</title>
|
||||||
<link rel="stylesheet" type="text/css" href="/css/admin.css">
|
<link rel="stylesheet" type="text/css" href="/css/dashboard.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
<input type="search" name="q">
|
<input type="search" name="q">
|
||||||
<button type="submit">search</button>
|
<button type="submit">search</button>
|
||||||
</form>
|
</form>
|
||||||
<a href="/dashboard">articles</a>
|
<a href="/articles">articles</a>
|
||||||
<a href="/new">new</a>
|
<a href="/new">new</a>
|
||||||
<a href="/categories">categories</a>
|
<a href="/categories">categories</a>
|
||||||
<a href="/collections">collections</a>
|
<a href="/collections">collections</a>
|
|
@ -1,4 +1,4 @@
|
||||||
<a href="'/tags/'.$slot.'/' }}"
|
<a href="{{ '/tags/'.$slot.'/' }}"
|
||||||
aria-current="{{ str_starts_with(request()->path(), 'tags/'.$slot) ? 'true' : 'false' }}"
|
aria-current="{{ str_starts_with(request()->path(), 'tags/'.$slot) ? 'true' : 'false' }}"
|
||||||
{{ $attributes->merge(['class' => str_starts_with(request()->path(), 'tags/'.$slot ) ? 'current' : '' ])}}
|
{{ $attributes->merge(['class' => str_starts_with(request()->path(), 'tags/'.$slot ) ? 'current' : '' ])}}
|
||||||
>{{ $slot }}</a>
|
>{{ $slot }}</a>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<x-layout-admin>
|
<x-layout-dashboard>
|
||||||
|
|
||||||
<form class="col c w-30" method="post" name="edit_form" action="/edit">
|
<form class="col c w-30" method="post" name="edit_form" action="/edit">
|
||||||
@csrf
|
@csrf
|
||||||
|
@ -13,4 +13,4 @@
|
||||||
<button type="submit">Save</button>
|
<button type="submit">Save</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</x-layout-admin>
|
</x-layout-dashboard>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<x-layout-admin>
|
<x-layout-dashboard>
|
||||||
|
|
||||||
<form class="col c w-30" method="post" name="new_form" action="/new">
|
<form class="col c w-30" method="post" name="new_form" action="/new">
|
||||||
@csrf
|
@csrf
|
||||||
<x-input type="hidden">id</x-input>
|
<x-input type="hidden" value="0">id</x-input>
|
||||||
<x-input>title</x-input>
|
<x-input>title</x-input>
|
||||||
<x-input pattern="[A-Za-z0-9-]+" required>slug</x-input>
|
<x-input pattern="[A-Za-z0-9-]+" required>slug</x-input>
|
||||||
<textarea name="body"></textarea>
|
<x-input type="textarea">body</x-input>
|
||||||
<button type="submit">Create new</button>
|
<button type="submit">Create new</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</x-layout-admin>
|
</x-layout-dashboard>
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<x-layout>
|
|
||||||
|
|
||||||
<main class="article">
|
|
||||||
|
|
||||||
</main>
|
|
||||||
|
|
||||||
</x-layout>
|
|
|
@ -36,8 +36,8 @@ Route::get('/edit/{slug}', function (string $slug) {
|
||||||
]);
|
]);
|
||||||
})->where('slug', '[A-Za-z0-9-]+');
|
})->where('slug', '[A-Za-z0-9-]+');
|
||||||
|
|
||||||
Route::get('/dashboard', function () {
|
Route::get('/articles', function () {
|
||||||
return view('dashboard', [
|
return view('articles', [
|
||||||
'articles' => Article::all(),
|
'articles' => Article::all(),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue