[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object Type data parsing for the blade template #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ibnsultan
Copy link

Added object parsing support for the blade view function

Description

Added object parsing support for the blade view function, the view and render functions are explicitly set to receive the $data parameter as of type array, which is also fine but it's not very presentable when have very little or very large amount of data.

So I modified the $data parameter in the view and render function to also receive objects, if the then received data is object it is converted to array.

Comparison between array and object passing as data in the view function

# passing data as array on the view

$data = [
    'title' => 'My Page Title',
    'foo' => 'My Foo Content',
    'bar' => 'My Bar Content'
];

render('page', $data);
# passing data as of type object to the view
# assuming (object) $data in initialized in the BaseController

$this->data->title = 'My Page Title'
$this->data->foo = 'My Foo Content'
$this->data->bar = 'My Bar Content'

render('page' $this->data)

While this could be subjective from user to user, I think the data passed as an object look more presentable and are less congested.

Added object parsing support for the blade view function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant