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?

|
neelbas 2021-11-11 22:04:49
laravel_discuss-99584.jpg
this is the child data result, so how I can get parent data too? (product_name as product_id)
Mazouzi Yahia 2021-11-11 22:17:05
neelbas 2021-11-11 22:04:49
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

neelbas 2021-11-11 22:18:09
Mazouzi Yahia 2021-11-11 22:17:05
Before returning data do
$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

neelbas 2021-11-11 22:18:51
laravel_discuss-99587.jpg
Mazouzi
XOREN 2021-11-11 22:19:15
neelbas 2021-11-11 22:04:49
this is the child data result, so how I can get parent data too? (product_name as product_id)

Just use the relationships

Product::with(‘features’)->…

neelbas 2021-11-11 22:20:45
XOREN 2021-11-11 22:19:15
Just use the relationships

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?

XOREN 2021-11-11 22:21:42
neelbas 2021-11-11 22:20:45
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’)

XOREN 2021-11-11 22:23:56
XOREN 2021-11-11 22:21:42
Use the $product->load(‘rel’)

Or u can define
protected $with=[];
In model

neelbas 2021-11-11 22:25:44
XOREN 2021-11-11 22:23:56
Or u can define
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?

XOREN 2021-11-11 22:26:53
neelbas 2021-11-11 22:25:44
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

neelbas 2021-11-11 22:28:04
XOREN 2021-11-11 22:26:53
$product->price
$product->relname->price

🙏 can I receive result as flat via ->load? (overwrite same attribs)

neelbas 2021-11-11 22:31:16
XOREN 2021-11-11 22:26:53
$product->price
$product->relname->price

where I can find the ->load() docs?

XOREN 2021-11-11 22:31:37
neelbas 2021-11-11 22:28:04
🙏 can I receive result as flat via ->load? (overwrite same attribs)

What u mean?

XOREN 2021-11-11 22:32:18
neelbas 2021-11-11 22:31:16
where I can find the ->load() docs?

https://laravel.com/docs/8.x/eloquent-relationships

neelbas 2021-11-11 22:32:33
XOREN 2021-11-11 22:31:37
What u mean?

thank you my friend, sorry it was my misunderstand 🙏

XOREN 2021-11-11 22:32:58
neelbas 2021-11-11 22:32:33
thank you my friend, sorry it was my misunderstand 🙏

Good luck

ForgeDark 2021-11-11 22:53:06
Anyone with EDU Account OR EDU VPN USA VS BTC
vikash_dev 2021-11-12 08:29:21
how i get json data on controller in laravel 8
Alitech22 2021-11-12 09:29:48
Which hosting is best for laravel
foulla_sam 2021-11-12 09:33:38
Alitech22 2021-11-12 09:29:48
Which hosting is best for laravel

Digital ocean

foulla_sam 2021-11-12 09:34:02
vikash_dev 2021-11-12 08:29:21
how i get json data on controller in laravel 8

Http client

vikash_dev 2021-11-12 09:35:05
foulla_sam 2021-11-12 09:34:02
Http client

you have any syntax

foulla_sam 2021-11-12 09:35:36
vikash_dev 2021-11-12 09:35:05
you have any syntax

Do you want to get data from Api?

vikash_dev 2021-11-12 09:36:26
foulla_sam 2021-11-12 09:35:36
Do you want to get data from Api?

without api is not posible

Waxikevin 2021-11-12 09:45:52
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?
foulla_sam 2021-11-12 09:46:57
vikash_dev 2021-11-12 09:36:26
without api is not posible

From where do you want to get the json data?

vikash_dev 2021-11-12 09:47:44
foulla_sam 2021-11-12 09:46:57
From where do you want to get the json data?

i want pass data view to controller

foulla_sam 2021-11-12 09:52:13
vikash_dev 2021-11-12 09:47:44
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

vikash_dev 2021-11-12 09:53:09
foulla_sam 2021-11-12 09:52:13
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

$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);
});
}
}

vikash_dev 2021-11-12 09:53:43
vikash_dev 2021-11-12 09:53:09
$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);
});
}
}

not pass data on controller

foulla_sam 2021-11-12 09:57:16
vikash_dev 2021-11-12 09:53:43
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

vikash_dev 2021-11-12 09:59:19
foulla_sam 2021-11-12 09:57:16
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

foulla_sam 2021-11-12 10:10:24
vikash_dev 2021-11-12 09:59:19
it is an angularjs request

No matter, the request expect a json data

Silambarasan Raju 2021-11-12 10:14:29
imi800 2021-11-09 22:07:11
what’s this error

Composer install
Cp .env example .env
Php arrisan migrate
Php artisan key:generate
Php artisan serve

Silambarasan Raju 2021-11-12 10:15:43
skpnation 2021-11-11 16:35:27

Give in x-www-urlencoded
Dont give rawdata

|