to squeeze
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\StoreBilletRequest;
|
||||
use App\Http\Requests\UpdateBilletRequest;
|
||||
use App\Models\Billet;
|
||||
use App\Http\Resources\BilletResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BilletController extends Controller
|
||||
{
|
||||
@@ -13,22 +14,22 @@ class BilletController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$billets = Billet::all();
|
||||
return view('index', compact('billets'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
//Return all posts in json format
|
||||
try {
|
||||
return BilletResource::collection(Billet::with('commentaires')->get());
|
||||
}
|
||||
catch (\Illuminate\Database\QueryException $e){
|
||||
Log::channel('projectError')->error('Erreur accès base de données');
|
||||
return response()->json([
|
||||
'message' => 'Ressource indinponible.'
|
||||
],500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(StoreBilletRequest $request)
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -38,21 +39,21 @@ class BilletController extends Controller
|
||||
*/
|
||||
public function show(Billet $billet)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Billet $billet)
|
||||
{
|
||||
//
|
||||
try{
|
||||
return new BilletResource($billet);
|
||||
}
|
||||
catch (\Illuminate\Database\QueryException $e){
|
||||
Log::channel('projectError')->error('Erreur accès base de données');
|
||||
return response()->json([
|
||||
'message' => 'Ressource indinponible.'
|
||||
],500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(UpdateBilletRequest $request, Billet $billet)
|
||||
public function update(Request $request, Billet $billet)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
60
laravel/app/Http/Controllers/CommentaireController.php
Normal file
60
laravel/app/Http/Controllers/CommentaireController.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Commentaire;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CommentaireController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
try {
|
||||
$commentaire = Commentaire::create($request->all());
|
||||
return response()->json($commentaire,201);
|
||||
}
|
||||
catch(\Illuminate\Database\QueryException $e){
|
||||
Log::channel('projectError')->error('Erreur accès base de données\n'.$e->getMessage());
|
||||
return response()->json([
|
||||
'message' => 'Ressource indisponible.'
|
||||
],500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Commentaire $commentaire)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Commentaire $commentaire)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Commentaire $commentaire)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
0
laravel/app/Http/Controllers/Controller.php
Normal file → Executable file
0
laravel/app/Http/Controllers/Controller.php
Normal file → Executable file
0
laravel/app/Http/Requests/StoreBilletRequest.php
Normal file → Executable file
0
laravel/app/Http/Requests/StoreBilletRequest.php
Normal file → Executable file
0
laravel/app/Http/Requests/UpdateBilletRequest.php
Normal file → Executable file
0
laravel/app/Http/Requests/UpdateBilletRequest.php
Normal file → Executable file
25
laravel/app/Http/Resources/BilletResource.php
Normal file
25
laravel/app/Http/Resources/BilletResource.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class BilletResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
//return parent::toArray($request);
|
||||
return [
|
||||
'Date' => $this->BIL_DATE,
|
||||
'Titre' => $this->BIL_TITRE,
|
||||
'Contenu' => $this->BIL_CONTENU,
|
||||
'Commentaires' => CommentaireResource::collection($this->commentaires),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
laravel/app/Http/Resources/CommentaireResource.php
Normal file
24
laravel/app/Http/Resources/CommentaireResource.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CommentaireResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
//return parent::toArray($request);
|
||||
return [
|
||||
'Date' => $this->COM_DATE,
|
||||
'Auteur' => $this->COM_AUTEUR,
|
||||
'Contenu' => $this->COM_CONTENU,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Billet
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon $BIL_DATE
|
||||
* @property string $BIL_TITRE
|
||||
* @property string $BIL_CONTENU
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property Collection|BilletCategorie[] $billet_categories
|
||||
* @property Collection|Commentaire[] $commentaires
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Billet extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\BilletFactory> */
|
||||
use HasFactory;
|
||||
protected $table = 'billets';
|
||||
|
||||
protected $casts = [
|
||||
'BIL_DATE' => 'datetime'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'BIL_DATE',
|
||||
'BIL_TITRE',
|
||||
'BIL_CONTENU'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'id',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
|
||||
public function billet_categories()
|
||||
{
|
||||
return $this->hasMany(BilletCategorie::class);
|
||||
}
|
||||
|
||||
public function commentaires()
|
||||
{
|
||||
return $this->hasMany(Commentaire::class);
|
||||
}
|
||||
}
|
||||
|
||||
49
laravel/app/Models/BilletCategorie.php
Normal file
49
laravel/app/Models/BilletCategorie.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class BilletCategorie
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $billet_id
|
||||
* @property int $categorie_id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property Billet $billet
|
||||
* @property Category $category
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class BilletCategorie extends Model
|
||||
{
|
||||
protected $table = 'billet_categorie';
|
||||
|
||||
protected $casts = [
|
||||
'billet_id' => 'int',
|
||||
'categorie_id' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'billet_id',
|
||||
'categorie_id'
|
||||
];
|
||||
|
||||
public function billet()
|
||||
{
|
||||
return $this->belongsTo(Billet::class);
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(Category::class, 'categorie_id');
|
||||
}
|
||||
}
|
||||
35
laravel/app/Models/Cache.php
Executable file
35
laravel/app/Models/Cache.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Cache
|
||||
*
|
||||
* @property string $key
|
||||
* @property string $value
|
||||
* @property int $expiration
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Cache extends Model
|
||||
{
|
||||
protected $table = 'cache';
|
||||
protected $primaryKey = 'key';
|
||||
public $incrementing = false;
|
||||
public $timestamps = false;
|
||||
|
||||
protected $casts = [
|
||||
'expiration' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'value',
|
||||
'expiration'
|
||||
];
|
||||
}
|
||||
35
laravel/app/Models/CacheLock.php
Executable file
35
laravel/app/Models/CacheLock.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class CacheLock
|
||||
*
|
||||
* @property string $key
|
||||
* @property string $owner
|
||||
* @property int $expiration
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class CacheLock extends Model
|
||||
{
|
||||
protected $table = 'cache_locks';
|
||||
protected $primaryKey = 'key';
|
||||
public $incrementing = false;
|
||||
public $timestamps = false;
|
||||
|
||||
protected $casts = [
|
||||
'expiration' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'owner',
|
||||
'expiration'
|
||||
];
|
||||
}
|
||||
37
laravel/app/Models/Category.php
Normal file
37
laravel/app/Models/Category.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $CAT_NOM
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property Collection|BilletCategorie[] $billet_categories
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
protected $table = 'categories';
|
||||
|
||||
protected $fillable = [
|
||||
'CAT_NOM'
|
||||
];
|
||||
|
||||
public function billet_categories()
|
||||
{
|
||||
return $this->hasMany(BilletCategorie::class, 'categorie_id');
|
||||
}
|
||||
}
|
||||
54
laravel/app/Models/Commentaire.php
Normal file
54
laravel/app/Models/Commentaire.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Commentaire
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon $COM_DATE
|
||||
* @property string $COM_AUTEUR
|
||||
* @property string $COM_CONTENU
|
||||
* @property int $billet_id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property Billet $billet
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Commentaire extends Model
|
||||
{
|
||||
protected $table = 'commentaires';
|
||||
|
||||
protected $casts = [
|
||||
'COM_DATE' => 'datetime',
|
||||
'billet_id' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'COM_DATE',
|
||||
'COM_AUTEUR',
|
||||
'COM_CONTENU',
|
||||
'billet_id'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'billet_id'
|
||||
];
|
||||
|
||||
public function billet()
|
||||
{
|
||||
return $this->belongsTo(Billet::class);
|
||||
}
|
||||
}
|
||||
42
laravel/app/Models/Job.php
Executable file
42
laravel/app/Models/Job.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Job
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $queue
|
||||
* @property string $payload
|
||||
* @property int $attempts
|
||||
* @property int|null $reserved_at
|
||||
* @property int $available_at
|
||||
* @property int $created_at
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Job extends Model
|
||||
{
|
||||
protected $table = 'jobs';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $casts = [
|
||||
'attempts' => 'int',
|
||||
'reserved_at' => 'int',
|
||||
'available_at' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'queue',
|
||||
'payload',
|
||||
'attempts',
|
||||
'reserved_at',
|
||||
'available_at'
|
||||
];
|
||||
}
|
||||
51
laravel/app/Models/JobBatch.php
Executable file
51
laravel/app/Models/JobBatch.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class JobBatch
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $name
|
||||
* @property int $total_jobs
|
||||
* @property int $pending_jobs
|
||||
* @property int $failed_jobs
|
||||
* @property string $failed_job_ids
|
||||
* @property string|null $options
|
||||
* @property int|null $cancelled_at
|
||||
* @property int $created_at
|
||||
* @property int|null $finished_at
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class JobBatch extends Model
|
||||
{
|
||||
protected $table = 'job_batches';
|
||||
public $incrementing = false;
|
||||
public $timestamps = false;
|
||||
|
||||
protected $casts = [
|
||||
'total_jobs' => 'int',
|
||||
'pending_jobs' => 'int',
|
||||
'failed_jobs' => 'int',
|
||||
'cancelled_at' => 'int',
|
||||
'finished_at' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'total_jobs',
|
||||
'pending_jobs',
|
||||
'failed_jobs',
|
||||
'failed_job_ids',
|
||||
'options',
|
||||
'cancelled_at',
|
||||
'finished_at'
|
||||
];
|
||||
}
|
||||
41
laravel/app/Models/Session.php
Executable file
41
laravel/app/Models/Session.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Session
|
||||
*
|
||||
* @property string $id
|
||||
* @property int|null $user_id
|
||||
* @property string|null $ip_address
|
||||
* @property string|null $user_agent
|
||||
* @property string $payload
|
||||
* @property int $last_activity
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Session extends Model
|
||||
{
|
||||
protected $table = 'sessions';
|
||||
public $incrementing = false;
|
||||
public $timestamps = false;
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'last_activity' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'ip_address',
|
||||
'user_agent',
|
||||
'payload',
|
||||
'last_activity'
|
||||
];
|
||||
}
|
||||
74
laravel/app/Models/User.php
Normal file → Executable file
74
laravel/app/Models/User.php
Normal file → Executable file
@@ -1,48 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class User extends Authenticatable
|
||||
/**
|
||||
* Class User
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property Carbon|null $email_verified_at
|
||||
* @property string $password
|
||||
* @property string|null $remember_token
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class User extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
protected $table = 'users';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'email_verified_at',
|
||||
'password',
|
||||
'remember_token'
|
||||
];
|
||||
}
|
||||
|
||||
0
laravel/app/Policies/BilletPolicy.php
Normal file → Executable file
0
laravel/app/Policies/BilletPolicy.php
Normal file → Executable file
0
laravel/app/Providers/AppServiceProvider.php
Normal file → Executable file
0
laravel/app/Providers/AppServiceProvider.php
Normal file → Executable file
Reference in New Issue
Block a user