diff --git a/composer.json b/composer.json index 180ed3f0149237aa1653a47371acadad5a30e090..d3785853dec0e5a1831ac3704398881812ddbaab 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "autoload":{ "psr-4": { - "ccd\\" : "src/" + "gp\\" : "src/" } } } diff --git a/src/modeles/Apporte.php b/src/modeles/Apporte.php new file mode 100644 index 0000000000000000000000000000000000000000..94788c9ae4dcb5941519a8dc1703521bbcde68e8 --- /dev/null +++ b/src/modeles/Apporte.php @@ -0,0 +1,18 @@ +<?php + + + + +use Illuminate\Database\Eloquent\Builder; +class Apporte extends \Illuminate\Database\Eloquent\Model +{ + protected $table = 'apporte'; + protected $primaryKey = ['idCli', 'idIngre', 'idEvent']; + public $timestamps = false; + public $incrementing = false; + + public function ingredient() + { + return $this->hasOne('\fridgie\modeles\Ingredient', 'idIngre'); + } +} diff --git a/src/modeles/Client.php b/src/modeles/Client.php new file mode 100644 index 0000000000000000000000000000000000000000..39527ecfe8e95df398133aefdf293817a1df9d44 --- /dev/null +++ b/src/modeles/Client.php @@ -0,0 +1,13 @@ +<?php + + +namespace fridgie\modeles; + + +class Client extends \Illuminate\Database\Eloquent\Model +{ + protected $table = 'client'; + protected $primaryKey = 'idCli'; + public $timestamps = false ; + +} \ No newline at end of file diff --git a/src/modeles/Contient.php b/src/modeles/Contient.php new file mode 100644 index 0000000000000000000000000000000000000000..55efc803b254c3fa483cb95214c269ae1bd60f6a --- /dev/null +++ b/src/modeles/Contient.php @@ -0,0 +1,61 @@ +<?php + + +namespace fridgie\modeles; + +use Illuminate\Database\Eloquent\Builder; +class Contient extends \Illuminate\Database\Eloquent\Model +{ + protected $table = 'contient'; + protected $primaryKey = ['idRecette', 'idIngre']; + public $timestamps = false ; + public $incrementing = false; + + + public function recette() { + return $this->belongsTo('fridgie\modeles\Recette', 'idRecette'); + } + + public function ingredient() { + return $this->hasOne('fridgie\modeles\Ingredient', 'idIngre'); + } + + /** + * Set the keys for a save update query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return \Illuminate\Database\Eloquent\Builder + */ + protected function setKeysForSaveQuery(Builder $query) + { + $keys = $this->getKeyName(); + if(!is_array($keys)){ + return parent::setKeysForSaveQuery($query); + } + + foreach($keys as $keyName){ + $query->where($keyName, '=', $this->getKeyForSaveQuery($keyName)); + } + + return $query; + } + + /** + * Get the primary key value for a save query. + * + * @param mixed $keyName + * @return mixed + */ + protected function getKeyForSaveQuery($keyName = null) + { + if(is_null($keyName)){ + $keyName = $this->getKeyName(); + } + + if (isset($this->original[$keyName])) { + return $this->original[$keyName]; + } + + return $this->getAttribute($keyName); + } +} \ No newline at end of file