From 26b080447efcaa54e645a907beedb8493f957ddd Mon Sep 17 00:00:00 2001
From: Cahit Percin <cahit.percin7@etu.univ-lorraine.fr>
Date: Wed, 4 Mar 2020 10:38:17 +0100
Subject: [PATCH] preparation seance 2

---
 GamePedia/composer.lock                       | 119 ++++----------
 Gamepedia2.png => prepseance2/Gamepedia2.png  | Bin
 prepseance2/composer.lock                     | 119 ++++----------
 prepseance2/index.php                         |  39 +++--
 prepseance2/seance2.sql                       | 147 ++++++++++++++++++
 prepseance2/src/models/Annonce.php            |  17 ++
 .../models/{categorie.php => Categorie.php}   |   5 +-
 prepseance2/src/models/Photo.php              |  13 ++
 prepseance2/src/models/annonce.php            |  19 ---
 prepseance2/src/models/photo.php              |  14 --
 10 files changed, 263 insertions(+), 229 deletions(-)
 rename Gamepedia2.png => prepseance2/Gamepedia2.png (100%)
 create mode 100644 prepseance2/seance2.sql
 create mode 100644 prepseance2/src/models/Annonce.php
 rename prepseance2/src/models/{categorie.php => Categorie.php} (53%)
 create mode 100644 prepseance2/src/models/Photo.php
 delete mode 100644 prepseance2/src/models/annonce.php
 delete mode 100644 prepseance2/src/models/photo.php

