Skip to content

Commit

Permalink
Merge pull request #12 from ducthang-vu/seeder-relationships
Browse files Browse the repository at this point in the history
seeder & relationships
  • Loading branch information
ducthang-vu authored Jul 7, 2020
2 parents 03bb3ae + dbc7978 commit fb3b388
Show file tree
Hide file tree
Showing 20 changed files with 223 additions and 47 deletions.
26 changes: 26 additions & 0 deletions app/Flat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Flat extends Model
{
//

/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('App\User');
}

/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function requests()
{
return $this->hasMany('App\Request');
}
}
18 changes: 18 additions & 0 deletions app/Request.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Request extends Model
{
//

/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function flat()
{
return $this->belongsTo('App\Flat');
}
}
10 changes: 10 additions & 0 deletions app/Service.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Service extends Model
{
//
}
10 changes: 10 additions & 0 deletions app/Sponsorship.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Sponsorship extends Model
{
//
}
10 changes: 9 additions & 1 deletion app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ class User extends Authenticatable
protected $casts = [
'email_verified_at' => 'datetime',
];
}

/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function flats()
{
return $this->hasMany('App\Flat');
}
}
51 changes: 51 additions & 0 deletions config/schematics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Schematics
|--------------------------------------------------------------------------
|
| Here you may define the namespaces, middleware and toggle auto-migration.
| Middleware will be applied to the schematic routes and auto-migration
| will run the up and down methods on edit events through the UI.
|
*/

'controller-namespace' => null,
'form-request-namespace' => 'App\\Http\\Requests',
'model' => [
'namespace' => 'App\\',
'path' => app_path(),
'paths' => [
app_path(),
],
],
'middleware' => null,
'auto-migrate' => false,

/*
|--------------------------------------------------------------------------
| Create, Update & Delete
|--------------------------------------------------------------------------
|
| Here you may define defaults for the scaffolding. These will set
| the checkboxes in the forms to be checked or not.
|
*/

'create' => [
'migration' => false,
'resource-controller' => false,
'form-request' => false,
],

'update' => [
'migration' => false,
],

'delete' => [
'migration' => false,
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function up()
Schema::create('sponsorships', function (Blueprint $table) {
$table->id();
$table->string('sponsor_type');
$table->float('price', 3, 2);
$table->time('duration');
$table->timestamps();

Expand Down
45 changes: 0 additions & 45 deletions database/migrations/2020_07_07_151351_create_flats_table.php

This file was deleted.

6 changes: 5 additions & 1 deletion database/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
$this->call(UserSeeder::class);
$this->call([
UserSeeder::class,
SponsorshipSeeder::class
]
);
}
}
42 changes: 42 additions & 0 deletions database/seeds/SponsorshipSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

use Illuminate\Database\Seeder;
use App\Sponsorship;

class SponsorshipSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$sponsorships = [
[
'type' => '24 ore',
'price' => 2.99,
'duration' => '24:00:00'
],
[
'type' => '72 ore',
'price' => 5.99,
'duration' => '72:00:00'
],
[
'type' => '144 ore',
'price' => 9.99,
'duration' => '144:00:00'
]
];

foreach ($sponsorships as $sponsorship) {
$new_sponsorship = new Sponsorship();
$new_sponsorship->sponsor_type = $sponsorship['type'];
$new_sponsorship->price = $sponsorship['price'];
$new_sponsorship->duration = $sponsorship['duration'];

$new_sponsorship->save();
};
}
}
3 changes: 3 additions & 0 deletions public/vendor/schematics/app.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/vendor/schematics/app.js

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions public/vendor/schematics/app.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*!
* Font Awesome Free 5.12.1 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
*/

/*!
* Sizzle CSS Selector Engine v2.3.4
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2019-04-08
*/

/*!
* Vue.js v2.6.11
* (c) 2014-2019 Evan You
* Released under the MIT License.
*/

/*!
* jQuery JavaScript Library v3.4.1
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2019-05-01T21:04Z
*/

/**!
* Sortable 1.10.2
* @author RubaXa <[email protected]>
* @author owenm <[email protected]>
* @license MIT
*/
Binary file added public/vendor/schematics/images/bottom-arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/vendor/schematics/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/vendor/schematics/images/icon_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/vendor/schematics/images/left-arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/vendor/schematics/images/right-arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/vendor/schematics/images/top-arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/vendor/schematics/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"/app.js": "/app.js",
"/app.css": "/app.css"
}

0 comments on commit fb3b388

Please sign in to comment.