Wednesday, April 1, 2015

Re: CakePHP 3.0 - Confusion comes from

Hi dave
I agree with you, but I also disagree
cakephp manual book may not be perfect, but it is quite complete and very helpful to understand the cakephp. deficiencies in the manual may be updated in the next update. And that is not in the manual book, we can ask each other in this group.

On Friday, March 27, 2015 at 9:37:26 PM UTC+7, Bayezid Alam wrote:
Hi,

A confusion comes on my mind regarding the adding something on CakePHP 3.0

As example given on below link's in the add function.

public function add()      {          $article = $this->Articles->newEntity(); // A blank newEnttity added stored in $article variable          if ($this->request->is('post')) {              $article = $this->Articles->patchEntity($article, $this->request->data); // A patchEntity added here & passed the request data here              if ($this->Articles->save($article)) {                  $this->Flash->success(__('Your article has been saved.'));                  return $this->redirect(['action' => 'index']);              }              $this->Flash->error(__('Unable to add your article.'));          }          $this->set('article', $article);      }


But i found a different things on below link

public function add()      {          $user = $this->Users->newEntity($this->request->data); // request data passing through newEntity here          if ($this->request->is('post')) {              if ($this->Users->save($user)) {                  $this->Flash->success(__('The user has been saved.'));                  return $this->redirect(['action' => 'add']);              }              $this->
...

--
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+unsubscribe@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: Cakephp3.0 Authentication issue

Try this hopely it can help 

public function login() {
      if ($this->request->is('post')) {
                $user = $this->Auth->identify();
                if ($user) {
                    $this->Auth->setUser($user);
                    $userrole = $this->request->session()
                            ->read('Auth.User.role');
                    if ($userrole == 'admin') {
                        return $this->redirect(['controller' => 'Admin', 'action' => 'someaction']);
                    } else {
                        return $this->redirect(['controller' => 'User', 'action' => 'someaction']);
                    }
                } else {
                    $this->Flash->error(
                            __('Username or password is incorrect'), 'default', [], 'auth'
                    );
                }
            }
    }

On Monday, March 30, 2015 at 2:49:46 AM UTC+7, nilay singh wrote:
Hey In blog authentication there is admin and author based role can anyone suggest me how can I check in login action if user is admin if yes then redirect to admin controller and if it is author it go to author controller 

--
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+unsubscribe@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: CakePHP 3 session usage in a custom class

I would pass the session object to the place where you need it.

On Wednesday, April 1, 2015 at 10:54:19 PM UTC+2, Subi wrote:
Which is the best way for using session in a custom class where "$this->request" isn't available? I simple used "$session = new Session;" and it works perfectly, but I'm not sure it is the right way.

--
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+unsubscribe@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: CakePHP 2 v CakePHP 3 SQL

Well that's good news, much is made of the new ORM, but it seems as though bread and butter (not cake :) queries can be constructed in the same way that they could before (CakePHP 2) using contain?

Having watched your recent video release - 'Faster application development with CakePHP 3.0' I understand that you love and are passionate about SQL. Not everybody is, and I'm one of them. I want as much of the pain taken out of it as possible of constructing the SQL and find that the format below serves me well for about 98% of what I'm after.

Thanks for the reply

Dave


On Tuesday, 31 March 2015 08:33:16 UTC+1, José Lorenzo wrote:

Hopefully from our previous messages you can guess it yourself:

$options = array(
                
'conditions' => array(
                    
'Rentals.id' => $id,

                    
),
                    
'contain' => array(
                        
'Trailers' => array(

                            
'fields' => array('id', 'number', 'make', 'year', 'license', 'vin', 'skirt')
                        
),
                        
'Lessees' => array(
                            
'fields' => array('id', 'account', 'name', 'address_1', 'address_2', 'city', 'state', 'zip_1', 'zip_2')
                        
)
                    
)
                
);


            $rental
 = $this->Rentals->find('all', $options)->first();

You can also use the where(), select() and contain() methods if you prefer not using an array.

On Monday, March 30, 2015 at 10:29:40 PM UTC+2, Dave Edwards wrote:
BUMP!

On Tuesday, 24 March 2015 20:33:49 UTC, Dave Edwards wrote:
Thanks for the reply,

That being the case, I am pleasantly surprised that despite the documentation making a big play on how different the new ORM is, I can (if I choose) create my queries in much the same way.

The example I posted was a effectively a find 'all' (paginated using a limit clause). What about a find first, is this still as straightforward? Here is an example from the same controller, how would that translate please?


            $options = array(
               
'conditions' => array(
                   
'Rental.id' => $id,
                   
),
                   
'contain' => array(
                       
'Trailer' => array(
                           
'fields' => array('id', 'number', 'make', 'year', 'license', 'vin', 'skirt')
                       
),
                       
'Lessee' => array(
                           
'fields' => array('id', 'account', 'name', 'address_1', 'address_2', 'city', 'state', 'zip_1', 'zip_2')
                       
)
                   
)
               
);


            $this
->request->data = $this->Rental->find('first', $options);

Dave

On Tuesday, 24 March 2015 13:04:21 UTC, Dave Edwards wrote:
Here is a sample of some code I use in a Trailer rental application. This is a method from the Rental Controller.

Rental hasMany Trailers and hasMany Lessees

public function archived($id = null) {


        $options
= array(
         
'limit' => 10,
         
'order' => 'Trailer.number ASC',
         
'fields' => array('id', 'trailer_id', 'lessee_id', 'date_out', 'rented', 'agreement_number'),
         
'conditions' => array(
             
'Rental.deleted' => '1',
         
),
         
'contain' => array(
             
'Trailer' => array(
                 
'fields' => array('id', 'number', 'make', 'license'),
             
),
             
'Lessee' => array(
                 
'fields' => array('id', 'account', 'name'),
             
)
         
)
       
);


        $this
->paginate = $options;
        $this
->set('rentals', $this->paginate());
 
}


Turning off recursive, and using Containable provides a very flexible and readable method of building a query. Adding conditions, fields, associated models etc is a snip. Whoever produced this method of working should be fully credited.

My question is, how would something like this be created in CakePHP 3? There seem to be many many more pages to read and understand regarding the new ORM, and I'm really unsure how simple it will be to convert. Will I be able to achieve it in the a similar manner, and will it be as readable, and easy to edit?

Are there any examples in the new Manual (I can't find any), where the new ORM is used to bring all the new methods of working together in much the same way as the method above?

Thanks

Dave

--
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+unsubscribe@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: CakePHP 3.0 - Confusion comes from

I disagree that that the manual is fine. If Euromark is correct (and he usually is) then it is misleading. None of the examples use both. Even the section further down entitled 'Saving Entities' does not use patchEntity as well as newEntity.

Dave

On Tuesday, 31 March 2015 13:49:05 UTC+1, Farid Aditya wrote:
no cookbook tutorial/example is fine
maybe
$this->Model->newEntity(); is to create  new object with blank attribute or create blank object container
$this->Model->patchEntity($oldObjectAttr , $newObjAttr); is to update object attribute 

On Friday, March 27, 2015 at 9:37:26 PM UTC+7, Bayezid Alam wrote:
Hi,

A confusion comes on my mind regarding the adding something on CakePHP 3.0

As example given on below link's in the add function.

public function add()      {          $article = $this->Articles->newEntity(); // A blank newEnttity added stored in $article variable          if ($this->request->is('post')) {              $article = $this->Articles->patchEntity($article, $this->request->data); // A patchEntity added here & passed the request data here              if ($this->Articles->save($article)) {                  $this->Flash->success(__('Your article has been saved.'));                  return $this->redirect(['action' => 'index']);              }              $this->Flash->error(__('Unable to add your article.'));          }          $this->set('article', $article);      }


But i found a different things on below link

public function add()      {          $user = $this->Users->newEntity($this->request->data); // request data passing through newEntity here          if ($this->request->is('post')) {              if ($this->Users->save($user)) {                  $this->Flash->success(__('The user has been saved.'));                  return $this->redirect(['action' => 'add']);              }              $this->
...

--
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+unsubscribe@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: Very basic question about the 'CakePHP Project Files'

Hi Farid,

Thanks for your reply.

Yes, Dave also suggested that the maps issue was unrelated to cakephp, but that a number of other problems were related.

I agree that the radio button needs a default setting, but once selected  ...  should remain where set until that search session is over  ...  and it does not do that. 

I have now employed Dave to repair the code and he is making great strides. It is great to see it moving forward at last.

Thanks for your help too.

On Wednesday, 1 April 2015 01:18:30 UTC+10:30, Farid Aditya wrote:
hi, 
sorry for late answer
after i visit your site, maybe no problem with your cakephp app, maybe it's just wrong data parsing to google map api, not in your CakePPH application.
 var mapProp = {
  center:new google.maps.LatLng(Lat_Data, Lng_Data),
  zoom: 7,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};

where Lat_Data and Lnd_Data is your client location from your Databasename.clientTable, not 5253 Murray Bridge location.

'bout radio button, maybe developer set dafault input of radio button to 'the city only', but that's normal behavior for radio buton to select one options as default input.



On Thursday, March 26, 2015 at 4:08:42 PM UTC+7, rogerdw...@gmail.com wrote:
Hi guys, I searched out this group to get a definite answer to my dilemma. I am an end user  ...  not a programmer.

I had a CakePHP site built and delivered but there a few small issues with it.

The long and short of it is that after I had made the final payment and it was transferred to my own server, I asked for some minor issues to be fixed.

After dragging their feet and pretty much ignoring me, I approached other programmers to see if they could finish it off.

They told me that they need access to the 'cake project file' to continue any work  ...  but the web development team say that it is not their company policy to provide that.

Apart from the fact that it feels like I'm being held to ransom  ... especially after I paid the agreed price, plus a bit more  ...  they are not doing the work and my site is un-useable.

Can anyone offer any (helpful) advise please. :)

Thanks,  Roger

--
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+unsubscribe@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.

CakePHP 3 session usage in a custom class

Which is the best way for using session in a custom class where "$this->request" isn't available? I simple used "$session = new Session;" and it works perfectly, but I'm not sure it is the right way.

--
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+unsubscribe@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.