Laravel echo strange characters - php

Hey i wan't to echo something with belongsTo but the output gives me some strange characters back.
class Leviews extends Entity
{
public $table = 'reviews';
public function ravatar()
{
return $this->belongsTo('User', 'author', 'username')->select('avatar');
}
now when i echo the data with {{ $item->ravatar }} im getting this
{"avatar":"avatars\/1.jpg"}
and it should be
avatars/1.jpg
what im doing wrong?
edit
here is the Controller
<?php
use Carbon\Carbon;
use Lib\Reviews\LeviewsRepository;
use Lib\Services\Scraping\Scraper;
use Lib\Services\Validation\LeviewsValidator;
class LeviewsController extends \BaseController {
/**
* Leviews repository instance.
*
* #var Lib\Leviews\LeviewsRepository
*/
protected $repo;
/**
* validator instance.
*
* #var Lib\Services\Validation\LeviewsCreateValidator
*/
private $validator;
/**
* Leviews scraper isntance.
*
* #var Lib\Services\Scraping\NewScraper;
*/
private $scraper;
public function __construct(LeviewsRepository $lreviews, LeviewsValidator $validator, Scraper $scraper)
{
$this->beforeFilter('csrf', array('on' => 'post'));
$this->beforeFilter('logged', array('except' => array('index', 'show', 'paginate')));
$this->beforeFilter('news:create', array('only' => array('create', 'store')));
$this->beforeFilter('news:edit', array('only' => array('edit', 'update')));
$this->beforeFilter('news:delete', array('only' => 'destroy'));
$this->beforeFilter('news:update', array('only' => 'updateFromExternal'));
$this->repo = $lreviews;
$this->scraper = $scraper;
$this->validator = $validator;
}
/**
* Display list of paginated news.
*
* #return View
*/
public function index()
{
return View::make('Leviews.Index');
}
/**
* Display form for creating new news items.
*
* #return View
*/
public function create()
{
return View::make('Leviews.Create');
}
/**
* Store a newly created news item.
*
* #return Redirect
*/
public function store()
{
$input = Input::except('_token');
if ( ! $this->validator->with($input)->passes())
{
return Redirect::back()->withErrors($this->validator->errors())->withInput($input);
}
//escape double qoutes
$input['title'] = htmlspecialchars($input['title']);
$this->repo->store($input);
return Redirect::back()->withSuccess( trans('main.news create success') );
}
/**
* Display single news items.
*
* #param int $id
* #return View
*/
public function show($id)
{
$lreviews = $this->repo->byId($id);
if ($lreviews->full_url && ! $lreviews->fully_scraped)
{
$lreviews = $this->repo->getFullLeviewsItem($lreviews);
}
return View::make('Leviews.Show')->with(compact('news'))->withRecent($this->repo->latest());
}
/**
* Displays form for editing news item.
*
* #param int $id
* #return View
*/
public function edit($id)
{
$lreviews = $this->repo->byId($id);
return View::make('Leviews.Edit')->withLeviews($lreviews);
}
/**
* Updates the news item.
*
* #param int $id
* #return Redirect
*/
public function update($id)
{
$input = Input::except('_token', '_method');
$lreviews = $this->repo->byId($id);
if ($lreviews->title === $input['title'])
{
//dont check for title uniqueness when updating if
//title was not updated.
$this->validator->rules['title'] = 'required|min:2|max:255';
}
if ( ! $this->validator->with($input)->passes())
{
return Redirect::back()->withErrors($this->validator->errors())->withInput($input);
}
//escape double qoutes
$input['title'] = htmlspecialchars($input['title']);
$this->repo->update($lreviews, $input);
return Redirect::back()->withSuccess( trans('main.news update success') );
}
/**
* Delete specified news item.
*
* #param int $id
* #return Response
*/
public function destroy($id)
{
$this->repo->delete($id);
return Response::json(trans('main.news delete success'), 200);
}
/**
* Updates news from external sources.
*
* #return void
*/
public function updateFromExternal()
{
$this->scraper->updateLeviews();
Event::fire('Leviews.Updated', Carbon::now());
return Redirect::back()->withSuccess( trans('dash.updated news successfully') );
}
}
and here the view
#if ($options->enableNews())
#foreach($lreviews as $k => $item)
{{ $item->body }}
{{ $item->ravatar }}
#endforeach
#endif
{{ $item->body }} is without strange characters
edit
here the dd output
object(Illuminate\Database\Eloquent\Collection)#634 (1) { ["items":protected]=> array(6) { [0]=> object(Leviews)#606 (22) { ["table"]=> string(7) "reviews" ["defaultOrderColumn":protected]=> string(10) "created_at" ["connection":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(12) { ["id"]=> int(42) ["author"]=> string(7) "Clayman" ["source"]=> string(8) "Japanime" ["body"]=> string(182) "Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review " ["score"]=> int(9) ["link"]=> NULL ["title_id"]=> int(1655) ["created_at"]=> string(19) "2015-04-24 16:08:34" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(1) ["type"]=> string(4) "user" } ["original":protected]=> array(12) { ["id"]=> int(42) ["author"]=> string(7) "Clayman" ["source"]=> string(8) "Japanime" ["body"]=> string(182) "Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review " ["score"]=> int(9) ["link"]=> NULL ["title_id"]=> int(1655) ["created_at"]=> string(19) "2015-04-24 16:08:34" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(1) ["type"]=> string(4) "user" } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } ["dates":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["with":protected]=> array(0) { } ["morphClass":protected]=> NULL ["exists"]=> bool(true) ["softDelete":protected]=> bool(false) } [1]=> object(Leviews)#635 (22) { ["table"]=> string(7) "reviews" ["defaultOrderColumn":protected]=> string(10) "created_at" ["connection":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(12) { ["id"]=> int(1) ["author"]=> string(18) "James Berardinelli" ["source"]=> string(9) "ReelViews" ["body"]=> string(265) "The movie is pretty to look at in a "Transformers" sort of way and moves briskly enough that it never threatens to bore, but it's hard to feel much of anything about the characters and, when it's all over, there's a sense that everything that happens is obligatory." ["score"]=> int(63) ["link"]=> string(64) "http://www.reelviews.net/php_review_template.php?identifier=2687" ["title_id"]=> int(87) ["created_at"]=> string(19) "2015-04-23 18:32:05" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } ["original":protected]=> array(12) { ["id"]=> int(1) ["author"]=> string(18) "James Berardinelli" ["source"]=> string(9) "ReelViews" ["body"]=> string(265) "The movie is pretty to look at in a "Transformers" sort of way and moves briskly enough that it never threatens to bore, but it's hard to feel much of anything about the characters and, when it's all over, there's a sense that everything that happens is obligatory." ["score"]=> int(63) ["link"]=> string(64) "http://www.reelviews.net/php_review_template.php?identifier=2687" ["title_id"]=> int(87) ["created_at"]=> string(19) "2015-04-23 18:32:05" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } ["dates":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["with":protected]=> array(0) { } ["morphClass":protected]=> NULL ["exists"]=> bool(true) ["softDelete":protected]=> bool(false) } [2]=> object(Leviews)#629 (22) { ["table"]=> string(7) "reviews" ["defaultOrderColumn":protected]=> string(10) "created_at" ["connection":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(12) { ["id"]=> int(2) ["author"]=> string(10) "Steven Rea" ["source"]=> string(21) "Philadelphia Inquirer" ["body"]=> string(345) "One of the problems with The Dark World is that its monsters and angry armies and visual effects are interchangeable with Peter Jackson's Tolkien pics, with Clash of the Titans, with The Avengers, with Man of Steel, and on and on. These superhero movies. These Middle Earth movies. These mythic god movies. It's getting hard to tell them apart." ["score"]=> int(63) ["link"]=> string(99) "http://www.philly.com/philly/entertainment/movies/20131108_Thor_s_back__more_generic_than_ever.html" ["title_id"]=> int(87) ["created_at"]=> string(19) "2015-04-23 18:32:05" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } ["original":protected]=> array(12) { ["id"]=> int(2) ["author"]=> string(10) "Steven Rea" ["source"]=> string(21) "Philadelphia Inquirer" ["body"]=> string(345) "One of the problems with The Dark World is that its monsters and angry armies and visual effects are interchangeable with Peter Jackson's Tolkien pics, with Clash of the Titans, with The Avengers, with Man of Steel, and on and on. These superhero movies. These Middle Earth movies. These mythic god movies. It's getting hard to tell them apart." ["score"]=> int(63) ["link"]=> string(99) "http://www.philly.com/philly/entertainment/movies/20131108_Thor_s_back__more_generic_than_ever.html" ["title_id"]=> int(87) ["created_at"]=> string(19) "2015-04-23 18:32:05" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } ["dates":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["with":protected]=> array(0) { } ["morphClass":protected]=> NULL ["exists"]=> bool(true) ["softDelete":protected]=> bool(false) } [3]=> object(Leviews)#630 (22) { ["table"]=> string(7) "reviews" ["defaultOrderColumn":protected]=> string(10) "created_at" ["connection":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(12) { ["id"]=> int(3) ["author"]=> string(12) "Simon Abrams" ["source"]=> string(14) "RogerEbert.com" ["body"]=> string(133) "Thor: The Dark World's characters are often very charming, but they're only so much fun when they're stuck going through the motions." ["score"]=> int(63) ["link"]=> string(58) "http://www.rogerebert.com/reviews/thor-the-dark-world-2013" ["title_id"]=> int(87) ["created_at"]=> string(19) "2015-04-23 18:32:05" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } ["original":protected]=> array(12) { ["id"]=> int(3) ["author"]=> string(12) "Simon Abrams" ["source"]=> string(14) "RogerEbert.com" ["body"]=> string(133) "Thor: The Dark World's characters are often very charming, but they're only so much fun when they're stuck going through the motions." ["score"]=> int(63) ["link"]=> string(58) "http://www.rogerebert.com/reviews/thor-the-dark-world-2013" ["title_id"]=> int(87) ["created_at"]=> string(19) "2015-04-23 18:32:05" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } ["dates":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["with":protected]=> array(0) { } ["morphClass":protected]=> NULL ["exists"]=> bool(true) ["softDelete":protected]=> bool(false) } [4]=> object(Leviews)#641 (22) { ["table"]=> string(7) "reviews" ["defaultOrderColumn":protected]=> string(10) "created_at" ["connection":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(12) { ["id"]=> int(4) ["author"]=> string(10) "Mike Scott" ["source"]=> string(26) "New Orleans Times-Picayune" ["body"]=> string(213) "None of that is to say that Thor: The Dark World is a bad movie, necessarily. I would never speak ill of a man with a giant, magical hammer. At the same time, hammer or no hammer, it doesn't quite nail it, either." ["score"]=> int(40) ["link"]=> string(95) "http://www.nola.com/movies/index.ssf/2013/11/thor_the_dark_world_movie_revi.html#incart_m-rpt-1" ["title_id"]=> int(87) ["created_at"]=> string(19) "2015-04-23 18:32:05" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } ["original":protected]=> array(12) { ["id"]=> int(4) ["author"]=> string(10) "Mike Scott" ["source"]=> string(26) "New Orleans Times-Picayune" ["body"]=> string(213) "None of that is to say that Thor: The Dark World is a bad movie, necessarily. I would never speak ill of a man with a giant, magical hammer. At the same time, hammer or no hammer, it doesn't quite nail it, either." ["score"]=> int(40) ["link"]=> string(95) "http://www.nola.com/movies/index.ssf/2013/11/thor_the_dark_world_movie_revi.html#incart_m-rpt-1" ["title_id"]=> int(87) ["created_at"]=> string(19) "2015-04-23 18:32:05" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } ["dates":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["with":protected]=> array(0) { } ["morphClass":protected]=> NULL ["exists"]=> bool(true) ["softDelete":protected]=> bool(false) } [5]=> object(Leviews)#640 (22) { ["table"]=> string(7) "reviews" ["defaultOrderColumn":protected]=> string(10) "created_at" ["connection":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(12) { ["id"]=> int(5) ["author"]=> string(12) "Peter Rainer" ["source"]=> string(25) "Christian Science Monitor" ["body"]=> string(183) "My favorite moment in the movie: Astrophysicist Erik Selvig (Stellan Skarsgard) insisting on wearing only his underwear because he says he thinks better that way. Hey, whatever works." ["score"]=> int(58) ["link"]=> string(108) "http://www.csmonitor.com/The-Culture/Movies/2013/1108/Thor-The-Dark-World-has-lost-the-spark-of-the-original" ["title_id"]=> int(87) ["created_at"]=> string(19) "2015-04-23 18:32:05" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } ["original":protected]=> array(12) { ["id"]=> int(5) ["author"]=> string(12) "Peter Rainer" ["source"]=> string(25) "Christian Science Monitor" ["body"]=> string(183) "My favorite moment in the movie: Astrophysicist Erik Selvig (Stellan Skarsgard) insisting on wearing only his underwear because he says he thinks better that way. Hey, whatever works." ["score"]=> int(58) ["link"]=> string(108) "http://www.csmonitor.com/The-Culture/Movies/2013/1108/Thor-The-Dark-World-has-lost-the-spark-of-the-original" ["title_id"]=> int(87) ["created_at"]=> string(19) "2015-04-23 18:32:05" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } ["dates":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["with":protected]=> array(0) { } ["morphClass":protected]=> NULL ["exists"]=> bool(true) ["softDelete":protected]=> bool(false) } } }
edit
array(6) { [0]=> array(12) { ["id"]=> int(42) ["author"]=> string(7) "Clayman" ["source"]=> string(8) "Japanime" ["body"]=> string(182) "Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review Review " ["score"]=> int(9) ["link"]=> NULL ["title_id"]=> int(1655) ["created_at"]=> string(12) "Apr 24, 2015" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(1) ["type"]=> string(4) "user" } [1]=> array(12) { ["id"]=> int(1) ["author"]=> string(18) "James Berardinelli" ["source"]=> string(9) "ReelViews" ["body"]=> string(265) "The movie is pretty to look at in a "Transformers" sort of way and moves briskly enough that it never threatens to bore, but it's hard to feel much of anything about the characters and, when it's all over, there's a sense that everything that happens is obligatory." ["score"]=> int(63) ["link"]=> string(64) "http://www.reelviews.net/php_review_template.php?identifier=2687" ["title_id"]=> int(87) ["created_at"]=> string(12) "Apr 23, 2015" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } [2]=> array(12) { ["id"]=> int(2) ["author"]=> string(10) "Steven Rea" ["source"]=> string(21) "Philadelphia Inquirer" ["body"]=> string(345) "One of the problems with The Dark World is that its monsters and angry armies and visual effects are interchangeable with Peter Jackson's Tolkien pics, with Clash of the Titans, with The Avengers, with Man of Steel, and on and on. These superhero movies. These Middle Earth movies. These mythic god movies. It's getting hard to tell them apart." ["score"]=> int(63) ["link"]=> string(99) "http://www.philly.com/philly/entertainment/movies/20131108_Thor_s_back__more_generic_than_ever.html" ["title_id"]=> int(87) ["created_at"]=> string(12) "Apr 23, 2015" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } [3]=> array(12) { ["id"]=> int(3) ["author"]=> string(12) "Simon Abrams" ["source"]=> string(14) "RogerEbert.com" ["body"]=> string(133) "Thor: The Dark World's characters are often very charming, but they're only so much fun when they're stuck going through the motions." ["score"]=> int(63) ["link"]=> string(58) "http://www.rogerebert.com/reviews/thor-the-dark-world-2013" ["title_id"]=> int(87) ["created_at"]=> string(12) "Apr 23, 2015" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } [4]=> array(12) { ["id"]=> int(4) ["author"]=> string(10) "Mike Scott" ["source"]=> string(26) "New Orleans Times-Picayune" ["body"]=> string(213) "None of that is to say that Thor: The Dark World is a bad movie, necessarily. I would never speak ill of a man with a giant, magical hammer. At the same time, hammer or no hammer, it doesn't quite nail it, either." ["score"]=> int(40) ["link"]=> string(95) "http://www.nola.com/movies/index.ssf/2013/11/thor_the_dark_world_movie_revi.html#incart_m-rpt-1" ["title_id"]=> int(87) ["created_at"]=> string(12) "Apr 23, 2015" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } [5]=> array(12) { ["id"]=> int(5) ["author"]=> string(12) "Peter Rainer" ["source"]=> string(25) "Christian Science Monitor" ["body"]=> string(183) "My favorite moment in the movie: Astrophysicist Erik Selvig (Stellan Skarsgard) insisting on wearing only his underwear because he says he thinks better that way. Hey, whatever works." ["score"]=> int(58) ["link"]=> string(108) "http://www.csmonitor.com/The-Culture/Movies/2013/1108/Thor-The-Dark-World-has-lost-the-spark-of-the-original" ["title_id"]=> int(87) ["created_at"]=> string(12) "Apr 23, 2015" ["updated_at"]=> NULL ["temp_id"]=> NULL ["user_id"]=> int(0) ["type"]=> string(6) "critic" } }

$item->ravatar is model and not just a string. What you see is the JSON representation of that model. To get the actual path use:
{{ $item->ravatar->avatar }}
If it's possible that not every review has has an avatar, check that with an if statement or use this:
{{ $item->ravatar->avatar or 'avatar/default.jpg' }}

Related

How can I get values from two Laravel tables using loop on my view

The below line returns all record from two tables, because I added a relationship for these two tables.
$allmarketers = ProductStock::whereRaw('MONTH(created_at) = ?',[$currentMonth])->get();
Now I want to loop through the records in the view and display the records from two tables for each user. I forgot how to achieve this.
I tried
#foreach($allmarketers as $item)
But how can I get the values of both tables inside this loop?
Var_dump
n)#601 (1) { ["items":protected]=> array(3) { [0]=> object(App\ProductStock)#602 (26) { ["table":protected]=> string(14) "product_stocks" ["fillable":protected]=> array(5) { [0]=> string(8) "marketer" [1]=> string(6) "target" [2]=> string(6) "_token" [3]=> string(10) "updated_at" [4]=> string(10) "created_at" } ["connection":protected]=> string(5) "mysql" ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(9) { ["id"]=> int(97) ["user_id"]=> int(70) ["marketer"]=> string(18) "Samson Samson | 70" ["target"]=> string(3) "100" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["original":protected]=> array(9) { ["id"]=> int(97) ["user_id"]=> int(70) ["marketer"]=> string(18) "Samson Samson | 70" ["target"]=> string(3) "100" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["changes":protected]=> array(0) { } ["casts":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["dispatchesEvents":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=> bool(true) ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } } [1]=> object(App\ProductStock)#603 (26) { ["table":protected]=> string(14) "product_stocks" ["fillable":protected]=> array(5) { [0]=> string(8) "marketer" [1]=> string(6) "target" [2]=> string(6) "_token" [3]=> string(10) "updated_at" [4]=> string(10) "created_at" } ["connection":protected]=> string(5) "mysql" ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(9) { ["id"]=> int(98) ["user_id"]=> int(72) ["marketer"]=> string(22) "Emmanuel Increase | 72" ["target"]=> string(3) "150" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["original":protected]=> array(9) { ["id"]=> int(98) ["user_id"]=> int(72) ["marketer"]=> string(22) "Emmanuel Increase | 72" ["target"]=> string(3) "150" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["changes":protected]=> array(0) { } ["casts":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["dispatchesEvents":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=> bool(true) ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } } [2]=> object(App\ProductStock)#604 (26) { ["table":protected]=> string(14) "product_stocks" ["fillable":protected]=> array(5) { [0]=> string(8) "marketer" [1]=> string(6) "target" [2]=> string(6) "_token" [3]=> string(10) "updated_at" [4]=> string(10) "created_at" } ["connection":protected]=> string(5) "mysql" ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(9) { ["id"]=> int(99) ["user_id"]=> int(73) ["marketer"]=> string(18) "Timothy Kukah | 73" ["target"]=> string(3) "200" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["original":protected]=> array(9) { ["id"]=> int(99) ["user_id"]=> int(73) ["marketer"]=> string(18) "Timothy Kukah | 73" ["target"]=> string(3) "200" ["_token"]=> NULL ["status"]=> int(1) ["vehicle"]=> string(10) "Unassigned" ["created_at"]=> string(19) "2020-01-07 13:11:47" ["updated_at"]=> string(19) "2020-01-07 13:11:47" } ["changes":protected]=> array(0) { } ["casts":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["dispatchesEvents":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=> bool(true) ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } } } }
you can use this below. hope it might help you. it's a simple code. I presume you have id column in your DB.
<table class="table is-striped">
#if(count($allmarketers) > 0)
<thead>
<tr>
<th>id</th>
<th>date</th>
</tr>
</thead>
#endif
<tbody>
#foreach ($allmarketers as $item)
<tr>
<td>{{$item->id}}</td>
<td>{{$item->created_at}}</td>
</tr>
#endforeach
</tbody>
</table>

