<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    /**
     * The attribute of database connection bound to the model.
     *
     * @var array
     */
    protected $connection = 'mysql';

    /**
     * Function to link database connection to constructor of model
     * Avec cette fonctionn, on instancie un objet dans une base de donnée qu'on peut utiliser
     *
     * @var array
     */
    public function __construct($connection = 'mysql')
    {
        $this->connection = $connection;
    }

    public function articles()
    {
        return $this->hasMany(Article::class);
    }

    public function sujets()
    {
        return $this->hasMany(Sujet::class);
    }

    public function commentaires()
    {
        return $this->hasMany(Commentaire::class);
    }

    public function themes()
    {
        return $this->hasMany(Theme::class);
    }

    public function documents()
    {
        return $this->hasMany(Document::class);
    }

    public function profile()
    {
        return $this->hasOne(Profile::class);
    }
}
