this is the child data result, so how I can get parent data too?
Do you want to get data from Api?
Any one who uses spatie permissions and with laravel sanctum, I have this problem when i seed the super user with roles and permissions seeds okay but does not assign role to the user, what could the problem?
From where do you want to get the json data?

this is the child data result, so how I can get parent data too? (product_name as product_id)
Before returning data do
$products=Products::where(“id”,product_id)->first() ;
and
childname -> product=$products
$products=Products::where(“id”,product_id)->first() ;
and
childname -> product=$products
thank you for reply but it make one more query, I got the product from route as before

Mazouzi
Just use the relationships
Product::with(‘features’)->…
Product::with(‘features’)->…
thank you for reply but the ::facade make one more query, I got the product from route as before so how to use it?
Use the $product->load(‘rel’)
Or u can define
protected $with=[];
In model
protected $with=[];
In model
it will with always… but ->load is ok, thank you🙏 but I have same column name in parent and child like ‘price’ how to refer to each on separately?
$product->price
$product->relname->price
$product->relname->price
🙏 can I receive result as flat via ->load? (overwrite same attribs)
$product->relname->price
where I can find the ->load() docs?
What u mean?
https://laravel.com/docs/8.x/eloquent-relationships
thank you my friend, sorry it was my misunderstand 🙏
Good luck
Digital ocean
Http client
you have any syntax
Do you want to get data from Api?
without api is not posible
From where do you want to get the json data?
i want pass data view to controller
If you want to pass the data to view but as a json, you can encode it with json_encode php function.
But I don’t see the use case.
But if you just want to return the data as json for an ajax request, you can return the data directly or use json resources
But I don’t see the use case.
But if you just want to return the data as json for an ajax request, you can return the data directly or use json resources
$scope.Close_Save = function(model, id, page) {
if (model && id && page) {
model.id = id;
model.page = page;
$http({
method: ‘POST’,
url: “{{url(‘Close_Save’)}}”,
data: ‘{model:’ + JSON.stringify(model) + ‘}’,
dataType: “json”,
}).then(function success(response) {
alert(‘Success-‘ + JSON.stringify(response.data));
}, function error(response) {
alert(‘Error-‘ + response.data);
});
}
}
if (model && id && page) {
model.id = id;
model.page = page;
$http({
method: ‘POST’,
url: “{{url(‘Close_Save’)}}”,
data: ‘{model:’ + JSON.stringify(model) + ‘}’,
dataType: “json”,
}).then(function success(response) {
alert(‘Success-‘ + JSON.stringify(response.data));
}, function error(response) {
alert(‘Error-‘ + response.data);
});
}
}
not pass data on controller
As I see, it is an ajax request. The endpoint is Close_save. You can return a json from this endpoint with Json resources or just a data as well
it is an angularjs request
No matter, the request expect a json data
Composer install
Cp .env example .env
Php arrisan migrate
Php artisan key:generate
Php artisan serve
Give in x-www-urlencoded
Dont give rawdata