Compare commits
4 Commits
sampleblog
...
gestion_de
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f2e0f78e9 | |||
|
|
f4aa84a82d | ||
|
|
338e803c5f | ||
|
|
dad50e035f |
28
A_retenir.md
28
A_retenir.md
@@ -10,3 +10,31 @@
|
||||
- `storage` => logs, cache
|
||||
- `tests` => tests de l'app (automatisés)
|
||||
- `vendor` => le dossier de composer (on n'y touche pas)
|
||||
|
||||
# Commandes PHP Artisan (Docker)
|
||||
|
||||
- Créer une migration => `php artisan make:migration create_nom_table`
|
||||
- migration => `php artisan migrate:fresh`
|
||||
- seeder => `php artisan db:seed --class=NomSeeder`
|
||||
|
||||
php artisan make:model Categorie --migration -a
|
||||
php artisan make:model billet_categorie -m
|
||||
|
||||
```sql
|
||||
use laravel_db;
|
||||
INSERT INTO billet_categorie (id, billet_id, categorie_id, created_at, updated_at)
|
||||
VALUES
|
||||
(1, 1, 1, NULL, NULL),
|
||||
(2, 1, 2, NULL, NULL),
|
||||
(3, 1, 10, NULL, NULL),
|
||||
(4, 2, 3, NULL, NULL),
|
||||
(5, 3, 9, NULL, NULL),
|
||||
(6, 4, 1, NULL, NULL),
|
||||
(7, 4, 4, NULL, NULL),
|
||||
(8, 5, 5, NULL, NULL),
|
||||
(9, 6, 7, NULL, NULL),
|
||||
(10, 7, 1, NULL, NULL),
|
||||
(11, 8, 10, NULL, NULL),
|
||||
(12, 9, 6, NULL, NULL),
|
||||
(13, 10, 8, NULL, NULL);
|
||||
```
|
||||
@@ -6,6 +6,8 @@ use App\Http\Requests\StoreBilletRequest;
|
||||
use App\Http\Requests\UpdateBilletRequest;
|
||||
use App\Models\Billet;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BilletController extends Controller
|
||||
{
|
||||
/**
|
||||
@@ -13,7 +15,13 @@ class BilletController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$billets = Billet::all();
|
||||
Log::info("coucou");
|
||||
try {
|
||||
$billets = Billet::all();
|
||||
} catch (\Illuminate\Database\QueryException $e) {
|
||||
Log::channel('projectError')->error('Erreur d\'accès à la base de données');
|
||||
return view('errors.unavailable');
|
||||
}
|
||||
return view('index', compact('billets'));
|
||||
}
|
||||
|
||||
@@ -39,6 +47,8 @@ class BilletController extends Controller
|
||||
public function show(Billet $billet)
|
||||
{
|
||||
//
|
||||
$commentaires = $billet->commentaires;
|
||||
return view('vBillet', compact('billet', 'commentaires'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
66
laravel/app/Http/Controllers/CategorieController.php
Normal file
66
laravel/app/Http/Controllers/CategorieController.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\StoreCategorieRequest;
|
||||
use App\Http\Requests\UpdateCategorieRequest;
|
||||
use App\Models\Categorie;
|
||||
|
||||
class CategorieController 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(StoreCategorieRequest $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Categorie $categorie)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Categorie $categorie)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(UpdateCategorieRequest $request, Categorie $categorie)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Categorie $categorie)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
66
laravel/app/Http/Controllers/CommentaireController.php
Normal file
66
laravel/app/Http/Controllers/CommentaireController.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\StoreCommentaireRequest;
|
||||
use App\Http\Requests\UpdateCommentaireRequest;
|
||||
use App\Models\Commentaire;
|
||||
|
||||
class CommentaireController 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(StoreCommentaireRequest $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Commentaire $commentaire)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Commentaire $commentaire)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(UpdateCommentaireRequest $request, Commentaire $commentaire)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Commentaire $commentaire)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
28
laravel/app/Http/Requests/StoreCategorieRequest.php
Normal file
28
laravel/app/Http/Requests/StoreCategorieRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreCategorieRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
28
laravel/app/Http/Requests/StoreCommentaireRequest.php
Normal file
28
laravel/app/Http/Requests/StoreCommentaireRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreCommentaireRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
28
laravel/app/Http/Requests/UpdateCategorieRequest.php
Normal file
28
laravel/app/Http/Requests/UpdateCategorieRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateCategorieRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
28
laravel/app/Http/Requests/UpdateCommentaireRequest.php
Normal file
28
laravel/app/Http/Requests/UpdateCommentaireRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateCommentaireRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -9,4 +9,22 @@ class Billet extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\BilletFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'BIL_DATE',
|
||||
'BIL_TITRE',
|
||||
'BIL_CONTENU',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function commentaires()
|
||||
{
|
||||
return $this->hasMany(Commentaire::class);
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->belongsToMany(Categorie::class);
|
||||
}
|
||||
}
|
||||
|
||||
17
laravel/app/Models/Categorie.php
Normal file
17
laravel/app/Models/Categorie.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Categorie extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\CategorieFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public function billets()
|
||||
{
|
||||
return $this->belongsToMany(Billet::class);
|
||||
}
|
||||
}
|
||||
26
laravel/app/Models/Commentaire.php
Normal file
26
laravel/app/Models/Commentaire.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Commentaire extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\CommentaireFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'COM_DATE',
|
||||
'COM_AUTEUR',
|
||||
'COM_CONTENU',
|
||||
'billet_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function billet()
|
||||
{
|
||||
return $this->belongsTo(Billet::class, 'billet_id');
|
||||
}
|
||||
}
|
||||
12
laravel/app/Models/billet_categorie.php
Normal file
12
laravel/app/Models/billet_categorie.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class billet_categorie extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\BilletCategorieFactory> */
|
||||
use HasFactory;
|
||||
}
|
||||
66
laravel/app/Policies/CategoriePolicy.php
Normal file
66
laravel/app/Policies/CategoriePolicy.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Categorie;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class CategoriePolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Categorie $categorie): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Categorie $categorie): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Categorie $categorie): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Categorie $categorie): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, Categorie $categorie): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
66
laravel/app/Policies/CommentairePolicy.php
Normal file
66
laravel/app/Policies/CommentairePolicy.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Commentaire;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class CommentairePolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Commentaire $commentaire): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Commentaire $commentaire): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Commentaire $commentaire): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Commentaire $commentaire): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, Commentaire $commentaire): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -127,6 +127,12 @@ return [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
"projectError" => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/project.log'),
|
||||
'level' => 'error',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
23
laravel/database/factories/BilletCategorieFactory.php
Normal file
23
laravel/database/factories/BilletCategorieFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\billet_categorie>
|
||||
*/
|
||||
class BilletCategorieFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
24
laravel/database/factories/CategorieFactory.php
Normal file
24
laravel/database/factories/CategorieFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Categorie>
|
||||
*/
|
||||
class CategorieFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'CAT_NOM' => fake()->text(10),
|
||||
];
|
||||
}
|
||||
}
|
||||
29
laravel/database/factories/CommentaireFactory.php
Normal file
29
laravel/database/factories/CommentaireFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Commentaire>
|
||||
*/
|
||||
class CommentaireFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'COM_DATE' => now(),
|
||||
'COM_AUTEUR' => fake()->lastName(),
|
||||
'COM_CONTENU' => fake()->text(200),
|
||||
'billet_id' => fake()->numberBetween(1,10),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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('commentaires', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->date('COM_DATE');
|
||||
$table->text('COM_AUTEUR');
|
||||
$table->text('COM_CONTENU');
|
||||
$table->unsignedBigInteger('billet_id');
|
||||
$table->foreign('billet_id')
|
||||
->references('id')
|
||||
->on('billets')
|
||||
->onDelete('cascade')
|
||||
->onUpdate('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('commentaires');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->text('CAT_NOM');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('categories');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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('billet_categorie', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('billet_id');
|
||||
$table->foreign('billet_id')
|
||||
->references('id')
|
||||
->on('billets')
|
||||
->onDelete('cascade')
|
||||
->onUpdate('cascade');
|
||||
$table->unsignedBigInteger('categorie_id');
|
||||
$table->foreign('categorie_id')
|
||||
->references('id')
|
||||
->on('categories')
|
||||
->onDelete('cascade')
|
||||
->onUpdate('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('billet_categories');
|
||||
}
|
||||
};
|
||||
19
laravel/database/seeders/CategorieSeeder.php
Normal file
19
laravel/database/seeders/CategorieSeeder.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Categorie;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CategorieSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
Categorie::factory(10)->create();
|
||||
}
|
||||
}
|
||||
20
laravel/database/seeders/CommentaireSeeder.php
Normal file
20
laravel/database/seeders/CommentaireSeeder.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Commentaire;
|
||||
|
||||
class CommentaireSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
// Create 10 comments
|
||||
Commentaire::factory(10)->create();
|
||||
}
|
||||
}
|
||||
@@ -40,3 +40,11 @@ h1 {
|
||||
#txtCommentaire {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
#titreReponses {
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
#txtCommentaire {
|
||||
width: 50%;
|
||||
}
|
||||
4
laravel/resources/views/errors/404.blade.php
Normal file
4
laravel/resources/views/errors/404.blade.php
Normal file
@@ -0,0 +1,4 @@
|
||||
@extends('layout')
|
||||
@section('contenu')
|
||||
<h2>La page demandée n'est pas disponible</h2>
|
||||
@endsection
|
||||
4
laravel/resources/views/errors/unavailable.blade.php
Normal file
4
laravel/resources/views/errors/unavailable.blade.php
Normal file
@@ -0,0 +1,4 @@
|
||||
@extends('layout')
|
||||
@section('contenu')
|
||||
<h2>La ressource demandée n'est pas disponible</h2>
|
||||
@endsection
|
||||
@@ -1,31 +1,27 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<title>Mon Blog</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="global">
|
||||
@extends('layout')
|
||||
@section('contenu')
|
||||
@foreach($billets as $billet)
|
||||
<article>
|
||||
<header>
|
||||
<a href="index.php"><h1 id="titreBlog">Mon Blog</h1></a>
|
||||
<p>Je vous souhaite la bienvenue sur ce modeste blog.</p>
|
||||
<a href="{{ route('billets.show', $billet->id) }}"><h1 class="titreBillet">{{ $billet->BIL_TITRE }}</h1></a>
|
||||
<time>{{ $billet->BIL_DATE }}</time>
|
||||
</header>
|
||||
<div id="contenu">
|
||||
@foreach($billets as $billet)
|
||||
<article>
|
||||
<header>
|
||||
<h1 class="titreBillet">{{ $billet->BIL_TITRE }}</h1>
|
||||
<time>{{ $billet->BIL_DATE }}</time>
|
||||
</header>
|
||||
<p>{{ $billet->BIL_CONTENU }}</p>
|
||||
</article>
|
||||
<hr />
|
||||
<p>
|
||||
Dans :
|
||||
@php
|
||||
$counter = 0;
|
||||
@endphp
|
||||
@foreach($billet->categories as $categorie)
|
||||
{{ $categorie->CAT_NOM }}
|
||||
@php
|
||||
$counter++;
|
||||
@endphp
|
||||
@if(count($billet->categories) > $counter)
|
||||
/
|
||||
@endif
|
||||
@endforeach
|
||||
</div> <!-- #contenu -->
|
||||
<footer id="piedBlog">
|
||||
Blog réalisé avec PHP, HTML5 et CSS.
|
||||
</footer>
|
||||
</div> <!-- #global -->
|
||||
</body>
|
||||
</html>
|
||||
</p>
|
||||
<p>{{ $billet->BIL_CONTENU }}</p>
|
||||
</article>
|
||||
@endforeach
|
||||
@endsection
|
||||
23
laravel/resources/views/layout.blade.php
Normal file
23
laravel/resources/views/layout.blade.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<!--link rel="stylesheet" href="style.css" /-->
|
||||
<link rel="stylesheet" href="{{ URL::asset('style.css') }}" />
|
||||
<title>Mon Blog</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="global">
|
||||
<header>
|
||||
<a href="{{ route('billets.index') }}"><h1 id="titreBlog">Mon Blog</h1></a>
|
||||
<p>Je vous souhaite la bienvenue sur ce modeste blog.</p>
|
||||
</header>
|
||||
<div id="contenu">
|
||||
@yield('contenu')
|
||||
</div> <!-- #contenu -->
|
||||
<footer id="piedBlog">
|
||||
Blog réalisé avec PHP, HTML5 et CSS.
|
||||
</footer>
|
||||
</div> <!-- #global -->
|
||||
</body>
|
||||
</html>
|
||||
24
laravel/resources/views/vBillet.blade.php
Normal file
24
laravel/resources/views/vBillet.blade.php
Normal file
@@ -0,0 +1,24 @@
|
||||
@extends('layout')
|
||||
@section('contenu')
|
||||
<article>
|
||||
<header>
|
||||
<h1 class="titreBillet">{{ $billet->BIL_TITRE }}</h1>
|
||||
<time>{{ $billet->BIL_DATE }}</time>
|
||||
</header>
|
||||
<p>{{ $billet->BIL_CONTENU }}</p>
|
||||
</article>
|
||||
<hr />
|
||||
@if (count($commentaires) > 0)
|
||||
<header>
|
||||
<h1 id="titreReponses">Réponses à {{ $billet->BIL_TITRE }}</h1>
|
||||
</header>
|
||||
@foreach($commentaires as $commentaire)
|
||||
<p>{{ $commentaire->COM_AUTEUR }} dit :</p>
|
||||
<p>{{ $commentaire->COM_CONTENU }}</p>
|
||||
@endforeach
|
||||
@else
|
||||
<header>
|
||||
<h1 id="titreReponses">Il n'y a pas de réponse à ce billet.</h1>
|
||||
</header>
|
||||
@endif
|
||||
@endsection
|
||||
0
laravel/storage/app/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/app/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/app/private/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/app/private/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/app/public/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/app/public/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/cache/data/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/cache/data/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/testing/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/testing/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/logs/.gitignore
vendored
Normal file → Executable file
0
laravel/storage/logs/.gitignore
vendored
Normal file → Executable file
Reference in New Issue
Block a user