diff --git a/GamePedia/composer.lock b/GamePedia/composer.lock
index 8295e51..4bbf2c8 100644
--- a/GamePedia/composer.lock
+++ b/GamePedia/composer.lock
@@ -1,27 +1,27 @@
 {
     "_readme": [
         "This file locks the dependencies of your project to a known state",
-        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
     "content-hash": "cc18e66e95cadfdfa2cb91becd1b4524",
     "packages": [
         {
             "name": "doctrine/inflector",
-            "version": "1.3.1",
+            "version": "v1.2.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/doctrine/inflector.git",
-                "reference": "ec3a55242203ffa6a4b27c58176da97ff0a7aec1"
+                "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/doctrine/inflector/zipball/ec3a55242203ffa6a4b27c58176da97ff0a7aec1",
-                "reference": "ec3a55242203ffa6a4b27c58176da97ff0a7aec1",
+                "url": "https://api.github.com/repos/doctrine/inflector/zipball/e11d84c6e018beedd929cff5220969a3c6d1d462",
+                "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462",
                 "shasum": ""
             },
             "require": {
-                "php": "^7.1"
+                "php": "^7.0"
             },
             "require-dev": {
                 "phpunit/phpunit": "^6.2"
@@ -29,7 +29,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "1.3.x-dev"
+                    "dev-master": "1.2.x-dev"
                 }
             },
             "autoload": {
@@ -42,10 +42,6 @@
                 "MIT"
             ],
             "authors": [
-                {
-                    "name": "Guilherme Blanco",
-                    "email": "guilhermeblanco@gmail.com"
-                },
                 {
                     "name": "Roman Borschel",
                     "email": "roman@code-factory.org"
@@ -54,6 +50,10 @@
                     "name": "Benjamin Eberlei",
                     "email": "kontakt@beberlei.de"
                 },
+                {
+                    "name": "Guilherme Blanco",
+                    "email": "guilhermeblanco@gmail.com"
+                },
                 {
                     "name": "Jonathan Wage",
                     "email": "jonwage@gmail.com"
@@ -71,7 +71,7 @@
                 "singularize",
                 "string"
             ],
-            "time": "2019-10-30T19:59:35+00:00"
+            "time": "2017-07-22T12:18:28+00:00"
         },
         {
             "name": "illuminate/container",
@@ -632,42 +632,36 @@
         },
         {
             "name": "symfony/translation",
-            "version": "v4.4.5",
+            "version": "v3.4.38",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/translation.git",
-                "reference": "0a19a77fba20818a969ef03fdaf1602de0546353"
+                "reference": "1eb074e0bd94939a30dd14dbecf7a92b165cea34"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/translation/zipball/0a19a77fba20818a969ef03fdaf1602de0546353",
-                "reference": "0a19a77fba20818a969ef03fdaf1602de0546353",
+                "url": "https://api.github.com/repos/symfony/translation/zipball/1eb074e0bd94939a30dd14dbecf7a92b165cea34",
+                "reference": "1eb074e0bd94939a30dd14dbecf7a92b165cea34",
                 "shasum": ""
             },
             "require": {
-                "php": "^7.1.3",
-                "symfony/polyfill-mbstring": "~1.0",
-                "symfony/translation-contracts": "^1.1.6|^2"
+                "php": "^5.5.9|>=7.0.8",
+                "symfony/polyfill-mbstring": "~1.0"
             },
             "conflict": {
-                "symfony/config": "<3.4",
+                "symfony/config": "<2.8",
                 "symfony/dependency-injection": "<3.4",
-                "symfony/http-kernel": "<4.4",
                 "symfony/yaml": "<3.4"
             },
-            "provide": {
-                "symfony/translation-implementation": "1.0"
-            },
             "require-dev": {
                 "psr/log": "~1.0",
-                "symfony/config": "^3.4|^4.0|^5.0",
-                "symfony/console": "^3.4|^4.0|^5.0",
-                "symfony/dependency-injection": "^3.4|^4.0|^5.0",
-                "symfony/finder": "~2.8|~3.0|~4.0|^5.0",
-                "symfony/http-kernel": "^4.4",
-                "symfony/intl": "^3.4|^4.0|^5.0",
-                "symfony/service-contracts": "^1.1.2|^2",
-                "symfony/yaml": "^3.4|^4.0|^5.0"
+                "symfony/config": "~2.8|~3.0|~4.0",
+                "symfony/dependency-injection": "~3.4|~4.0",
+                "symfony/finder": "~2.8|~3.0|~4.0",
+                "symfony/http-kernel": "~3.4|~4.0",
+                "symfony/intl": "^2.8.18|^3.2.5|~4.0",
+                "symfony/var-dumper": "~3.4|~4.0",
+                "symfony/yaml": "~3.4|~4.0"
             },
             "suggest": {
                 "psr/log-implementation": "To use logging capability in translator",
@@ -677,7 +671,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "4.4-dev"
+                    "dev-master": "3.4-dev"
                 }
             },
             "autoload": {
@@ -704,64 +698,7 @@
             ],
             "description": "Symfony Translation Component",
             "homepage": "https://symfony.com",
-            "time": "2020-02-04T09:32:40+00:00"
-        },
-        {
-            "name": "symfony/translation-contracts",
-            "version": "v2.0.1",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/translation-contracts.git",
-                "reference": "8cc682ac458d75557203b2f2f14b0b92e1c744ed"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/8cc682ac458d75557203b2f2f14b0b92e1c744ed",
-                "reference": "8cc682ac458d75557203b2f2f14b0b92e1c744ed",
-                "shasum": ""
-            },
-            "require": {
-                "php": "^7.2.5"
-            },
-            "suggest": {
-                "symfony/translation-implementation": ""
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.0-dev"
-                }
-            },
-            "autoload": {
-                "psr-4": {
-                    "Symfony\\Contracts\\Translation\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Nicolas Grekas",
-                    "email": "p@tchwork.com"
-                },
-                {
-                    "name": "Symfony Community",
-                    "homepage": "https://symfony.com/contributors"
-                }
-            ],
-            "description": "Generic abstractions related to translation",
-            "homepage": "https://symfony.com",
-            "keywords": [
-                "abstractions",
-                "contracts",
-                "decoupling",
-                "interfaces",
-                "interoperability",
-                "standards"
-            ],
-            "time": "2019-11-18T17:27:11+00:00"
+            "time": "2020-02-04T07:22:30+00:00"
         }
     ],
     "packages-dev": [],
