phalcon volt engine with getters and setters - phalcon

I want try this framework, but i have a problem.
i am create a application via phalcon-dev-tools
phalcon project phalcon
after this i create table users with 2 field = id, login
then
phalcon scaffold --table-name=users --get-set --force --template-engine=volt
Model with protected attribute with public methods - its okey
in volt {{ user.id }} return null, because its try to ger property id not method getId()
why?
ps. phalcon 1.2.1

You could call:
{{ user.getId() }} from Volt.
Are you expecting it to behave differently?

Related

How to retrieve data in vuejs from laravel eloquent?

By using relationship one to one in laravel eloquent I can get data from table users and countries.
In User model
public function country(){
return $this->hasOne(App\Models\Country::class,'id','id_country');
}
In blade template, to get the name of the country I can get it like this.
$user = App\Models\User::all()
$user_native = $user->country->name
Using the same result, how can I retrieve the country name in vue.js? Let's say that the returned data are in user so to call user's name I can do #{{ user.name }}. But when I tried to get country name using #{{ user.country.name }}, I get error Cannot read properties of undefined (reading 'name').

APS.NET core 2.2 Entity framework db migration looking for primary key

I am trying to run DB migration on my DAL project but receiving an error that my entity does not have key defined which has ?! could anyone help, please.
For posterity, please post your code and not an image.
Entity Framework will work from properties defined in your model, and the Id property is set up by convention. However you need to have the Id set up as a property for it to work correctly, and right now you have it as a field.
Change
public int Id; to public int Id { get; set; } and try again and you should be in business.

Common authentication table between Yii2 advance and Laravel 5.3

I have already one application built using Yii2 advance and working perfectly.
Now, client's requirement is to create new separate (but related with first) application using Laravel 5.3 and this new system must use the same database of Yii2.
A user should be able to login into both the application.
So, I'm curious is it even possible?
Any help would be appreciated.
Thanks,
Parth vora
Finally, I am able to achieve what I wanted.
So, here are the steps you need follow in your Laravel in order to login into Laravel application using auth table of Yii2:
Yii2 uses "user" name for the auth table, whereas Laravel uses "users".
So add this into your User model:
protected $table = "user";
Yii2 uses "password_hash" field to store the user password, whereas Laravel uses "password".
So add this into your User model:
public function getAuthPassword()
{
return $this->password_hash;
}
Yii2 uses "auth_key" field to store the user's remember token, whereas Laravel uses "remember_token". You also need to increase size of this field from 32 to 100, otherwise you will get an error upon logout.
So add this into your User model:
public function getRememberTokenName()
{
return 'auth_key';
}
You also need to increase the size of 'auth_key' field from 32 to 100, otherwise you will get an error upon logout.
Yii2 uses "int(11)" for created_at and updated_at field type, whereas Laravel uses "timestamp" type.
So add this into your User model:
protected $dateFormat = 'U';
Hope it might helpful to someone.
Thanks

MVC Routing with wildcard

I am developing a website on Asp MVC4
I have a link like that www.myhostname/category/{some arbitrary text}_ProductId
(e.g: www.myhostname.com/electronics/the-new-ipad_12345, in which 12345 is the ProductId that I need to extract)
Is the any way to register one route that give my directly the Id ?
I tried
routes.MapRoute(
name: "productRoute",
url: "{category}/*_{ProductId}",
defaults: new { Controller = "Home", action = "Product" }
);
But of course, it doesn't work
Note : as a work around, I used "{category}/{ProductLink}", to get the whole segment (e.g: the-new-ipad_12345) and extracted this ProductId on my action
Thanks & regards,
You are better off using attribute based routing. You can add regex to [Route] attribute and parse the product id.
It is part of Web API 2 now. If you are using older version of Web API, you can add reference to - http://attributerouting.net/
The final solution will look something like..
[Route("electronics/{productId:int:regex(_([0-9]+))}")]
public ProductDto GetProduct(int productId)
{
// ...
}

altering type of attribute using yii migration

I have an existing database for web application developed using yii. Now one of the attributes in the table is of type int but I want to convert its type to timestamp in table. How I can achieve this using yii migration so that my web application is affected. I am using Mysql database.
create a yii migration and modify the code
public function up(){
$this->alterColumn('table_name', 'column_name', 'new_data_type');//timestamp new_data_type
}
public function down() {
$this->alterColumn('table_name','column_name', 'old_data_type' );//int is old_data_type
}
then migrate up