diff --git a/app/Entities/Subscriptions/Subscription.php b/app/Entities/Subscriptions/Subscription.php index 1829921..e5d4c0e 100755 --- a/app/Entities/Subscriptions/Subscription.php +++ b/app/Entities/Subscriptions/Subscription.php @@ -35,6 +35,21 @@ class Subscription extends Model } /** + * Show subscription name with link to subscription detail attribute. + * + * @return Illuminate\Support\HtmlString + */ + public function getNameLinkAttribute() + { + return link_to_route('subscriptions.show', $this->name, $this, [ + 'title' => __( + 'app.show_detail_title', + ['name' => $this->name, 'type' => __('subscription.subscription')] + ), + ]); + } + + /** * Check weather the subscription is near it's due date. * * @return bool diff --git a/tests/Unit/Models/SubscriptionTest.php b/tests/Unit/Models/SubscriptionTest.php index 9c7791f..fde1ef9 100644 --- a/tests/Unit/Models/SubscriptionTest.php +++ b/tests/Unit/Models/SubscriptionTest.php @@ -31,6 +31,21 @@ class SubscriptionTest extends TestCase } /** @test */ + public function it_has_name_link_attribute() + { + $subscription = factory(Subscription::class)->create(); + + $this->assertEquals( + link_to_route('subscriptions.show', $subscription->name, $subscription, [ + 'title' => trans( + 'app.show_detail_title', + ['name' => $subscription->name, 'type' => trans('subscription.subscription')] + ), + ]), $subscription->name_link + ); + } + + /** @test */ public function it_has_near_of_due_date_method() { $next3Months = Carbon::now()->addMonths(3)->format('Y-m-d');