diff --git a/Gamepedia2.png b/prepseance2/Gamepedia2.png
similarity index 100%
rename from Gamepedia2.png
rename to prepseance2/Gamepedia2.png
diff --git a/prepseance2/composer.lock b/prepseance2/composer.lock
index c5c6058..11d5126 100644
--- a/prepseance2/composer.lock
+++ b/prepseance2/composer.lock
@@ -1,27 +1,27 @@
 {
     "_readme": [
         "This file locks the dependencies of your project to a known state",
-        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
     "content-hash": "f3df5191784ad7db53f1bdc559097748",
     "packages": [
         {
             "name": "doctrine/inflector",
-            "version": "1.3.1",
+            "version": "v1.2.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/doctrine/inflector.git",
-                "reference": "ec3a55242203ffa6a4b27c58176da97ff0a7aec1"
+                "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/doctrine/inflector/zipball/ec3a55242203ffa6a4b27c58176da97ff0a7aec1",
-                "reference": "ec3a55242203ffa6a4b27c58176da97ff0a7aec1",
+                "url": "https://api.github.com/repos/doctrine/inflector/zipball/e11d84c6e018beedd929cff5220969a3c6d1d462",
+                "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462",
                 "shasum": ""
             },
             "require": {
-                "php": "^7.1"
+                "php": "^7.0"
             },
             "require-dev": {
                 "phpunit/phpunit": "^6.2"
@@ -29,7 +29,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "1.3.x-dev"
+                    "dev-master": "1.2.x-dev"
                 }
             },
             "autoload": {
@@ -42,10 +42,6 @@
                 "MIT"
             ],
             "authors": [
-                {
-                    "name": "Guilherme Blanco",
-                    "email": "guilhermeblanco@gmail.com"
-                },
                 {
                     "name": "Roman Borschel",
                     "email": "roman@code-factory.org"
@@ -54,6 +50,10 @@
                     "name": "Benjamin Eberlei",
                     "email": "kontakt@beberlei.de"
                 },
+                {
+                    "name": "Guilherme Blanco",
+                    "email": "guilhermeblanco@gmail.com"
+                },
                 {
                     "name": "Jonathan Wage",
                     "email": "jonwage@gmail.com"
@@ -71,7 +71,7 @@
                 "singularize",
                 "string"
             ],
-            "time": "2019-10-30T19:59:35+00:00"
+            "time": "2017-07-22T12:18:28+00:00"
         },
         {
             "name": "illuminate/container",
@@ -541,42 +541,36 @@
         },
         {
             "name": "symfony/translation",
-            "version": "v4.4.5",
+            "version": "v3.4.38",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/translation.git",
-                "reference": "0a19a77fba20818a969ef03fdaf1602de0546353"
+                "reference": "1eb074e0bd94939a30dd14dbecf7a92b165cea34"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/translation/zipball/0a19a77fba20818a969ef03fdaf1602de0546353",
-                "reference": "0a19a77fba20818a969ef03fdaf1602de0546353",
+                "url": "https://api.github.com/repos/symfony/translation/zipball/1eb074e0bd94939a30dd14dbecf7a92b165cea34",
+                "reference": "1eb074e0bd94939a30dd14dbecf7a92b165cea34",
                 "shasum": ""
             },
             "require": {
-                "php": "^7.1.3",
-                "symfony/polyfill-mbstring": "~1.0",
-                "symfony/translation-contracts": "^1.1.6|^2"
+                "php": "^5.5.9|>=7.0.8",
+                "symfony/polyfill-mbstring": "~1.0"
             },
             "conflict": {
-                "symfony/config": "<3.4",
+                "symfony/config": "<2.8",
                 "symfony/dependency-injection": "<3.4",
-                "symfony/http-kernel": "<4.4",
                 "symfony/yaml": "<3.4"
             },
-            "provide": {
-                "symfony/translation-implementation": "1.0"
-            },
             "require-dev": {
                 "psr/log": "~1.0",
-                "symfony/config": "^3.4|^4.0|^5.0",
-                "symfony/console": "^3.4|^4.0|^5.0",
-                "symfony/dependency-injection": "^3.4|^4.0|^5.0",
-                "symfony/finder": "~2.8|~3.0|~4.0|^5.0",
-                "symfony/http-kernel": "^4.4",
-                "symfony/intl": "^3.4|^4.0|^5.0",
-                "symfony/service-contracts": "^1.1.2|^2",
-                "symfony/yaml": "^3.4|^4.0|^5.0"
+                "symfony/config": "~2.8|~3.0|~4.0",
+                "symfony/dependency-injection": "~3.4|~4.0",
+                "symfony/finder": "~2.8|~3.0|~4.0",
+                "symfony/http-kernel": "~3.4|~4.0",
+                "symfony/intl": "^2.8.18|^3.2.5|~4.0",
+                "symfony/var-dumper": "~3.4|~4.0",
+                "symfony/yaml": "~3.4|~4.0"
             },
             "suggest": {
                 "psr/log-implementation": "To use logging capability in translator",
@@ -586,7 +580,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "4.4-dev"
+                    "dev-master": "3.4-dev"
                 }
             },
             "autoload": {
@@ -613,64 +607,7 @@
             ],
             "description": "Symfony Translation Component",
             "homepage": "https://symfony.com",
-            "time": "2020-02-04T09:32:40+00:00"
-        },
-        {
-            "name": "symfony/translation-contracts",
-            "version": "v2.0.1",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/translation-contracts.git",
-                "reference": "8cc682ac458d75557203b2f2f14b0b92e1c744ed"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/8cc682ac458d75557203b2f2f14b0b92e1c744ed",
-                "reference": "8cc682ac458d75557203b2f2f14b0b92e1c744ed",
-                "shasum": ""
-            },
-            "require": {
-                "php": "^7.2.5"
-            },
-            "suggest": {
-                "symfony/translation-implementation": ""
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.0-dev"
-                }
-            },
-            "autoload": {
-                "psr-4": {
-                    "Symfony\\Contracts\\Translation\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Nicolas Grekas",
-                    "email": "p@tchwork.com"
-                },
-                {
-                    "name": "Symfony Community",
-                    "homepage": "https://symfony.com/contributors"
-                }
-            ],
-            "description": "Generic abstractions related to translation",
-            "homepage": "https://symfony.com",
-            "keywords": [
-                "abstractions",
-                "contracts",
-                "decoupling",
-                "interfaces",
-                "interoperability",
-                "standards"
-            ],
-            "time": "2019-11-18T17:27:11+00:00"
+            "time": "2020-02-04T07:22:30+00:00"
         }
     ],
     "packages-dev": [],
