Union is what i need, how do i do it in laravel?

|
AlaaDq 2020-03-26 17:38:04
Ohh it is long time ago
Since last time a played with this old query
AlaaDq 2020-03-26 17:45:12
TheGuyi 2020-03-26 15:34:55
I just want to select all data from the tables then pass them to a variable that i can sort which data to return in my view …in SQL this is how the query looks like ::::::::::

SELECT * FROM trustee,limited_company ;

JOIN – You can use joins to combine columns from one or more queries into one result.
UNION – Use Unions and other set operators to combine rows from one or more queries into one result.
Sub Queries – Sometimes called nested queries, these can be used to perform a separate search in the database showed results can be used in another query.

TheGuyi 2020-03-26 17:47:38
AlaaDq 2020-03-26 17:45:12
JOIN – You can use joins to combine columns from one or more queries into one result.
UNION – Use Unions and other set operators to combine rows from one or more queries into one result.
Sub Queries – Sometimes called nested queries, these can be used to perform a separate search in the database showed results can be used in another query.

makes sense. union is what i need, how do i do it in laravel? this is where i am

TheGuyi 2020-03-26 17:48:07
laravel_discuss-30931.jpg

TheGuyi 2020-03-26 17:48:20
done but not finding where i am making the mistake
TheGuyi 2020-03-26 17:48:39
laravel_discuss-30933.jpg

TheGuyi 2020-03-26 17:50:09
yes sir but i have an issue seems to be coming from my view but my view is fine because i tested with 1 table
AlaaDq 2020-03-26 17:50:45
If you just want to show the both in the view
Why you don’t just pass the tow results
TheGuyi 2020-03-26 18:13:47
thank you it has worked👍
alexanderdavii 2020-03-26 18:25:26
laravel_discuss-30944.jpg
how to make button to print the whole blade file , as pdf , exactly like this opetion
TheGuyi 2020-03-26 18:25:36
pagnation??? any help?
DesolatorMagno 2020-03-26 18:41:43
sedhossein_dev 2020-03-26 13:33:16
How to be a Senior Junior Software Engineer?

https://medium.com/@sedhossein/how-to-be-a-senior-junior-software-engineer-part-1-c205ce51810e

I should have know what I was getting into from the first couple of words. IMO he wrote so much but say to little.

2020-03-26 18:43:27
emtized 2020-03-26 11:28:45
tell me if your error has gone, ok ?

I tried protected $guarded = []; but still i am getting the same error of create method does not exist

Mahdi_khani 2020-03-26 18:45:08
Hi
How to create custom command like {{csrf_field}} ?
With different name and action
I just need the instruction to create it
Thanks
DesolatorMagno 2020-03-26 18:45:19
2020-03-26 11:07:06

Try with comment()

DesolatorMagno 2020-03-26 18:52:30
2020-03-26 18:43:27
I tried protected $guarded = []; but still i am getting the same error of create method does not exist

When you use ->comments you are accessing the relationship, a collection, so is right to say that a collection don’t have a create function

2020-03-26 18:53:06
DesolatorMagno 2020-03-26 18:45:19
Try with comment()

Thanks i’ll try it ..

alwad3ani 2020-03-26 18:56:25
How I can Use Google chart in pdf ?!
DesolatorMagno 2020-03-26 18:56:34
If any doubt about why that work you can find a better explain reading the docs.
TheGuyi 2020-03-26 19:11:02
Mahdi_khani 2020-03-26 18:45:08
Hi
How to create custom command like {{csrf_field}} ?
With different name and action
I just need the instruction to create it
Thanks

{!! csrf_field() !!}

DesolatorMagno 2020-03-26 19:14:42
https://laravel.com/docs/5.8/blade#extending-blade

Laravel – The PHP Framework For Web ArtisansLaravel
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
TheGuyi 2020-03-26 20:33:08
hello @Rattone the link helped alot but i am trying to put it into search but i am unable to return data it brings blank. what am i missing?