How to get specific Array value from an Array in Laravel

I'd like to get a specific array data from an array I've get from this code :
$user = $request->instance()->query('user');
var_dump($user);exit;
And the result is :
array(1) { ["user"]=> object(App\Models\User)#332 (27) {
["fillable":protected]=> array(5) { [0]=> string(4) "name" [1]=>
string(8) "username" [2]=> string(5) "email" [3]=> string(8)
"password" [4]=> string(5) "token" } ["hidden":protected]=> array(2) {
[0]=> string(8) "password" [1]=> string(14) "remember_token" }
["casts":protected]=> array(1) { ["email_verified_at"]=> string(8)
"datetime" } ["connection":protected]=> string(5) "mysql"
["table":protected]=> string(5) "users" ["primaryKey":protected]=>
string(2) "id" ["keyType":protected]=> string(3) "int"
["incrementing"]=> bool(true) ["with":protected]=> array(0) { }
["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15)
["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false)
["attributes":protected]=> array(15) { ["id"]=> int(3) ["name"]=>
string(14) "Manchesteriyah" ["username"]=> string(14) "manchesteriyah"
["email"]=> string(24) "manchesteriyah#gmail.com" ["facebook"]=>
string(37) "https://web.facebook.com/xkionna" ["phone"]=> NULL
["email_verified_at"]=> NULL ["password"]=> string(60)
"$2y$10$IrqHE1JfyH0bJ0XD/Hjy.efLg95y/buTIir0PuXcOqDb1yCSS69Oe"
["image"]=> NULL ["description"]=> NULL ["role"]=> string(1) "1"
["token"]=> string(20) "ymsJxEtFnxdPBWYwlYFw" ["member_expiration"]=>
string(19) "2019-07-08 20:33:29" ["created_at"]=> string(19)
"2019-06-08 20:30:25" ["updated_at"]=> string(19) "2019-06-08
20:33:29" } ["original":protected]=> array(15) { ["id"]=> int(3)
["name"]=> string(14) "Manchesteriyah" ["username"]=> string(14)
"manchesteriyah" ["email"]=> string(24) "manchesteriyah#gmail.com"
["facebook"]=> string(37) "https://web.facebook.com/xkionna"
["phone"]=> NULL ["email_verified_at"]=> NULL ["password"]=>
string(60)
"$2y$10$IrqHE1JfyH0bJ0XD/Hjy.efLg95y/buTIir0PuXcOqDb1yCSS69Oe"
["image"]=> NULL ["description"]=> NULL ["role"]=> string(1) "1"
["token"]=> string(20) "ymsJxEtFnxdPBWYwlYFw" ["member_expiration"]=>
string(19) "2019-07-08 20:33:29" ["created_at"]=> string(19)
"2019-06-08 20:30:25" ["updated_at"]=> string(19) "2019-06-08
20:33:29" } ["changes":protected]=> array(0) { } ["dates":protected]=>
array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=>
array(0) { } ["dispatchesEvents":protected]=> array(0) { }
["observables":protected]=> array(0) { } ["relations":protected]=>
array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=>
bool(true) ["visible":protected]=> array(0) { }
["guarded":protected]=> array(1) { [0]=> string(1) "*" }
["rememberTokenName":protected]=> string(14) "remember_token" } }
What I'd like to get is the username value, I've tried some solution like this :
$user->username
but it give me error like this :
Trying to get property 'username' of non-object
How to fix this? Thanks for attention.
The $user variable seems to be holding an array containing 1 element, not the User itself. You must first retrieve the User object from the array and then access the username attribute.
$user = $request->instance()->query('user')['user'];
var_dump($user->username); exit;

die dump laravel strange behavior

That's is a kind of what I'm used to see in laravel when I use dd($var); function to see whats in the variable:
{
id: "1",
username: "Muzikman",
email: "matt.paolini#gmail.com",
password: "$2y$10$Sp7k9Fs0DwFSYHTpWrTWquFmXJpkiKfRIHsjYtdEXTvbdOJwv9AtG",
password_confirmation: "",
confirmation_code: "91f0583ed76c95ebf378648d65d0eac7",
remember_token: "bGmdTchXtilBj41FIazkFS3PDZzr1tVKmTFnMkeeSoD7wpW6hoQ07A42plle",
confirmed: "1",
created_at: "2014-10-19 12:17:55",
updated_at: "2014-10-20 15:07:01",
but in my app I have no idea why now I see like this when I dd($var);
object(OrdemServico)#728 (23) { ["guarded":protected]=> array(4) { [0]=> string(10) "updated_at" [1]=> string(10) "created_at" [2]=> string(10) "deleted_at" [3]=> string(2) "id" } ["fillable":protected]=> array(13) { [0]=> string(7) "tipo_id" [1]=> string(10) "cliente_id" [2]=> string(11) "contrato_id" [3]=> string(10) "tecnico_id" [4]=> string(10) "created_by" [5]=> string(10) "updated_by" [6]=> string(13) "data_execucao" [7]=> string(13) "tempo_servico" [8]=> string(18) "tempo_deslocamento" [9]=> string(5) "ativo" [10]=> string(10) "finalizada" [11]=> string(5) "os_id" [12]=> string(6) "visita" } ["dates":protected]=> array(1) { [0]=> string(10) "deleted_at" } ["errors"]=> NULL ["originalAttributes":protected]=> array(0) { } ["autoHydrateEntityFromInput"]=> bool(true) ["connection":protected]=> NULL ["table":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(0) { } ["original":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["with":protected]=> array(0) { } ["morphClass":protected]=> NULL ["exists"]=> bool(false) }
its all in the same line and hard to read and identify the attributes, how could fix this?
obs that's isnt the same object, I just got any from google in the first one, the second is my actual dd(); and how show the attributes
thx for help!

Php Json get first element info

so I'm using a PHP Twitter API to grab a list of tweets with a certain hashtag. I'm looking to get the following info from the returned json; 'screen_name' and 'text'.
The screen_name is on line 44 and the text is on line 20.
Here is the json output.
object(stdClass)#5 (2) {
["statuses"]=>
array(15) {
[0]=>
object(stdClass)#6 (24) {
["metadata"]=>
object(stdClass)#7 (2) {
["iso_language_code"]=>
string(2) "en"
["result_type"]=>
string(6) "recent"
}
["created_at"]=>
string(30) "Fri Dec 05 21:22:00 +0000 2014"
["id"]=>
float(5.4097942452372E+17)
["id_str"]=>
string(18) "540979424523718656"
["text"]=>
string(100) "Shits getting real. Crit happens tonight. #dnd #dungeonsanddragons #nerd #rpg http://t.co/44Lnrmmfte"
["source"]=>
string(59) "Instagram"
["truncated"]=>
bool(false)
["in_reply_to_status_id"]=>
NULL
["in_reply_to_status_id_str"]=>
NULL
["in_reply_to_user_id"]=>
NULL
["in_reply_to_user_id_str"]=>
NULL
["in_reply_to_screen_name"]=>
NULL
["user"]=>
object(stdClass)#8 (41) {
["id"]=>
int(1297196190)
["id_str"]=>
string(10) "1297196190"
["name"]=>
string(12) "Brandon Wade"
["screen_name"]=>
string(15) "Brandonus_Prime"
["location"]=>
string(15) "The woods of NC"
["profile_location"]=>
NULL
["description"]=>
string(29) "If it bleeds, we can kill it."
["url"]=>
string(22) "http://t.co/EkGUdm9yDO"
["entities"]=>
object(stdClass)#9 (2) {
["url"]=>
object(stdClass)#10 (1) {
["urls"]=>
array(1) {
[0]=>
object(stdClass)#11 (4) {
["url"]=>
string(22) "http://t.co/EkGUdm9yDO"
["expanded_url"]=>
string(34) "http://facebook.com/brandonusprime"
["display_url"]=>
string(27) "facebook.com/brandonusprime"
["indices"]=>
array(2) {
[0]=>
int(0)
[1]=>
int(22)
}
}
}
}
["description"]=>
object(stdClass)#12 (1) {
["urls"]=>
array(0) {
}
}
}
["protected"]=>
bool(false)
["followers_count"]=>
int(44)
["friends_count"]=>
int(246)
["listed_count"]=>
int(0)
["created_at"]=>
string(30) "Mon Mar 25 01:10:47 +0000 2013"
["favourites_count"]=>
int(18)
["utc_offset"]=>
NULL
["time_zone"]=>
NULL
["geo_enabled"]=>
bool(false)
["verified"]=>
bool(false)
["statuses_count"]=>
int(170)
["lang"]=>
string(2) "en"
["contributors_enabled"]=>
bool(false)
["is_translator"]=>
bool(false)
["is_translation_enabled"]=>
bool(false)
["profile_background_color"]=>
string(6) "C0DEED"
["profile_background_image_url"]=>
string(48) "http://abs.twimg.com/images/themes/theme1/bg.png"
["profile_background_image_url_https"]=>
string(49) "https://abs.twimg.com/images/themes/theme1/bg.png"
["profile_background_tile"]=>
bool(false)
["profile_image_url"]=>
string(99) "http://pbs.twimg.com/profile_images/378800000698263057/6592d36cf8e2beb02c9f3ee9abf4fdd7_normal.jpeg"
["profile_image_url_https"]=>
string(100) "https://pbs.twimg.com/profile_images/378800000698263057/6592d36cf8e2beb02c9f3ee9abf4fdd7_normal.jpeg"
["profile_banner_url"]=>
string(59) "https://pbs.twimg.com/profile_banners/1297196190/1364236862"
["profile_link_color"]=>
string(6) "0084B4"
["profile_sidebar_border_color"]=>
string(6) "C0DEED"
["profile_sidebar_fill_color"]=>
string(6) "DDEEF6"
["profile_text_color"]=>
string(6) "333333"
["profile_use_background_image"]=>
bool(true)
["default_profile"]=>
bool(true)
["default_profile_image"]=>
bool(false)
["following"]=>
bool(false)
["follow_request_sent"]=>
bool(false)
["notifications"]=>
bool(false)
}
["geo"]=>
NULL
["coordinates"]=>
NULL
["place"]=>
NULL
["contributors"]=>
NULL
["retweet_count"]=>
int(0)
["favorite_count"]=>
int(0)
["entities"]=>
object(stdClass)#13 (4) {
["hashtags"]=>
array(4) {
[0]=>
object(stdClass)#14 (2) {
["text"]=>
string(3) "dnd"
["indices"]=>
array(2) {
[0]=>
int(42)
[1]=>
int(46)
}
}
[1]=>
object(stdClass)#15 (2) {
["text"]=>
string(18) "dungeonsanddragons"
["indices"]=>
array(2) {
[0]=>
int(47)
[1]=>
int(66)
}
}
[2]=>
object(stdClass)#16 (2) {
["text"]=>
string(4) "nerd"
["indices"]=>
array(2) {
[0]=>
int(67)
[1]=>
int(72)
}
}
[3]=>
object(stdClass)#17 (2) {
["text"]=>
string(3) "rpg"
["indices"]=>
array(2) {
[0]=>
int(73)
[1]=>
int(77)
}
}
}
["symbols"]=>
array(0) {
}
["user_mentions"]=>
array(0) {
}
["urls"]=>
array(1) {
[0]=>
object(stdClass)#18 (4) {
["url"]=>
string(22) "http://t.co/44Lnrmmfte"
["expanded_url"]=>
string(34) "http://instagram.com/p/wPV3gmr1kl/"
["display_url"]=>
string(27) "instagram.com/p/wPV3gmr1kl/"
["indices"]=>
array(2) {
[0]=>
int(78)
[1]=>
int(100)
}
}
}
}
["favorited"]=>
bool(false)
["retweeted"]=>
bool(false)
["possibly_sensitive"]=>
bool(false)
["lang"]=>
string(2) "en"
}
}
Here is my PHP Code
<?php
require_once 'twitteroauth/twitteroauth.php';
define('CONSUMER_KEY', '');
define('CONSUMER_SECRET', '');
define('ACCESS_TOKEN', '-');
define('ACCESS_TOKEN_SECRET', '');
$toa = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$query = array(
"q" => "#nerd",
"result_type" => "recent"
);
$results = $toa->get('search/tweets', $query);
var_dump($results); die();
foreach ($results->statuses as $result) {
echo $result->user->screen_name . ": " . $result->text . "<br>";
}
Thanks a ton! I've been trying for a while and need some pointing in the right direction :)

