get clients
This commit is contained in:
parent
798996b615
commit
8bc9e962b7
63
app/Http/Controllers/ClientsController.php
Normal file
63
app/Http/Controllers/ClientsController.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Clients;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ClientsController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
return Clients::all();
|
||||
//return response()->json(['Clients' => Clients::all(), 'status' => 'OK'], 200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
27
app/Models/Categories.php
Normal file
27
app/Models/Categories.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Categories extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "Categories";
|
||||
protected $primaryKey = "id";
|
||||
public $incrementing = true;
|
||||
public $timestamps = true;
|
||||
protected $casts = [
|
||||
'created_at' => 'timestamp',
|
||||
'updated_at' => 'timestamp',
|
||||
];
|
||||
|
||||
public function Produits(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany('App\Models\Produits', 'produits_categories', 'categories_id', 'products_id');
|
||||
}
|
||||
|
||||
}
|
26
app/Models/Clients.php
Normal file
26
app/Models/Clients.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Clients extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "clients";
|
||||
protected $primaryKey = "id";
|
||||
public $incrementing = true;
|
||||
public $timestamps = true;
|
||||
protected $casts = [
|
||||
'adresse' => 'json',
|
||||
'created_at' => 'timestamp',
|
||||
'updated_at' => 'timestamp',
|
||||
];
|
||||
|
||||
public function Commandes(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\Commandes', 'clients_id', 'id');
|
||||
}
|
||||
}
|
33
app/Models/Commandes.php
Normal file
33
app/Models/Commandes.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Commandes extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "Commandes";
|
||||
protected $primaryKey = "id";
|
||||
public $incrementing = true;
|
||||
public $timestamps = true;
|
||||
protected $casts = [
|
||||
'adresse' => 'json',
|
||||
'created_at' => 'timestamp',
|
||||
'updated_at' => 'timestamp',
|
||||
];
|
||||
|
||||
public function Client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo('App\Models\Clients', 'clients_id', 'id');
|
||||
}
|
||||
|
||||
public function LignesCommandes(): HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\Lignes_Commandes', 'comandes_id', 'id');
|
||||
}
|
||||
}
|
32
app/Models/Lignes_Commandes.php
Normal file
32
app/Models/Lignes_Commandes.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Lignes_Commandes extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "Lignes_Commandes";
|
||||
protected $primaryKey = "id";
|
||||
public $incrementing = true;
|
||||
public $timestamps = true;
|
||||
protected $casts = [
|
||||
'created_at' => 'timestamp',
|
||||
'updated_at' => 'timestamp',
|
||||
];
|
||||
|
||||
public function Produit(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo('App\Models\Produits', 'produits_id', 'id');
|
||||
}
|
||||
|
||||
public function Commandes(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo('App\Models\Commandes', 'commandes_id', 'id');
|
||||
}
|
||||
|
||||
}
|
33
app/Models/Produits.php
Normal file
33
app/Models/Produits.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Produits extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "Produits";
|
||||
protected $primaryKey = "id";
|
||||
public $incrementing = true;
|
||||
public $timestamps = true;
|
||||
protected $casts = [
|
||||
'created_at' => 'timestamp',
|
||||
'updated_at' => 'timestamp',
|
||||
];
|
||||
|
||||
public function Categories(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany('App\Models\Categories', 'produits_categories', 'products_id', 'categories_id');
|
||||
}
|
||||
|
||||
public function LignesCommandes(): HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\Lignes_Commandes', 'produits_id', 'id');
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\ClientsController;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
@ -17,3 +18,7 @@ use Illuminate\Support\Facades\Route;
|
||||
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
|
||||
Route::apiResource('/clients', ClientsController::class);
|
||||
|
||||
//Route::get('/clients', [ClientsController::class, 'index']);
|
||||
|
Loading…
x
Reference in New Issue
Block a user