public function search(Request $request){

$search = $request->get(‘search’);
$trust = DB::table(‘trustee’)->get();
$ltd = DB::table(‘limited_company’)->get();
//my final data
$posts = $trust->union($ltd) ->where(‘agent_company’, ‘like’, ‘%’.$search.’%’);

return view(‘index’, [‘posts’ => $posts]);

TheGuyi 2020-03-26 20:37:02
your right
TheGuyi 2020-03-26 20:39:16
yes to view the data where i am failing is to put a search’like’
2020-03-26 20:44:35
Window.close() not working in chrome
TheGuyi 2020-03-26 20:45:49
Your right @Rattone . So this is fine.. so why is data not returning after I search table empty. How would you write the function? Or what do you advise. Thanks

public function search(Request $request){

$search = $request->get(‘search’);
$trust = DB::table(‘trustee’)->get();
$ltd = DB::table(‘limited_company’)->get();
//my final data
$posts = $trust->union($ltd) ->where(‘agent_company’, ‘like’, ‘%’.$search.’%’);

return view(‘index’, [‘posts’ => $posts]);

TheGuyi 2020-03-26 20:49:15
I was using this one
TheGuyi 2020-03-26 20:49:40
Let me change it to use this
TheGuyi 2020-03-26 20:49:50
And compare
TheGuyi 2020-03-26 20:50:00
Thank you so much for your time
DesolatorMagno 2020-03-26 20:50:40
TheGuyi 2020-03-26 20:49:15
I was using this one

Read again the link you just linked, read to the end.

Suraz Ghimire 2020-03-26 22:42:54
I am going live on youtube for 15 Hours teaching you the bigdata fundamentals.
Date: 4th April 6:00 PM to 8:00 PM (sat-sun)
All interested can subscribe to my youtube channel

https://youtu.be/YJC5fYvG5AM (This is the live youtube session link, Click on it and set reminder in case you dont want to miss it. Dont forget to like it, so that we get to know the real count.

khanbozkurt 2020-03-27 00:05:24
Access to XMLHttpRequest at ‘http://localhost:8000/api/urun_ekle’ from origin ‘http://127.0.0.1:8000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
khanbozkurt 2020-03-27 00:05:33
i have a problem, how can i solve?
stefan_ssv 2020-03-27 00:46:06
Change app_url to localhost
stefan_ssv 2020-03-27 00:47:06
Ive heard that laravel community is much more presented in other messengers
stefan_ssv 2020-03-27 00:47:55
Is it all about slack or discord?
stefan_ssv 2020-03-27 00:48:26
Or maybe thereis any nonpublic communities?
AlaaDq 2020-03-27 01:23:24
#CustomizingTheNotificationChannel

anyone can help me
i need to use different channels for
broadcast the notifications
like i need one for admins
and one for normal users

AlaaDq 2020-03-27 01:25:30
i read the docs
and found this way to Customize the original channel
public function receivesBroadcastNotificationsOn()
{
return ‘users.’.$this->id;
}
AlaaDq 2020-03-27 01:26:41
but i need more than one
i need one for admin notification
and one for normal users

any suggestions please!!

AlaaDq 2020-03-27 01:31:07
will it work for me if i made it like

public function receivesBroadcastNotificationsOn()
{
return ‘users.’ . $this->role . $this->id;
}

???????

AlaaDq 2020-03-27 01:32:37
@Rattone @DesolatorMagno
anyideas??
stefan_ssv 2020-03-27 01:43:33
BroadcastOn
Return private channel “admins”

In broadcatsrviceprovider implement auth for this channel

stefan_ssv 2020-03-27 01:43:43
To allow users only with admin role
AlaaDq 2020-03-27 01:58:03
but BroadcastOn
is for event class

not for notifications class

AlaaDq 2020-03-27 01:58:42
am i right?
raka_anamaka 2020-03-27 05:27:38
Unable to fetch env file variable in vendor folder file..already tried php artisan config:cache and clear…
raka_anamaka 2020-03-27 05:53:40
Please can anyone help
DesolatorMagno 2020-03-27 05:57:12
did you try using a config file?
|