I have create admin in laravel. so now i want to post as a admin to database but when i did i got error like above.
i have a Post Table, I have admin id, I have admin table but it couldn't work.
// To create post
$post = new Post;
$post->title = $request->input('title');
$post->body = $request->input('body');
$post->admin_id = Auth()->guard('admin')->id;
$post->save();
I did like this above but i got error.
I also tried as
$post->admin_id = Auth()->admin()->id;
i got admin() not found.
I did Everything as per instructions but i got error.
$post->user_id = Auth()->user()->id;
Whereas this works i don't know what to do. i did everything as per instructions in Github but I have a trouble here. Please help me
Guard declaration:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'admin-api' => [
'driver' => 'token',
'provider' => 'admins',
],
],
please check your code it should be like this.
auth()->id()
try with it
auth()->guard('admin')->id();
Related
'methods' => ['POST', 'GET'],
'args' =>
[
'users' =>
[
'type' => 'array',
'minItems' => 1,
'items' =>
[
'type' => 'object',
'properties' =>
[
'user_login' =>
[
'type' => 'string',
'required' => true,
'validate_callback' => function($user_login)
{
error_log("login validation");
}
],
'user_email' =>
[
'type' => 'string',
'required' => false,
'validate_callback' => function($user_email)
{
error_log("email validation");
}
]
]
]
]
],
'callback' => function($request)
{
return $request->get_body_params();
}
]
As is, every request fails, saying that the users array is empty. ~~If I comment out the```minItems` line, the request succeeds and I can get the parameters in the callback; however, neither error log fires, so I can't validate the incoming data. I suspect that the main issue is whatever is causing the minItems to fail, as the API for some reason thinks there's no data, and thus nothing to validate, until the main callback fires.~~
Edit: minItems now works. The problem is otherwise the same: the args are treated as empty until the main callback fires, at which point they're populated correctly.
Validation callbacks can only be added to top-level args, not items of arrays or properties of objects. I'm going to make a feature request; I'll try to remember to update this post if it gets approved.
I have a react-native application using Firebase to handle push notifications. I always used FCM legacy api to send the notifications.
I recently switched to the new FCM v1 API. After changing authentification mode and payload structure, everything is working well, except the badge count on the app. I checked the documentation at https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages, there is a notification_countfield for Android, but nothing for iOS. With the legacy api, I was able to define a badge property.
Here is my current structure :
'message' => [
// Android
'android' => [
'priority' => 'HIGH',
'notification' => [
'notification_count' => $badge
]
],
// iOS
'apns' => [
'payload' => [
'aps' => [
'notification_count' => $badge
]
]
],
'token' => $deviceToken,
'notification' => [
'title' => $title,
'body' => $body
],
'data' => [
'title' => $title,
'message' => $body
],
'fcm_options' => [
'analytics_label' => $analyticsLabel
]
]
Thanks in advance for your help
The solution was finally to replace notification_count by badge under 'apns' => 'payload' => 'aps'
I cant find any information in the Wordpress rest api documentation about how to pass in a dynamic string as part of a url, I know how to do an ID.
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<type>)', [
'args' => [
'type' => [
'description' => __('Type of notification to generate', $this->pluginName),
'type' => 'string',
'enum' => ['product_question']
]
],
[
'methods' => \WP_REST_Server::CREATABLE,
'callback' => [$this, 'create_item'],
'permission_callback' => [$this, 'create_item_permissions_check'],
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE)
],
'schema' => [$this, 'get_public_item_schema']
]);
The above is the code im using to try and register the route. The route should look something like this /notifications/product_question The last part of the url, would be the dynamic part, and would be one of an array of values
So I have following:
$builder
->add('name')
->add('address', AddressType::class, [
'property_path' => 'address'
])
// TODO: Refactor to create new entities that are without ID
->add('person', CollectionType::class, [
'entry_type' => PersonType::class,
'allow_add' => true,
'property_path' => 'persons'
])
;
I run my functional test as follows with given parameters and everything works as expected. The entity is getting populated with new address relation & 2 new persons inside:
'entity' => [
'name' => 'Test',
'person' => [
[
'firstname' => 'one', 'lastname' => 'two'
], [
'firstname' => 'three', 'lastname' => 'four'
]
],
'address' => [
'street' => 'test str.',
]
]
Now if I run update on the same formtype with following params:
'entity' => [
'id' => 1,
'name' => 'Test upd',
'person' => [
[
'id' => 1, 'lastname' => 'update'
], [
'firstname' => 'new', 'lastname' => 'person'
]
]
]
What it does is: it correctly updates person with id 1. The problem is with the second one with firstname 'new' - instead of creating a new person and updating relationship it just looks for the remaining relation in 'entity' and updates the person with id 2.
Please help me find a way to properly configure this.
UPDATE: I can see the point in what's happening, most probably It is because the inverse side of relation of "entity" is not defined in PersonType. What would be the proper way to set up this relation field in PersonType, so it won't be recursive?
I've plugged Formatter (with CKeditor) to the 'content' field in one of my Sonata's Admin classes. This 'content' also has a translation, that's editable through 'a2lix_translations_gedmo' translations type. I've been trying to add CKeditor to this field as well, but it throws exceptions in any configuration I'm trying to set.
Google knows nothing about it, as well as SO. I've also looked in Sonata News Bundle sources (where sonata_formatter_type is implemented), but there are no translations available.
My Formatter field:
->add('content', 'sonata_formatter_type', [
'label' => "Content",
'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(),
'format_field' => 'contentFormatter',
'source_field' => 'rawContent',
'ckeditor_context' => 'my_config',
'source_field_options' => [
'attr' => [
'class' => 'span10', 'rows' => 10
]
],
'listener' => TRUE,
'target_field' => 'content'
])
My Translation fields:
->add('translations', 'a2lix_translations_gedmo', [
'label' => "Управление локализациями",
'translatable_class' => 'AppBundle\Entity\Article',
'fields' => [
'content' => [
'locale_options' => [
'ru' => [
'label' => 'Контент'
]
]
]
]
])
Maybe someone knows how to add 'sonata_formatter_type' to this damn 'a2lix_translations_gedmo' type (or 'a2lix_translations')?
'a2lix_translations_gedmo' or 'a2lix_translations' depends of the translation strategy chosen.
Gedmo strategy is discouraged and you shoud use a more recent translation strategy like the KnpLabs that I recommend. https://github.com/KnpLabs/DoctrineBehaviors#translatable
Othewise, see https://github.com/a2lix/TranslationFormBundle/issues/177#issuecomment-94949480