mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 05:14:04 +00:00
improve thread links
This commit is contained in:
parent
57ab16675e
commit
4f2b5dc999
4 changed files with 19 additions and 6 deletions
|
|
@ -2,13 +2,21 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Twitter\Tweet;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Collection;
|
||||
use Orbit\Concerns\Orbital;
|
||||
|
||||
/**
|
||||
* @property string $slug
|
||||
* @property string $title
|
||||
* @property string|null $tweet_id
|
||||
* @property string $author_username
|
||||
* @property string $content
|
||||
* @property array $links
|
||||
*/
|
||||
class Thread extends Model
|
||||
{
|
||||
use Orbital;
|
||||
|
|
@ -59,4 +67,9 @@ class Thread extends Model
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function links(): Collection
|
||||
{
|
||||
return collect($this->links)->map(fn (array $link, string $key) => route('thread.link', ['thread' => $this, 'link' => $key]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue