'billets' table + pages
This commit is contained in:
67
laravel/app/Http/Controllers/BilletController.php
Normal file
67
laravel/app/Http/Controllers/BilletController.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\StoreBilletRequest;
|
||||
use App\Http\Requests\UpdateBilletRequest;
|
||||
use App\Models\Billet;
|
||||
|
||||
class BilletController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$billets = Billet::all();
|
||||
return view('index', compact('billets'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(StoreBilletRequest $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Billet $billet)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Billet $billet)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(UpdateBilletRequest $request, Billet $billet)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Billet $billet)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
28
laravel/app/Http/Requests/StoreBilletRequest.php
Normal file
28
laravel/app/Http/Requests/StoreBilletRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreBilletRequest 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/UpdateBilletRequest.php
Normal file
28
laravel/app/Http/Requests/UpdateBilletRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateBilletRequest 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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
12
laravel/app/Models/Billet.php
Normal file
12
laravel/app/Models/Billet.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Billet extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\BilletFactory> */
|
||||
use HasFactory;
|
||||
}
|
||||
66
laravel/app/Policies/BilletPolicy.php
Normal file
66
laravel/app/Policies/BilletPolicy.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Billet;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class BilletPolicy
|
||||
{
|
||||
/**
|
||||
* 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, Billet $billet): 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, Billet $billet): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Billet $billet): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Billet $billet): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, Billet $billet): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -67,9 +67,9 @@ return [
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'database' => env('DB_DATABASE', 'laravel_db'),
|
||||
'username' => env('DB_USERNAME', 'laravel_user'),
|
||||
'password' => env('DB_PASSWORD', 'super_strong_password'),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
|
||||
27
laravel/database/factories/BilletFactory.php
Normal file
27
laravel/database/factories/BilletFactory.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Billet>
|
||||
*/
|
||||
class BilletFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'BIL_DATE' => now(),
|
||||
'BIL_TITRE' => fake()->text(20),
|
||||
'BIL_CONTENU' => fake()->text(100),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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('billets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->date('BIL_DATE');
|
||||
$table->text('BIL_TITRE');
|
||||
$table->text('BIL_CONTENU');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('billets');
|
||||
}
|
||||
};
|
||||
18
laravel/database/seeders/BilletSeeder.php
Normal file
18
laravel/database/seeders/BilletSeeder.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Billet;
|
||||
|
||||
class BilletSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Billet::factory(10)->create();
|
||||
}
|
||||
}
|
||||
42
laravel/public/style.css
Normal file
42
laravel/public/style.css
Normal file
@@ -0,0 +1,42 @@
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #bfbfbf;
|
||||
background: black;
|
||||
font-family: 'Futura-Medium', 'Futura', 'Trebuchet MS', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.titreBillet {
|
||||
margin-bottom : 0px;
|
||||
}
|
||||
|
||||
#global {
|
||||
min-height: 100%; /* Voir commentaire sur html et body plus haut */
|
||||
background: #333534;
|
||||
width: 70%;
|
||||
margin: auto; /* Permet de centrer la div */
|
||||
text-align: justify;
|
||||
padding: 5px 20px;
|
||||
}
|
||||
|
||||
#contenu {
|
||||
margin-bottom : 30px;
|
||||
}
|
||||
|
||||
#titreBlog, #piedBlog {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#titreReponses {
|
||||
font-size : 100%;
|
||||
}
|
||||
|
||||
#txtCommentaire {
|
||||
width: 50%;
|
||||
}
|
||||
31
laravel/resources/views/index.blade.php
Normal file
31
laravel/resources/views/index.blade.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<!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">
|
||||
<header>
|
||||
<a href="index.php"><h1 id="titreBlog">Mon Blog</h1></a>
|
||||
<p>Je vous souhaite la bienvenue sur ce modeste blog.</p>
|
||||
</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 />
|
||||
@endforeach
|
||||
</div> <!-- #contenu -->
|
||||
<footer id="piedBlog">
|
||||
Blog réalisé avec PHP, HTML5 et CSS.
|
||||
</footer>
|
||||
</div> <!-- #global -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,10 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\BilletController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
Route::resource('billets', BilletController::class);
|
||||
|
||||
Reference in New Issue
Block a user