logo
down
shadow

Laravel: Load posts with privacy only to subscriber


Laravel: Load posts with privacy only to subscriber

Content Index :

Laravel: Load posts with privacy only to subscriber
Tag : mysql , By : user184975
Date : January 12 2021, 07:00 PM

To fix the issue you can do You will simply have to make a distinction within the constraints. Because you have a few other constraints, it is necessary to put the OR joined constraints in their own where():
use Illuminate\Database\Eloquent\Builder;

$posts = Post::query()
    ->with('comments', 'tags')
    ->where('posts.status', 1)
    ->where('posts.archived', 0)
    ->where('posts.type', '!=', 7)
    ->where(function (Builder $query) {
        $query>where('posts.privacy', 1)
            ->orWhere(function (Builder $query) {
                $query->where('posts.privacy', 2)
                    ->whereExists(function ($query) {
                        $query->select(DB::raw(1))
                            ->from('followers')
                            ->whereColumn('followers.user_id', 'posts.user_id')
                            ->where('followers.follower_id', auth()->id())
                            ->where('followers.active', 1);
                    });
            });
    })
    ->latest()
    ->paginate(15);

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Changing privacy of old Facebook posts using the Graph API


Tag : php , By : Senthil
Date : March 29 2020, 07:55 AM
hop of those help? 1) Nope.
2) Yes, you can use the Graph API and HTTP Get me/feed?until={date}

How to show own posts if privacy is set to friends


Tag : php , By : brij
Date : March 29 2020, 07:55 AM
it should still fix some issue Without more info (sample data, for example), I'd say: try the following:
$result = mysql_query("
    SELECT t.tid, t.title, t.time, t.authorid, t.photo, f.fuid, f.myuid, u.username as writer 
      FROM topics as t, friends as f, users as u 
     WHERE cid='$cid' 
       AND u.id=t.authorid 
       AND (
               f.fuid=t.authorid AND f.myuid='$myid' 
               OR
               f.myuid=t.authorid AND f.fuid='$myid'
               OR
               t.autorid='$myid'
           ) 
  ORDER BY tid DESC 
     LIMIT $start, $perpage
");

Load all posts and check if the post is liked or not in laravel


Tag : php , By : Marc
Date : March 29 2020, 07:55 AM
will be helpful for those in need First, I would change up your initial query a little bit. I'd get the posts liked by the user like this (assuming the Post has a likes relationship):
$profileLikedPosts = Post::whereHas('likes', function($query) use ($user) {
        return $query->where('user_id', $user->id);
    })
    ->get();
// The "whereIn" just limits the results to those posts already retrieved
// for the profile user. Not required, but gives a little performance boost
// if this collection doesn't need the non-profile-liked posts.

$authUser = Auth::user();
$authLikedPosts = Post::whereHas('likes', function($query) use ($authUser) {
        return $query->where('user_id', $authUser->id);
    })
    ->whereIn('id', $profileLikedPosts->lists('id'))
    ->get();
@foreach ($profileLikedPosts as $post)
    // ...
    @if ($authLikedPosts->contains('id', $post->id))
        // this post is liked by both; show your icon
    @endif
    // ...
@endforeach

Facebook Graph API - How to read posts privacy


Tag : facebook , By : user177837
Date : March 29 2020, 07:55 AM
Does that help The error message is very clear, there is no field called "value" in the user table - which is exactly what you are trying to access with the /me endpoint. This would be the API call to get the privacy setting of a specific post:
https://graph.facebook.com/{post-id}?fields=privacy{value}&access_token={user-token}

How to publish posts depend on privacy?


Tag : mongodb , By : Sergio Rudenko
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How to group all scores by username in a table and display rank?
  • How to remove timestamp with the date using sql query?
  • Modify SQL query to get data only from past 2 months
  • change engine type from MyISAM to InnoDB
  • Need mysql query to find total sum as per matched query
  • json_table syntax and structure
  • Is there any way in sql query to rank certain value in ordered set of records such that ranking reset after it encounter
  • not able to login in google cloud storage sql instance
  • Inserting data into MySQL database with VBA
  • Make (user_id&music_id) unique in Likes table and Dislikes table
  • Can't do 50k insertion using bulkCreate
  • SQL syntax to get data IN date
  • How to get 4-byte emojis to store correctly in mysql 5.7?
  • How to create an in-memory database for PHPUnit testing?
  • How to write an SQL query to fetch the id in a column that has all the required data in some other column?
  • Invalid COLUMN in the select list because it is not contained in either an aggregate function or the GROUP BY clause
  • How to get actual index number of rows in MySQL when using Where clause
  • SQL Table Relationship
  • How to fix "FUNCTION doesnt exist" error in mysql?
  • Importing .bak from MSSQL into MySQL database
  • Aggregate query with distinct subquery kills every connection
  • How do i use and with multiple or condition?
  • How to fix 'The server requested authentication method unknown to the client [caching_sha2_password]' on docker compose?
  • In Mysql How to fetch distinct row value from a column1 and sum(column 2 row value) group by invoice number
  • MySQL ORDER BY field with a toggle
  • How to insert system's Date into Table
  • Aws lambda function too many connection issue rds
  • MYSQL - join 2 tables - sort in time
  • SQL code to select records where field_A matches the field_A value of a certain field_B value
  • How to model Amazon Redshift external table for changing column structure?
  • Query the list of CITY names from STATION that do not start with vowels and do not end with vowels. Your result cannot c
  • how to get rows with time for each minute for last 30 minutes
  • SQL Query With Between ,AND & OR in Where Clauses Not Given Correct Answers
  • ER_PARSE_ERROR: You have an error in your SQL syntax;
  • How to write normal sql queries inside controller in laravel
  • MySql query between range values(single record)
  • Set length conditions on text column in MySQL table
  • Mysql order of sorting
  • Sequelize raw queries TextRow and getting data out of it
  • Comparing the contents of two csv files, where the relation between the two files is specified in a third file?
  • Can 1 primary id link to multiple ids in one table?
  • Rewrite MySQL query and make it short
  • Why are parentheses used in JOIN USING clauses
  • Delete from row to row in phpadmin
  • Inserting Data into a table
  • How to efficiently get a entry with highest version in mysql table
  • How do I create views in dolphindb?
  • MySQL - update with inner join is creating nulls
  • Should i rather use a subquery or a combined WHERE?
  • INSERT INTO using data from other table causing ERROR 1064
  • How to display a MySQL table completely?
  • Can create procedure without using delimiter in MySQL?
  • distributed crawler and consistency
  • How to use mysql in node with Typescript
  • Is there any collation to differentiate 'е' and 'ё' in case insensitive way?
  • How to grant all privileges to specific user to remote ip
  • MySQL - Why is Safe Update Mode blocking this UPDATE command?
  • Can someone tell me why this query isn't working please?
  • At what time will MySQL execute events that are scheduled every DAY?
  • Same execution path, data and schematics; different query times
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com