generated from hans-thomas/package-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
aca950b
commit 002e372
Showing
5 changed files
with
103 additions
and
0 deletions.
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,19 @@ | ||
<?php | ||
|
||
namespace Hans\Lyra\Tests\Core\Models; | ||
|
||
use Hans\Lyra\Models\Invoice; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\MorphToMany; | ||
|
||
class Post extends Model { | ||
|
||
protected $fillable = [ | ||
'title', | ||
'description', | ||
]; | ||
|
||
public function invoices(): MorphToMany { | ||
return $this->morphToMany( Invoice::class, 'invoicable' ); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Hans\Lyra\Tests\Core\Models; | ||
|
||
use Hans\Lyra\Models\Invoice; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\MorphToMany; | ||
|
||
class Product extends Model { | ||
|
||
protected $fillable = [ | ||
'title', | ||
'brand' | ||
]; | ||
|
||
public function invoices(): MorphToMany { | ||
return $this->morphToMany( Invoice::class, 'invoicable' ); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
tests/Core/migrations/2023_08_25_100000_create_posts_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,31 @@ | ||
<?php | ||
|
||
use Hans\Lyra\Tests\Core\Models\Post; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class() extends Migration { | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up(): void { | ||
Schema::create( ( new Post )->getTable(), function( Blueprint $table ) { | ||
$table->id(); | ||
$table->string( 'title' ); | ||
$table->text( 'description' ); | ||
$table->timestamps(); | ||
} ); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down(): void { | ||
Schema::dropIfExists( ( new Post )->getTable() ); | ||
} | ||
}; |
32 changes: 32 additions & 0 deletions
32
tests/Core/migrations/2023_08_25_100001_create_products_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,32 @@ | ||
<?php | ||
|
||
use Hans\Lyra\Models\Invoice; | ||
use Hans\Lyra\Tests\Core\Models\Product; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class() extends Migration { | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up(): void { | ||
Schema::create( ( new Product )->getTable(), function( Blueprint $table ) { | ||
$table->id(); | ||
$table->string( 'name' ); | ||
$table->string( 'brand' ); | ||
$table->timestamps(); | ||
} ); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down(): void { | ||
Schema::dropIfExists( ( new Product )->getTable() ); | ||
} | ||
}; |
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