Preparing document handling

beta
anulax1225 ago%!(EXTRA string=2 months)
parent 2385347434
commit 41dccd395a
  1. 65
      app/Http/Controllers/DocumentController.php
  2. 39
      app/Models/Document.php
  3. 26
      app/Models/DocumentState.php
  4. 35
      database/migrations/2025_04_26_184348_create_document_states.php
  5. 36
      database/migrations/2025_04_26_223135_create_documents.php
  6. BIN
      public/img/new-logo.png

@ -0,0 +1,65 @@
<?php
namespace App\Http\Controllers;
use App\Models\Document;
use Illuminate\Http\Request;
class DocumentController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(Document $document)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Document $document)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Document $document)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Document $document)
{
//
}
}

@ -0,0 +1,39 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Document extends Model
{
protected $fillable = [
'uuid',
'title',
'html',
'json',
'document_state_id',
'user_id'
];
public function jsonSerialize():array
{
return [
'uuid' => $this->uuid,
'title' => $this->title,
'html' => $this->html,
'json' => $this->json,
'state' => $this->state,
'user' => $this->user,
];
}
public function state()
{
return $this->belongsTo(DocumentState::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
}

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class DocumentState extends Model
{
protected $fillable = [
'id',
'name',
];
public function jsonSerialize():array
{
return [
'id' => $this->uuid,
'name' => $this->name,
];
}
public function documents()
{
return $this->hasMany(Document::class);
}
}

@ -0,0 +1,35 @@
<?php
use App\Models\Document;
use App\Models\DocumentState;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illumite\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('document_states', function (Blueprint $table) {
$table->id();
$table->string("name");
$table->timestamps();
});
DocumentState::create(["name"=> "Brouillon"]);
DocumentState::create(["name"=> "Public"]);
DocumentState::create(["name"=> "Privé"]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('document_states');
}
};

@ -0,0 +1,36 @@
<?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('documents', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string("title");
$table->text("html");
$table->json("json");
$table->unsignedBigInteger("document_state_id");
$table->unsignedBigInteger("user_id");
$table->timestamps();
$table->foreign("user_id")->references("id")->on("users");
$table->foreign("document_state_id")->references("id")->on("document_states");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('documents');
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Loading…
Cancel
Save