Exclude Retweets in Twitter Search API 1.1

Here I'm trying to retrieve the tweets which has the tag 'V57' using search api 1.1. Dumped & seen the results of search term by using,
$search_tim = $connection->get('search/tweets',array('q' => ' #V57', 'count' => 5, 'result_type' => 'recent'));
This is the result after doing var_dump :
object(stdClass)#10 (2) {
["statuses"]=>
array(5) {
[0]=>
object(stdClass)#11 (25) {
["metadata"]=>
object(stdClass)#12 (2) {
["result_type"]=>
string(6) "recent"
["iso_language_code"]=>
string(2) "en"
}
["created_at"]=>
string(30) "Wed Feb 12 16:26:35 +0000 2014"
["id"]=>
float(4.33638273555E+17)
["id_str"]=>
string(18) "4336382731354561"
["text"]=>
string(131) "RT #useracc: Plz consult a doctor #V57"
["source"]=>
string(84) "Twitter for Android"
["truncated"]=>
bool(false)
["in_reply_to_status_id"]=>
NULL
["in_reply_to_status_id_str"]=>
NULL
["in_reply_to_user_id"]=>
NULL
["in_reply_to_user_id_str"]=>
NULL
["in_reply_to_screen_name"]=>
NULL
["user"]=>
object(stdClass)#13 (40) {
["id"]=>
int(965892252)
["id_str"]=>
string(9) "965892252"
["name"]=>
string(10) "khan"
["screen_name"]=>
string(10) "khan"
["location"]=>
string(0) ""
["url"]=>
NULL
["entities"]=>
object(stdClass)#14 (1) {
["description"]=>
object(stdClass)#15 (1) {
["urls"]=>
array(0) {
}
}
}
["protected"]=>
bool(false)
["followers_count"]=>
int(457)
["friends_count"]=>
int(500)
["listed_count"]=>
int(3)
["created_at"]=>
string(30) "Fri Nov 23 10:56:08 +0000 2012"
["favourites_count"]=>
int(129)
["utc_offset"]=>
int(19800)
["time_zone"]=>
string(7) "Chennai"
["geo_enabled"]=>
bool(false)
["verified"]=>
bool(false)
["statuses_count"]=>
int(3230)
["lang"]=>
string(2) "en"
["contributors_enabled"]=>
bool(false)
["is_translator"]=>
bool(false)
["is_translation_enabled"]=>
bool(false)
["profile_background_color"]=>
string(6) "0099B9"
["profile_background_image_url"]=>
string(48) "http://abs.twimg.com/images/themes/theme4/bg.gif"
["profile_background_image_url_https"]=>
string(49) "https://abs.twimg.com/images/themes/theme4/bg.gif"
["profile_background_tile"]=>
bool(false)
["profile_image_url"]=>
string(99) "http://pbs.twimg.com/profile_images/3788093993/0639a4b8297f9eea2cbb9de89f5c3a40_normal.jpeg"
["profile_image_url_https"]=>
string(100) "https://pbs.twimg.com/profile_images/37883993/0639a4b8297f9eea2cbb95c3a40_normal.jpeg"
["profile_banner_url"]=>
string(58) "https://pbs.twimg.com/profile_banners/9658922/1386619"
["profile_link_color"]=>
string(6) "0099B9"
["profile_sidebar_border_color"]=>
string(6) "5ED4DC"
["profile_sidebar_fill_color"]=>
string(6) "95E8EC"
["profile_text_color"]=>
string(6) "3C3940"
["profile_use_background_image"]=>
bool(true)
["default_profile"]=>
bool(false)
["default_profile_image"]=>
bool(false)
["following"]=>
bool(false)
["follow_request_sent"]=>
bool(false)
["notifications"]=>
bool(false)
}
["geo"]=>
NULL
["coordinates"]=>
NULL
["place"]=>
NULL
["contributors"]=>
NULL
["retweeted_status"]=>
object(stdClass)#16 (24) {
["metadata"]=>
object(stdClass)#17 (2) {
["result_type"]=>
string(6) "recent"
["iso_language_code"]=>
string(2) "en"
}
["created_at"]=>
string(30) "Wed Feb 12 15:33:36 +0000 2014"
["id"]=>
float(4.3362493936345E+17)
["id_str"]=>
string(18) "43362493446784"
["source"]=>
string(84) "Twitter for Android"
["truncated"]=>
bool(false)
["in_reply_to_status_id"]=>
NULL
["in_reply_to_status_id_str"]=>
NULL
["in_reply_to_user_id"]=>
NULL
["in_reply_to_user_id_str"]=>
NULL
["in_reply_to_screen_name"]=>
NULL
["user"]=>
object(stdClass)#18 (40) {
["id"]=>
int(168362964)
["id_str"]=>
string(9) "168362964"
["name"]=>
string(5) "usracc"
["screen_name"]=>
string(12) "useracc"
["location"]=>
string(16) "India."
["url"]=>
NULL
["entities"]=>
object(stdClass)#19 (1) {
["description"]=>
object(stdClass)#20 (1) {
["urls"]=>
array(0) {
}
}
}
["protected"]=>
bool(false)
["followers_count"]=>
int(651)
["friends_count"]=>
int(197)
["listed_count"]=>
int(6)
["created_at"]=>
string(30) "Mon Jul 19 03:54:15 +0000 2010"
["favourites_count"]=>
int(4267)
["utc_offset"]=>
int(19800)
["time_zone"]=>
string(7) "Chennai"
["geo_enabled"]=>
bool(true)
["verified"]=>
bool(false)
["statuses_count"]=>
int(10177)
["lang"]=>
string(2) "en"
["contributors_enabled"]=>
bool(false)
["is_translator"]=>
bool(false)
["is_translation_enabled"]=>
bool(false)
["profile_background_color"]=>
string(6) "C0DEED"
["profile_background_image_url"]=>
string(48) "http://abs.twimg.com/images/themes/theme1/bg.png"
["profile_background_image_url_https"]=>
string(49) "https://abs.twimg.com/images/themes/theme1/bg.png"
["profile_background_tile"]=>
bool(false)
["profile_image_url"]=>
string(75) "http://pbs.twimg.com/profile_images/4338561184/quFHKeYq_normal.jpeg"
["profile_image_url_https"]=>
string(76) "https://pbs.twimg.com/profile_images/433856131184/quFHKeYq_normal.jpeg"
["profile_banner_url"]=>
string(58) "https://pbs.twimg.com/profile_banners/168364/1392170036"
["profile_link_color"]=>
string(6) "0084B4"
["profile_sidebar_border_color"]=>
string(6) "C0DEED"
["profile_sidebar_fill_color"]=>
string(6) "DDEEF6"
["profile_text_color"]=>
string(6) "333333"
["profile_use_background_image"]=>
bool(true)
["default_profile"]=>
bool(true)
["default_profile_image"]=>
bool(false)
["following"]=>
bool(false)
["follow_request_sent"]=>
bool(false)
["notifications"]=>
bool(false)
}
["geo"]=>
NULL
["coordinates"]=>
NULL
["place"]=>
NULL
["contributors"]=>
NULL
["retweet_count"]=>
int(5)
["favorite_count"]=>
int(10)
["entities"]=>
object(stdClass)#21 (5) {
["hashtags"]=>
array(1) {
[0]=>
object(stdClass)#22 (2) {
["text"]=>
string(7) "v57"
["indices"]=>
array(2) {
[0]=>
int(76)
[1]=>
int(84)
}
}
}
["symbols"]=>
array(0) {
}
["urls"]=>
array(0) {
}
["favorited"]=>
bool(false)
["retweeted"]=>
bool(false)
["possibly_sensitive"]=>
bool(false)
["lang"]=>
string(2) "en"
}
["retweet_count"]=>
int(5)
["favorite_count"]=>
int(0)
Now, i would like to retrieve the original tweets alone which has V57 tag by ignoring all Retweets similar to this
string(131) "RT #useravv: Plz consult a doctor #V57"
I've googled and found this thread. But it was old API version.
My Doubt has been cleared. Thanks to the SO user Newbi3 :)
Here is a way to exclude Retweets in Search api 1.1
$search_tim = $connection->get('search/tweets',array('q' => ' #V57 -RT', 'count' => 5,'result_type' => 'recent'));
Adding -RT at the end of search term will filter it.
EDIT :
The above approach will simply eliminate the tweet too if they included #RT is in their status and username or screename. This will blindly ignore tweets when its sees RT. This is a temporary solution.
The permanent solution is, get the RT status & if if its retweet simply assign a value like 1 to a variable & 0 if its original. Eg..
if (isset($tweet_object->retweeted_status)) {
// This is a retweet
// Use the original tweet's entities, they are more complete
$entities = $tweet_object->retweeted_status->entities;
$is_rt = 1; // Set 1 if retweeted
} else {
$entities = $tweet_object->entities;
$is_rt = 0; // Set 0 if original
}
Then just do like,
if($is_rt==0) // if its a original tweet
{
...
....
}
I have found concatenating "-filter:retweets" to the end of your query string works best.
If you simply add -RT you might run into issues with accidentally filtering tweets containing "RT" for example "Russia Today" will use that string quite a lot!
The following pages describe Twitter search operators:
https://support.twitter.com/articles/71577-using-advanced-search
http://thesocialchic.com/2013/04/26/how-to-master-twitter-search/

Categories