Re: In CakePHP 3, how do I bake admin controller?

2015-05-01 Thread Simerjit Kaur

On baking the controller and model bin/cake bake controller --prefix admin 
users and bin/cake bake template --prefix admin users,it creates the admin 
folder, in it it creates the folder for users, then it includes the files, 
on executing the http://127.0.0.1:/admin/users it gives error of 
missing controller
Please help.

I think it is worth adding to euromark's reply with an example full command 
> because for a few minutes I struggled until I looked into --help
>
> bin/cake bake controller --prefix admin users
>
> I had erroneously thought that 
> --prefix admin
>
> I was the thing on the command line
>
> CakePHP 3 rocks
>
> Thanks
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: In CakePHP 3, how do I bake admin controller?

2015-03-14 Thread Andre Santiago
I think it is worth adding to euromark's reply with an example full command 
because for a few minutes I struggled until I looked into --help

bin/cake bake controller --prefix admin users

I had erroneously thought that 
--prefix admin

I was the thing on the command line

CakePHP 3 rocks

Thanks



On Wednesday, December 3, 2014 at 10:55:20 AM UTC-5, frocco wrote:
>
> I want to create admin controller with view
>
> Thanks
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: In CakePHP 3, how do I bake admin controller?

2014-12-04 Thread frocco
Thanks,

Did not know about the  --prefix admin

Liking version 3 alot, have used yii and laravel before, also django

On Wednesday, December 3, 2014 10:55:20 AM UTC-5, frocco wrote:
>
> I want to create admin controller with view
>
> Thanks
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: In CakePHP 3, how do I bake admin controller?

2014-12-04 Thread euromark
No need to move anything
Just use bake correctly as documented:

cake bake ... --prefix admin

That will create it in the right places.


Am Donnerstag, 4. Dezember 2014 17:38:46 UTC+1 schrieb cesar calvo:
>
> After bake just move Templates and Controllers to Admin directory and 
> adjust the Controller namespace
>
> El jueves, 4 de diciembre de 2014 14:03:02 UTC-2, frocco escribió:
>>
>> Thanks,
>>
>> But when I use bake, will it generate the controller under admin?
>>
>>
>> On Wednesday, December 3, 2014 10:55:20 AM UTC-5, frocco wrote:
>>>
>>> I want to create admin controller with view
>>>
>>> Thanks
>>>
>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: In CakePHP 3, how do I bake admin controller?

2014-12-04 Thread cesar calvo
After bake just move Templates and Controllers to Admin directory and 
adjust the Controller namespace

El jueves, 4 de diciembre de 2014 14:03:02 UTC-2, frocco escribió:
>
> Thanks,
>
> But when I use bake, will it generate the controller under admin?
>
>
> On Wednesday, December 3, 2014 10:55:20 AM UTC-5, frocco wrote:
>>
>> I want to create admin controller with view
>>
>> Thanks
>>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: In CakePHP 3, how do I bake admin controller?

2014-12-04 Thread frocco
Thanks,

But when I use bake, will it generate the controller under admin?


On Wednesday, December 3, 2014 10:55:20 AM UTC-5, frocco wrote:
>
> I want to create admin controller with view
>
> Thanks
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: In CakePHP 3, how do I bake admin controller?

2014-12-04 Thread cesar calvo
In your config/routes.php add this:

Router::prefix('admin', function ($routes) {
$routes->fallbacks();
});

In AppController.php:
class AppController extends Controller {
public function initialize() {
$this->loadComponent('Auth')
}
public function beforeFilter(Event $event) {
   if ($this->request->prefix === null) {
$this->Auth->allow();
   }
}
public function isAuthorized($user) {
if ($this->request->prefix === 'admin') {
return (bool)$user['role'] === 'admin';
}
}
}

In src/Controller/Admin/UsersController.php
namespace App\Controller\Admin;
use App\Controller\AppController;
class UsersController extends AppController {
public function index() {
$users = $this->paginate();
$this->set(compact('users'));
}
}

Put the view template in src/Template/Admin/Users/index.ctp

--cesar



El miércoles, 3 de diciembre de 2014 13:55:20 UTC-2, frocco escribió:
>
> I want to create admin controller with view
>
> Thanks
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


In CakePHP 3, how do I bake admin controller?

2014-12-03 Thread frocco
I want to create admin controller with view

Thanks

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Admin Controller

2009-10-20 Thread adam

I always thought the same thing as Dave, but finally gave up because
there is no other sensible solution.  I never thought to put common
methods in app_controller!!  I'm so glad I opened this thread, because
this just made cake so much more elegant for me.

On Oct 20, 11:55 am, "Dave Maharaj :: WidePixels.com"
 wrote:
