mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 13:24:03 +00:00
php 7.4 refactor
This commit is contained in:
parent
21c2fd4e94
commit
bb40b60d3e
4 changed files with 40 additions and 15 deletions
|
|
@ -40,7 +40,7 @@ class Thread extends Model
|
||||||
return $this->belongsTo(Author::class, 'author_username', 'username');
|
return $this->belongsTo(Author::class, 'author_username', 'username');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTweetUrlAttribute(): string|null
|
public function getTweetUrlAttribute(): string
|
||||||
{
|
{
|
||||||
return "https://twitter.com/{$this->author_username}/status/{$this->tweet_id}";
|
return "https://twitter.com/{$this->author_username}/status/{$this->tweet_id}";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,25 @@ use Illuminate\Support\Facades\Http;
|
||||||
*/
|
*/
|
||||||
class Tweet
|
class Tweet
|
||||||
{
|
{
|
||||||
|
public string $id;
|
||||||
|
public string $text;
|
||||||
|
public TwitterUser $author;
|
||||||
|
public string|null $threadId = null;
|
||||||
|
public array $images = [];
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public string $id,
|
string $id,
|
||||||
public string $text,
|
string $text,
|
||||||
public TwitterUser $author,
|
TwitterUser $author,
|
||||||
public string|null $threadId = null,
|
string|null $threadId = null,
|
||||||
public array $images = [],
|
array $images = [],
|
||||||
) {}
|
) {
|
||||||
|
$this->id = $id;
|
||||||
|
$this->text = $text;
|
||||||
|
$this->author = $author;
|
||||||
|
$this->threadId = $threadId;
|
||||||
|
$this->images = $images;
|
||||||
|
}
|
||||||
|
|
||||||
/** Fetch a tweet. */
|
/** Fetch a tweet. */
|
||||||
public static function fetch(string $id): Tweet
|
public static function fetch(string $id): Tweet
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,12 @@ namespace App\Twitter;
|
||||||
*/
|
*/
|
||||||
class TwitterImage
|
class TwitterImage
|
||||||
{
|
{
|
||||||
public function __construct(
|
public string $url;
|
||||||
public string $url,
|
|
||||||
) {}
|
public function __construct(string $url)
|
||||||
|
{
|
||||||
|
$this->url = $url;
|
||||||
|
}
|
||||||
|
|
||||||
public function __call($size, $args): string
|
public function __call($size, $args): string
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,20 @@ namespace App\Twitter;
|
||||||
|
|
||||||
class TwitterUser
|
class TwitterUser
|
||||||
{
|
{
|
||||||
|
public string $id;
|
||||||
|
public string $name;
|
||||||
|
public string $username;
|
||||||
|
public string $profile_image_url;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public string $id,
|
string $id,
|
||||||
public string $name,
|
string $name,
|
||||||
public string $username,
|
string $username,
|
||||||
public string $profile_image_url,
|
string $profile_image_url,
|
||||||
) {}
|
) {
|
||||||
|
$this->id = $id;
|
||||||
|
$this->name = $name;
|
||||||
|
$this->username = $username;
|
||||||
|
$this->profile_image_url = $profile_image_url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue