Set dashboard to display invoices only for that user

I’m pretty new to php and mvc framework. Just wondering how I can adjust dashboard data to only show current users invoices,quotes,etc.
I can get the user name
$this->session->userdata(‘user_name’)

but I can’t find the model now how to filter the database
here is the dashboard controller
Any help would be great
Thanks

class Dashboard extends Admin_Controller
{
    public function index()
    {
        $this->load->model('invoices/mdl_invoice_amounts');
        $this->load->model('quotes/mdl_quote_amounts');
        $this->load->model('invoices/mdl_invoices');
        $this->load->model('quotes/mdl_quotes');

        $quote_overview_period = $this->mdl_settings->setting('quote_overview_period');
        $invoice_overview_period = $this->mdl_settings->setting('invoice_overview_period');

        $this->layout->set(
            array(
                'invoice_status_totals' => $this->mdl_invoice_amounts->get_status_totals($invoice_overview_period),
                'quote_status_totals' => $this->mdl_quote_amounts->get_status_totals($quote_overview_period),
                'invoice_status_period' => str_replace('-', '_', $invoice_overview_period),
                'quote_status_period' => str_replace('-', '_', $quote_overview_period),
                'invoices' => $this->mdl_invoices->limit(10)->get()->result(),
                'quotes' => $this->mdl_quotes->limit(10)->get()->result(),
                'invoice_statuses' => $this->mdl_invoices->statuses(),
                'quote_statuses' => $this->mdl_quotes->statuses(),
                'overdue_invoices' => $this->mdl_invoices->is_overdue()->get()->result()
            )
        );

        $this->layout->buffer('content', 'dashboard/index');
        $this->layout->render();
    }

}

i figured it out

added

 'invoices' => $this->mdl_invoices->by_user($this->session->userdata('user_id'))->limit(10)->get()->result(),

this to dashboard.php

added this to mdi_invoices.php

public function by_user($user_id)
    {
        $this->filter_where('ip_invoices.user_id', $user_id);
        return $this;
    }
1 Like

I named the files where I added it to above . that is only to modify the invoices display on the dashboard

Update dashboard controller
Then add public function to invoices model down I put it down when the overdue() function was