Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8579855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:42:02+00:00 2026-06-11T20:42:02+00:00

May be a stupid question. Since my controller and model is too big (also

  • 0

May be a stupid question.

Since my controller and model is too big (also I don’t want to mess up with old modules), I want to create a new controller and model and I want to separate the code from existing..That is, I want to move some code from users controller and user model to billing controller and billing model (there is no billings table, all info is storing is users table, so I given useTable=’users’). I don’t want to execute any of the code written in user model, while executing the billings controller, only BillingModel code needs to be executed.

BusinessController

class BillingsController extends AppController 
{

    function add()
    {
        if (!empty($this->request->data)) 
        {
            $this->Billing->create();
            if ($this->Billing->save($this->request->data)) 
            {
                echo 'Saved'; // Message, redirect etc
            }
        }
    }
}

BillingModel

class Billing extends AppModel {


    public $useTable = 'users';

        public $hasOne = array('Profile');

public $validate = array(
        'email' => array(
            'email' => array(
                'rule' => 'email',
                'message' => 'Please provide a valid email address.',
                'last' => true,
            ),
                 'first_name' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Please enter your name',
            ),
                    )
        );

}

All Form fields will have data[Business] as prefix.

The data is saving correctly into the database. I just want to know, anything wrong with this approach ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:42:03+00:00Added an answer on June 11, 2026 at 8:42 pm

    In this case, as I understand you are duplicating some code in both models (validation, relations ect.) In my opinion better solution would be to extend Users model with Billing

    class Billing extends Users {
    
    }
    

    the same situation is with controller:

    class BillingsController extends UsersController 
    {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a stupid question, but I'll feel stupider if I don't ask
I know this question may seems stupid since i cannot give a lot of
I have a simple (may be stupid) question. I want to calculate Kullback–Leibler divergence
This may be stupid question, but I am looking at Ninject sources and don't
I know this may be stupid question i am gonna put here since i
I know this may be a stupid question to ask but I want to
Sorry for the stupid question, but since i don't know the inner workings of
This may be a stupid question but I have a code with the following
This may be a stupid question, but I'm trying to replicate a customer's OpenLDAP
This may be a stupid question, as I'm not sure how MSBuild works with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.