> Yeah the added model strain I figured as much.
>
> Low down on my problem. User has 5 HABTM relations. Normally you edit all
> the user info in 1 call admin_edit in user controller. But I have broken the
> info into sections for each HABTM, I managed to write 1 function that will
> updated each HABTM so that made the code cleaner, but the User has for 1
> specific example has User.email, if they edit the email is suspends the
> account until they confirm thier email again. So I need a separate form for
> just that function so I now need 2 additional admin functions, 1 to call the
> form, and 1 to save it. Same with the Users->Profile contact info. Profile
> is made up of lots of fields but I want a user to edit say just the contact
> info fields I need a admin_edit_contact and admin_index_contact and all
> these exra functions are making agiant mess. Just tossing ideas around to
> cleanit up and more readable / manageable
>
> Thoughts on how to combat this?
>
> -Original Message-
> From: Jamie [mailto:jamie@gmail.com]
> Sent: October-20-09 1:39 PM
> To: CakePHP
> Subject: Re: Admin Controller
>
> I don't think you should put your admin functions in their own controller.
>
> First, having a separate admin controller means that, instead of just
> loading one primary model per controller, you'll be stuck handling a ton of
> models within that one controller, which could get messy and almost
> certainly inefficient.
>
> Also, instead of being able to name your functions "admin_edit",
> "admin_index", etc., you'll need unique names for each model -
> "admin_users_edit", "admin_pages_edit", etc. Or, you could just have one
> massive admin_edit function. Or, your admin_edit function could just call a
> bunch of other internal functions. Any way you look at it, though, it'll be
> messy (again).
>
> Basically, if you keep a model's admin functions in that model's controller,
> you'll always know what you're working with.
>
> Why do you want to separate the functions, anyway? If you're worried about
> duplicate code (e.g. ten identical admin_edit functions), you could move
> some of your common functions that are the same in every controller to
> AppController. I did this for admin_delete and admin_edit, as well as some
> other ones I wrote (admin_publish, admin_unpublish, etc.). My 'stock'
> admin_delete in AppController, for example, looks like this:
>
> function admin_delete($id = null) {
>                 if (!$id) {
>                         $this->Session->setFlash(__('Invalid id for ' .
> $this->modelClass, true));
>                         $this->redirect($this->referer());
>                 }
>                 if ($this->{$this->modelClass}->del($id)) {
>                         $this->Session->setFlash(__($this->modelClass . '
> deleted', true));
>                         $this->redirect($this->referer());
>                 }
>         }
>
> If I need extra functionality for a certian controller I can just define
> admin_edit() in that individual controller. But most of the time, it works
> just fine.
>
> Anyway, hope this helps you decide.
>
> - Jamie
>
> On Oct 20, 8:28 am, "Dave Maharaj :: WidePixels.com"
>  wrote:
> > Can you, or suggest , reasons for or not to
>
> > create an admin_controller and keep all admin functions separate from
> > the other controllers?
>
> > Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Admin Controller

2009-10-20 Thread Dave Maharaj :: WidePixels.com

Yeah the added model strain I figured as much.

Low down on my problem. User has 5 HABTM relations. Normally you edit all
the user info in 1 call admin_edit in user controller. But I have broken the
info into sections for each HABTM, I managed to write 1 function that will
updated each HABTM so that made the code cleaner, but the User has for 1
specific example has User.email, if they edit the email is suspends the
account until they confirm thier email again. So I need a separate form for
just that function so I now need 2 additional admin functions, 1 to call the
form, and 1 to save it. Same with the Users->Profile contact info. Profile
is made up of lots of fields but I want a user to edit say just the contact
info fields I need a admin_edit_contact and admin_index_contact and all
these exra functions are making agiant mess. Just tossing ideas around to
cleanit up and more readable / manageable

Thoughts on how to combat this?

-Original Message-
From: Jamie [mailto:jamie@gmail.com] 
Sent: October-20-09 1:39 PM
To: CakePHP
Subject: Re: Admin Controller


I don't think you should put your admin functions in their own controller.

First, having a separate admin controller means that, instead of just
loading one primary model per controller, you'll be stuck handling a ton of
models within that one controller, which could get messy and almost
certainly inefficient.

Also, instead of being able to name your functions "admin_edit",
"admin_index", etc., you'll need unique names for each model -
"admin_users_edit", "admin_pages_edit", etc. Or, you could just have one
massive admin_edit function. Or, your admin_edit function could just call a
bunch of other internal functions. Any way you look at it, though, it'll be
messy (again).

Basically, if you keep a model's admin functions in that model's controller,
you'll always know what you're working with.

Why do you want to separate the functions, anyway? If you're worried about
duplicate code (e.g. ten identical admin_edit functions), you could move
some of your common functions that are the same in every controller to
AppController. I did this for admin_delete and admin_edit, as well as some
other ones I wrote (admin_publish, admin_unpublish, etc.). My 'stock'
admin_delete in AppController, for example, looks like this:

function admin_delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for ' .
$this->modelClass, true));
$this->redirect($this->referer());
}
if ($this->{$this->modelClass}->del($id)) {
$this->Session->setFlash(__($this->modelClass . '
deleted', true));
$this->redirect($this->referer());
}
}

If I need extra functionality for a certian controller I can just define
admin_edit() in that individual controller. But most of the time, it works
just fine.

Anyway, hope this helps you decide.

- Jamie

On Oct 20, 8:28 am, "Dave Maharaj :: WidePixels.com"
 wrote:
> Can you, or suggest , reasons for or not to
>
> create an admin_controller and keep all admin functions separate from 
> the other controllers?
>
> Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Admin Controller

2009-10-20 Thread Jon Bennett

Hi Dave,

> create an admin_controller and keep all admin functions separate from the
> other controllers?

Personally I wouldn't. Have a look at the Cookbook source, this is
what I follow - all admin methods except special cases go in
app_controller, streamlines things a lot.

Cheers,

Jon

-- 
jon bennett - www.jben.net - blog.jben.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Admin Controller

2009-10-20 Thread Jamie

I don't think you should put your admin functions in their own
controller.

First, having a separate admin controller means that, instead of just
loading one primary model per controller, you'll be stuck handling a
ton of models within that one controller, which could get messy and
almost certainly inefficient.

Also, instead of being able to name your functions "admin_edit",
"admin_index", etc., you'll need unique names for each model -
"admin_users_edit", "admin_pages_edit", etc. Or, you could just have
one massive admin_edit function. Or, your admin_edit function could
just call a bunch of other internal functions. Any way you look at it,
though, it'll be messy (again).

Basically, if you keep a model's admin functions in that model's
controller, you'll always know what you're working with.

Why do you want to separate the functions, anyway? If you're worried
about duplicate code (e.g. ten identical admin_edit functions), you
could move some of your common functions that are the same in every
controller to AppController. I did this for admin_delete and
admin_edit, as well as some other ones I wrote (admin_publish,
admin_unpublish, etc.). My 'stock' admin_delete in AppController, for
example, looks like this:

function admin_delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for ' . 
$this->modelClass,
true));
$this->redirect($this->referer());
}
if ($this->{$this->modelClass}->del($id)) {
$this->Session->setFlash(__($this->modelClass . ' 
deleted', true));
$this->redirect($this->referer());
}
}

If I need extra functionality for a certian controller I can just
define admin_edit() in that individual controller. But most of the
time, it works just fine.

Anyway, hope this helps you decide.

- Jamie

On Oct 20, 8:28 am, "Dave Maharaj :: WidePixels.com"
 wrote:
> Can you, or suggest , reasons for or not to
>
> create an admin_controller and keep all admin functions separate from the
> other controllers?
>
> Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Admin Controller

2009-10-20 Thread Dave Maharaj :: WidePixels.com
Can you, or suggest , reasons for or not to
 
create an admin_controller and keep all admin functions separate from the
other controllers?
 
Dave

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Admin Controller

2007-01-10 Thread Justin Johnson

If this is going to be the only action in the controller, then I would
use the pages controller.

simply add an admin() function in the pages controller and use the
following route

$Route->connect('/admin', array('controller' => 'pages','action' =>
'index'))


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Admin Controller

2007-01-09 Thread Tijs Teulings


I think there is no magic to auto identify all the available admin actions.
What you are talking about would be kind of neat though...

Tijs


PaulV wrote:
> 
> 
> Hi,
> 
> Having added CAKE_ADMIN functions to several controllers, I would like
> to add an action somewhere so that I can go to the URL /admin/ and get
> an interface screen containing all the various admin actions I can
> call.
> 
> Is there a prefered place to put this admin action (do I have to create
> an admin controller and add a new route)?
> 
> i.e.. $Route->connect('/admin', array('controller' => 'administrators',
> 'action' => 'index'))
> 
>  class AdministratorsController extends AppController {
> 
>  var $name = 'Administrators';
>  function index()
>  }
> }
> 
> Is there a way of automatically finding all the available admin actions
> and their respective controllers short of reading all the php files in
> and searching for the CAKE_ADMIN string in function definitions or do I
> have to manually pick out the available methods and define the action
> effectively statically?
> 
>Paul
> 
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Admin-Controller-tf2944794.html#a8236935
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Admin Controller