diff --git a/prepseance2/index.php b/prepseance2/index.php
index ea85a6c..a3a7a86 100644
--- a/prepseance2/index.php
+++ b/prepseance2/index.php
@@ -1,21 +1,38 @@
 <?php
 require 'vendor/autoload.php';
 use Illuminate\Database\Capsule\Manager as DB;
-use prep\models\annonce;
-use prep\models\photo;
-use prep\models\categorie;
+use prep\models\Annonce;
+use prep\models\Photo;
+use prep\models\Categorie;
 $db = new DB();
+$db->addConnection(parse_ini_file('./conf/conf.ini'));
 
+$db->setAsGlobal();
+$db->bootEloquent();
 
 
-$un = photo::where('ida', '=', 22)->get();
+$un = Photo::where('idannonce', '=', 22)->get();
 
-$deux = photo::where('ida', '=', 22)->where('taille_octet', '>', 100000)->get();
+foreach ($un as $l) {
+    echo 'Id :' . $l->idphoto . '<br>';
+    echo '<br>';
+}
 
-$quatre = annonce::photo()->where('taille_octet', '>', 100000)->get();
+$deux = Photo::where([
+    ['idannonce', '=', 22],
+    ['taille_octet', '>', 100000],
+])->get();
 
-$ajoutphoto = new photo;
-$ajoutphoto->file='test';
-$ajoutphoto->date=date('Y/m/d');
-$ajoutphoto->taille_octet=1000000;
-$ajoutphoto->save();
+
+foreach ($deux as $l) {
+   echo 'Id :' . $l->idphoto . '<br>';
+    echo '<br>';
+}
+
+//$quatre = Annonce::photo()->where('taille_octet', '>', 100000)->get();
+
+//$ajoutphoto = new Photo();
+//$ajoutphoto->file='test';
+//$ajoutphoto->date=date('Y/m/d');
+//$ajoutphoto->taille_octet=1000000;
+//$ajoutphoto->save();
diff --git a/prepseance2/seance2.sql b/prepseance2/seance2.sql
new file mode 100644
index 0000000..645aa27
--- /dev/null
+++ b/prepseance2/seance2.sql
@@ -0,0 +1,147 @@
+-- phpMyAdmin SQL Dump
+-- version 4.9.0.1
+-- https://www.phpmyadmin.net/
+--
+-- Hôte : localhost
+-- Généré le :  mer. 04 mars 2020 à 09:27
+-- Version du serveur :  5.5.64-MariaDB
+-- Version de PHP :  7.0.33
+
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET AUTOCOMMIT = 0;
+START TRANSACTION;
+SET time_zone = "+00:00";
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+--
+-- Base de données :  `percin4u`
+--
+
+-- --------------------------------------------------------
+
+--
+-- Structure de la table `annonce`
+--
+
+CREATE TABLE `annonce` (
+  `idannonce` int(11) NOT NULL,
+  `titre` varchar(128) NOT NULL,
+  `date` datetime DEFAULT NULL,
+  `descr` longtext
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Structure de la table `categorie`
+--
+
+CREATE TABLE `categorie` (
+  `idcategorie` int(11) NOT NULL,
+  `nom` varchar(128) NOT NULL,
+  `descr` longtext
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Structure de la table `categorie_annonce`
+--
+
+CREATE TABLE `categorie_annonce` (
+  `idcategorie` int(11) NOT NULL,
+  `idannonce` int(11) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Structure de la table `photo`
+--
+
+CREATE TABLE `photo` (
+  `idphoto` int(11) NOT NULL,
+  `idannonce` int(11) NOT NULL,
+  `file` varchar(128) NOT NULL,
+  `date` datetime DEFAULT NULL,
+  `taille_octet` varchar(128) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Index pour les tables déchargées
+--
+
+--
+-- Index pour la table `annonce`
+--
+ALTER TABLE `annonce`
+  ADD PRIMARY KEY (`idannonce`);
+
+--
+-- Index pour la table `categorie`
+--
+ALTER TABLE `categorie`
+  ADD PRIMARY KEY (`idcategorie`);
+
+--
+-- Index pour la table `categorie_annonce`
+--
+ALTER TABLE `categorie_annonce`
+  ADD PRIMARY KEY (`idcategorie`,`idannonce`),
+  ADD KEY `idannonce` (`idannonce`);
+
+--
+-- Index pour la table `photo`
+--
+ALTER TABLE `photo`
+  ADD PRIMARY KEY (`idphoto`),
+  ADD KEY `idannonce` (`idannonce`);
+
+--
+-- AUTO_INCREMENT pour les tables déchargées
+--
+
+--
+-- AUTO_INCREMENT pour la table `annonce`
+--
+ALTER TABLE `annonce`
+  MODIFY `idannonce` int(11) NOT NULL AUTO_INCREMENT;
+
+--
+-- AUTO_INCREMENT pour la table `categorie`
+--
+ALTER TABLE `categorie`
+  MODIFY `idcategorie` int(11) NOT NULL AUTO_INCREMENT;
+
+--
+-- AUTO_INCREMENT pour la table `photo`
+--
+ALTER TABLE `photo`
+  MODIFY `idphoto` int(11) NOT NULL AUTO_INCREMENT;
+
+--
+-- Contraintes pour les tables déchargées
+--
+
+--
+-- Contraintes pour la table `categorie_annonce`
+--
+ALTER TABLE `categorie_annonce`
+  ADD CONSTRAINT `categorie_annonce_ibfk_1` FOREIGN KEY (`idannonce`) REFERENCES `annonce` (`idannonce`),
+  ADD CONSTRAINT `categorie_annonce_ibfk_2` FOREIGN KEY (`idcategorie`) REFERENCES `categorie` (`idcategorie`);
+
+--
+-- Contraintes pour la table `photo`
+--
+ALTER TABLE `photo`
+  ADD CONSTRAINT `photo_ibfk_1` FOREIGN KEY (`idannonce`) REFERENCES `annonce` (`idannonce`);
+COMMIT;
+
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
diff --git a/prepseance2/src/models/Annonce.php b/prepseance2/src/models/Annonce.php
new file mode 100644
index 0000000..434b9cb
--- /dev/null
+++ b/prepseance2/src/models/Annonce.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace prep\models;
+
+class Annonce extends \Illuminate\Database\Eloquent\Model {
+  protected $table = 'annonce';
+  protected $primaryKey = 'idannonce';
+  public $timestamps = false;
+
+  public function categorie(){
+    return $this->belongsToMany('\prep\models\categorie', 'categorie', 'idcategorie');
+  }
+
+  public function photo(){
+    return $this->hasmany('\prep\models\photo', 'idannonce');
+  }
+}
diff --git a/prepseance2/src/models/categorie.php b/prepseance2/src/models/Categorie.php
similarity index 53%
rename from prepseance2/src/models/categorie.php
rename to prepseance2/src/models/Categorie.php
index 98d05c4..5d506cf 100644
--- a/prepseance2/src/models/categorie.php
+++ b/prepseance2/src/models/Categorie.php
@@ -2,14 +2,13 @@
 
 namespace prep\models;
 
-class categorie extends \Illuminate\Database\Eloquent\Model {
+class Categorie extends \Illuminate\Database\Eloquent\Model {
   protected $table = 'categorie';
   protected $primaryKey = 'id';
   public $timestamps = false;
 
   public function annonce(){
-    $s = 'id_cat';
-    return $this->hasmany('\mywishlist\models\photo', $s);
+    return $this->belongsToMany('\prep\models\photo', 'annonce','idannonce');
   }
 
 }
diff --git a/prepseance2/src/models/Photo.php b/prepseance2/src/models/Photo.php
new file mode 100644
index 0000000..9e2a904
--- /dev/null
+++ b/prepseance2/src/models/Photo.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace prep\models;
+
+class Photo extends \Illuminate\Database\Eloquent\Model {
+  protected $table = 'photo';
+  protected $primaryKey = 'idphoto';
+  public $timestamps = false;
+
+  public function categorie(){
+    return $this->belongsTo('\prep\models\annonce', 'idannonce');
+  }
+}
diff --git a/prepseance2/src/models/annonce.php b/prepseance2/src/models/annonce.php
deleted file mode 100644
index 921095d..0000000
--- a/prepseance2/src/models/annonce.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-namespace prep\models;
-
-class annonce extends \Illuminate\Database\Eloquent\Model {
-  protected $table = 'annonce';
-  protected $primaryKey = 'id';
-  public $timestamps = false;
-
-  public function categorie(){
-    $s = 'id_cat';
-    return $this->belongsToMany('\mywishlist\models\categorie', $s);
-  }
-
-  public function photo(){
-    $s = 'idannonce';
-    return $this->hasmany('\mywishlist\models\photo', $s);
-  }
-}
diff --git a/prepseance2/src/models/photo.php b/prepseance2/src/models/photo.php
deleted file mode 100644
index ec66db7..0000000
--- a/prepseance2/src/models/photo.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-namespace prep\models;
-
-class photo extends \Illuminate\Database\Eloquent\Model {
-  protected $table = 'annonce';
-  protected $primaryKey = 'id';
-  public $timestamps = false;
-
-  public function categorie(){
-    $s = 'idannonce';
-    return $this->belongsTo('\mywishlist\models\annonce', $s);
-  }
-}
-- 
GitLab