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_KEY=base64:/4iQMUGojyypXAMaOjvIRIHHG+a/cbY+2KLC2ToQYHQ=
|
||||
APP_DEBUG=true
|
||||
|
@ -52,7 +52,7 @@ MAIL_PORT=2525
|
|||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_ADDRESS="re@dym.sh"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
|
|
|
@ -26,6 +26,6 @@ class RegisteredUserController extends Controller
|
|||
|
||||
Auth::login( $user );
|
||||
|
||||
return redirect('/admin');
|
||||
return redirect('/articles');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class SessionController extends Controller
|
|||
|
||||
request()->session()->regenerate();
|
||||
|
||||
return redirect('/dashboard');
|
||||
return redirect('/articles');
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
|
|
|
@ -6,32 +6,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class Article //extends Model
|
||||
class Article extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'articles';
|
||||
|
||||
public static function all(): array {
|
||||
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',
|
||||
],
|
||||
];
|
||||
}
|
||||
use HasFactory;
|
||||
|
||||
public static function find(string $slug): array
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use Closure;
|
|||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class layout-admin extends Component
|
||||
class layout_dashboard extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
|
@ -21,6 +21,6 @@ class layout-admin extends Component
|
|||
*/
|
||||
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>
|
||||
@foreach($articles as $article)
|
||||
|
@ -6,4 +6,6 @@
|
|||
@endforeach
|
||||
</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">
|
||||
@csrf
|
||||
|
@ -23,5 +26,3 @@
|
|||
|
||||
<button type="submit">Register</button>
|
||||
</form>
|
||||
|
||||
</x-layout>
|
||||
|
|
|
@ -1,21 +1,47 @@
|
|||
@if( 'hidden' !== $attributes['type'] )
|
||||
|
||||
<div class="x-input"
|
||||
title="{{ $attributes['title'] ?? $slot }}"
|
||||
>
|
||||
<label
|
||||
for="{{ $slot }}"
|
||||
>{{ $attributes['title'] ?? $slot }}</label>
|
||||
@if( 'hidden' === $attributes['type'] )
|
||||
<input
|
||||
name="{{ $slot }}"
|
||||
id="{{ $slot }}"
|
||||
placeholder="{{ $attributes['title'] ?? $slot }}"
|
||||
{{ $attributes->merge()->filter(fn ($value, $key) => !in_array($key, ['title'])) }}
|
||||
>
|
||||
name="{{ $slot }}"
|
||||
{{ $attributes->merge() }}
|
||||
>
|
||||
|
||||
@error( "$slot" )
|
||||
<p class="error">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
@elseif( 'textarea' == $attributes['type'] )
|
||||
|
||||
<div class="x-input"
|
||||
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
|
|
@ -3,7 +3,7 @@
|
|||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf8">
|
||||
<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>
|
||||
|
||||
<body>
|
||||
|
@ -13,7 +13,7 @@
|
|||
<input type="search" name="q">
|
||||
<button type="submit">search</button>
|
||||
</form>
|
||||
<a href="/dashboard">articles</a>
|
||||
<a href="/articles">articles</a>
|
||||
<a href="/new">new</a>
|
||||
<a href="/categories">categories</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' }}"
|
||||
{{ $attributes->merge(['class' => str_starts_with(request()->path(), 'tags/'.$slot ) ? 'current' : '' ])}}
|
||||
>{{ $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">
|
||||
@csrf
|
||||
|
@ -13,4 +13,4 @@
|
|||
<button type="submit">Save</button>
|
||||
</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">
|
||||
@csrf
|
||||
<x-input type="hidden">id</x-input>
|
||||
<x-input type="hidden" value="0">id</x-input>
|
||||
<x-input>title</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>
|
||||
</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-]+');
|
||||
|
||||
Route::get('/dashboard', function () {
|
||||
return view('dashboard', [
|
||||
Route::get('/articles', function () {
|
||||
return view('articles', [
|
||||
'articles' => Article::all(),
|
||||
]);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue