-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\Locations\Database\Factories; | ||
|
||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
use Tipoff\Locations\Models\Location; | ||
use Tipoff\Locations\Models\ProfileLink; | ||
|
||
class ProfileLinkFactory extends Factory | ||
{ | ||
/** | ||
* The name of the factory's corresponding model. | ||
* | ||
* @var string | ||
*/ | ||
protected $model = ProfileLink::class; | ||
|
||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array | ||
*/ | ||
public function definition() | ||
{ | ||
return [ | ||
'link' => $this->faker->url, | ||
'type' => $this->faker->text, | ||
'location_id' => Location::factory()->create()->id | ||
]; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
database/migrations/2021_03_04_214512_create_profile_links_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
use Tipoff\Locations\Models\Location; | ||
|
||
class CreateProfileLinkTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('profile_links', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('link'); | ||
$table->string('type'); | ||
|
||
$table->foreignIdFor(Location::class); | ||
$table->foreignIdFor(app('company'))->nullable(); | ||
$table->foreignIdFor(app('webpage'))->nullable(); | ||
$table->foreignIdFor(app('domain'))->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\Locations\Models; | ||
|
||
use Tipoff\Support\Models\BaseModel; | ||
use Tipoff\Support\Traits\HasCreator; | ||
use Tipoff\Support\Traits\HasPackageFactory; | ||
use Tipoff\Support\Traits\HasUpdater; | ||
|
||
class ProfileLink extends BaseModel | ||
{ | ||
use HasPackageFactory; | ||
use HasCreator; | ||
use HasUpdater; | ||
|
||
public function company() | ||
{ | ||
return $this->belongsTo(app('company')); | ||
} | ||
|
||
public function domain() | ||
{ | ||
return $this->belongsTo(app('domain')); | ||
} | ||
|
||
public function location() | ||
{ | ||
return $this->belongsTo(Location::class); | ||
} | ||
|
||
public function webpage() | ||
{ | ||
return $this->belongsTo(app('webpage')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\Locations\Policies; | ||
|
||
use Illuminate\Auth\Access\HandlesAuthorization; | ||
use Tipoff\Locations\Models\ProfileLink; | ||
use Tipoff\Support\Contracts\Models\UserInterface; | ||
|
||
class ProfileLinkPolicy | ||
{ | ||
use HandlesAuthorization; | ||
|
||
public function viewAny(UserInterface $user): bool | ||
{ | ||
return $user->hasPermissionTo('view profile links') ? true : false; | ||
} | ||
|
||
public function view(UserInterface $user, ProfileLink $profile_link): bool | ||
{ | ||
return $user->hasPermissionTo('view profile links') ? true : false; | ||
} | ||
|
||
public function create(UserInterface $user): bool | ||
{ | ||
return $user->hasPermissionTo('create profile links') ? true : false; | ||
} | ||
|
||
public function update(UserInterface $user, ProfileLink $profile_link): bool | ||
{ | ||
return $user->hasPermissionTo('update profile links'); | ||
} | ||
|
||
public function delete(UserInterface $user, ProfileLink $profile_link): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function restore(UserInterface $user, ProfileLink $profile_link): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function forceDelete(UserInterface $user, ProfileLink $profile_link): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\Locations\Tests\Unit\Models; | ||
|
||
use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
use Tipoff\Locations\Models\ProfileLink; | ||
use Tipoff\Locations\Tests\TestCase; | ||
|
||
class ProfileLinkTest extends TestCase | ||
{ | ||
use DatabaseTransactions; | ||
|
||
/** @test */ | ||
public function create() | ||
{ | ||
$model = ProfileLink::factory()->create(); | ||
$this->assertNotNull($model); | ||
} | ||
} |