Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. echo $this->Form->input('location');
  2.  
  3. echo $this->Form->input('location_id', array('type' => 'select', 'options' => $CompanyLocations));
  4.  
  5. public function add()
  6. {
  7. $user = $this->Users->newEntity();
  8. if ($this->request->is('post')) {
  9. $user = $this->Users->patchEntity($user, $this->request->data);
  10. if ($this->Users->save($user)) {
  11. $this->Flash->success(__('The user has been saved.'));
  12.  
  13. return $this->redirect(['action' => 'index']);
  14. }
  15. $this->Flash->error(__('The user could not be saved. Please, try again.'));
  16. }
  17. $CompanyLocations= $this->Users->CompanyLocations->find('list');
  18. $this->set(compact('CompanyLocations'));
  19. $this->set(compact('user'));
  20. $this->set('_serialize', ['user']);
  21.  
  22. $this->belongsTo('CompanyLocations');
  23.  
  24. public function initialize(array $config)
  25. {
  26. parent::initialize($config);
  27.  
  28. $this->table('company_locations');
  29. $this->displayField('location_name');
  30. $this->primaryKey('location_id');
  31.  
  32. $this->belongsTo('Locations', [
  33. 'foreignKey' => 'location_id',
  34. 'joinType' => 'INNER'
  35. ]);
  36. }
  37.  
  38. CREATE TABLE IF NOT EXISTS southpac_team.company_locations (
  39. location_id INT NOT NULL AUTO_INCREMENT,
  40. location_name VARCHAR(45) NULL,
  41. PRIMARY KEY (location_id))
  42. ENGINE = InnoDB;
  43.  
  44. DROP TABLE IF EXISTS southpac_team.users ;
  45.  
  46. CREATE TABLE IF NOT EXISTS southpac_team.users (
  47. id INT NOT NULL AUTO_INCREMENT,
  48. username VARCHAR(20) NOT NULL,
  49. password VARCHAR(255) NOT NULL,
  50. name VARCHAR(255) NOT NULL,
  51. department INT NULL,
  52. mobile VARCHAR(255) NULL,
  53. email VARCHAR(255) NULL,
  54. extension INT NULL,
  55. lame_number INT NULL,
  56. spa_auth_number VARCHAR(15) NULL,
  57. creation_date DATE NULL,
  58. picture VARCHAR(255) NULL,
  59. employed TINYINT(1) NOT NULL,
  60. location INT NOT NULL,
  61. PRIMARY KEY (id),
  62. INDEX get location_idx (location ASC),
  63. CONSTRAINT get location
  64. FOREIGN KEY (location)
  65. REFERENCES southpac_team.company_locations(location_id)
  66. ON DELETE NO ACTION
  67. ON UPDATE NO ACTION)
  68. ENGINE = InnoDB;
  69.  
  70. echo $this->Form->input('company_location_id');
  71.  
  72. $companyLocations= $this->Users->CompanyLocations->find('list');
  73. $this->set(compact('companyLocations'));
  74.  
  75. $this->belongsTo('CompanyLocations', [
  76. 'foreignKey' => 'location'
  77. ]);
  78.  
  79. company_locations.location_id > locations.primary_key
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement