cakephp-3.x

CakePHP 3.7.5 Retrive data of a field into the controller

白昼怎懂夜的黑 提交于 2019-12-20 06:19:47
问题 I apologize in advance if I am opening a question that may have already been asked, but I don't think I have found any results. I have a problem with the following CakePHP code portion: $unavailable_resource_ids = $this->Resources->Unavailabilities ->find() ->select(['resource_id']) ->matching('Bookings', function ($q) { return $q->where([ 'Bookings.booking_status_id NOT IN ' => [6, 4, 3] ]); }) ->where([ 'OR' => [ [ 'Unavailabilities.start <= :start_date', 'DATE_ADD(Unavailabilities.end,

Subqueries in CakePHP 3?

半世苍凉 提交于 2019-12-20 02:37:25
问题 I have two tables products and product_categories that are associated through a third table, products_categories_products , according to CakePHP BelongsToMany conventions (Edit: these associations are established in ProductsTable.php and ProductCategoriesTable.php ). I want to generate a list of product categories, using the image from the best selling products to represent each category. I can achieve my desired outcome using the following function: public function findImages(Query $query,

Check if record exists in CakePHP3.5

大城市里の小女人 提交于 2019-12-19 07:09:11
问题 The Following Code returns only a error :Record not found in table "users" if($this->Users->get($uid)->isEmpty()) { //do something } Because the Table is empty, i want to customize this if the table is empty, and call a new page in browser 回答1: Table::get() will immediately evaluate the query and return an entity, or throw an exception if the record with the given primary key doesn't exist, ie it doesn't return a query, you cannot call isEmpty() on the result. If you are using Table::get()

How to match records that are associated with a specific set of other records?

試著忘記壹切 提交于 2019-12-18 09:46:44
问题 I am trying to add to two different search variations to my project. There is a model "User" and a model "Tag". A User has many Tags. Now I want to be able to search the Users with specific Tags. Either I want to show all Users that has any of the specified tags. I got this working this way: $query = $this->Users->find(); $query->matching('Tags', function ($q) { return $q->where(['Tags.name' => 'Tag1']) ->orWhere(['Tags.name' => 'Tag2']); }); But now I want to find all Users that have both

cakephp 3 Cron Job not working in cpanel

亡梦爱人 提交于 2019-12-18 09:01:27
问题 I am trying to implement cron job in cakephp 3 shell script but it is not working in cpanel. below is my cron job code blog is my cakephp 3 folder cd /home/mmentert/public_html/abc.com/blog && bin/cake hello main Cakephp 3 shell class file namespace App\Shell; use Cake\Console\Shell; use App\Controller\UsersController; class HelloShell extends Shell { public function main() { $userinfo=new UsersController(); $data=$userinfo->useremail(); $this->out($data); } } 回答1: I assume you are using

CakePHP 3 - association is not defined - even though it appears to be

倾然丶 夕夏残阳落幕 提交于 2019-12-13 19:36:24
问题 I've baked a legacy application using CakePHP 3.7 The database contains 3 tables as follows: regulations , groups , filters . The hierarchy as far as the application goes is: Regulations Groups Filters The table schemas are as follows: mysql> describe regulations; +-------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------------+------+-----+---------+----------------+ | id | tinyint(3) unsigned | NO | PRI |

cakephp 3 add default class to inputs

强颜欢笑 提交于 2019-12-13 03:14:27
问题 i'm trying to add a default class for each input in my cakephp 3 app. Example of what i want: Input: <echo $this->Form->control('email'); Output: <input class="form-control" class="is-invalid"/> Desired output: <input class="form-control is-invalid"/> for this i have edited input template of FormHelper $this->viewBuilder()->setHelpers([ 'Form' => [ 'templates' => [ 'input' => '<input class="form-control" type="{{type}}" name="{{name}}"{{attrs}}/>' ] ] ]); the problem is that {{attrs}}

How to get CakePdf to work in CakePHP 3.x?

给你一囗甜甜゛ 提交于 2019-12-12 15:09:49
问题 I have installed CakePdf plugin in app/plugins folder and followed all the documentation possbile, thus my settings are as following: // config/bootstrap.php Plugin::load('CakePdf', ['bootstrap' => true, 'routes' => true]); Configure::write('CakePdf', [ 'engine' => 'CakePdf.WkHtmlToPdf', 'binary' => '/wkhtmltopdf/bin/wkhtmltopdf', 'margin' => [ 'bottom' => 15, 'left' => 50, 'right' => 30, 'top' => 45 ], 'orientation' => 'landscape', 'download' => true ]); // config/routes.php Router:

Confusing Validation vs. Application Rules in CakePHP3

假如想象 提交于 2019-12-12 07:58:32
问题 Multiple questions about validation which may belong together, because they are all kind of adressing the new validation concept in CakePHP 3. I have read the chapters (1, 2, 3) in the cookbook multiple times but honestly I don't understand how to do it the right way. I also know there is currently a issue/discussion at GitHub about the Validation in CakePHP3 which may address the same topic. Validation errors are triggered e.g. with patchEntity. So I would think it is better to ALWAYS check

Cakephp 3.x show me empty row with my custom query

吃可爱长大的小学妹 提交于 2019-12-12 04:20:53
问题 I made a custom query in my cakephp 3.0, but when I wanna display the data in a table, the rows are empty. This is my function in controller: public function estadisticas() { $conn = ConnectionManager::get('default'); $stmt = $conn->execute('SELECT c.nombre, c.idComplejo, t.canchaFK, count(*) AS cantidadTurnos FROM turno t inner join complejo c inner join ciudad cc inner join cancha ca inner join usuario u on t.canchaFK=ca.idCancha and c.idComplejo=ca.complejoFK and u.idUsuario=t.usuarioFK