2007-01-09 Thread PaulV

Hi,

Having added CAKE_ADMIN functions to several controllers, I would like
to add an action somewhere so that I can go to the URL /admin/ and get
an interface screen containing all the various admin actions I can
call.

Is there a prefered place to put this admin action (do I have to create
an admin controller and add a new route)?

i.e.. $Route->connect('/admin', array('controller' => 'administrators',
'action' => 'index'))

 class AdministratorsController extends AppController {

 var $name = 'Administrators';
 function index()
 }
}

Is there a way of automatically finding all the available admin actions
and their respective controllers short of reading all the php files in
and searching for the CAKE_ADMIN string in function definitions or do I
have to manually pick out the available methods and define the action
effectively statically?

   Paul


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Unable to Access the Models from Admin Controller

2006-08-05 Thread Sharan

Hi,
 Here is the controller code

set('agents', $this->Agent->findAll());
}

}
?>

and here is the view (agents_index.thtml)

Agents


Name
Company Name
City
State
URL
Status










View Edit Delete




But the page shows the error :
Warning: Invalid argument supplied for foreach() in
/opt/lampp/htdocs/houseseeker/app/views/admin/agents_index.thtml on
line 15

and it does not show any recrods although there are records in the
table agents and also print_r($agents) also outputs nothing.

and line 15 is  $this->set('agents', $this->Agent->findAll());

Any Ideas. How to make the controller access the records of the Agent
Model.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---