<?php

namespace App\Models;

use CodeIgniter\Model;

class ContributionModel extends Model
{
    protected $table = 'contribution';
    protected $primaryKey = 'id';
    protected $useTimestamps    = true; // Active les champs created_at et updated_at


    protected $allowedFields = [
        'nom',
        'telephone',
        'email',
        'region',
        'departement',
        'thematique',
        'description',
        'file'
    ];

    public function getTotalContributions()
   {
    return $this->db->table('contribution')->countAllResults();
   }
    public function compteParCanal($canal)
    {
        return $this->where('canal', $canal)->countAllResults();
    }

    public function compteFiles()
   {
    return $this->where('file IS NOT NULL')
                ->where('file !=', '')
                ->countAllResults();
    }  



    
}