Add news tables and models #52

This commit is contained in:
Nabeel Shahzad 2018-01-08 09:02:55 -06:00
parent 247310b4e7
commit 8d65462084
3 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNewsTable extends Migration
{
public function up()
{
Schema::create('news', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->string('subject');
$table->text('body');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('news');
}
}

View File

@ -85,6 +85,22 @@ ranks:
auto_approve_manual: 1
auto_promote: 0
news:
- id: 1
user_id: 1
subject: Some VA News!
body: >
Lorem Ipsum is simply dummy text of the printing and
typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown
printer took a galley of type and scrambled it to make a
type specimen book. It has survived not only five centuries,
but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with
the release of Letraset sheets containing Lorem Ipsum passages,
and more recently with desktop publishing software like
Aldus PageMaker including versions of Lorem Ipsum.
airports:
- id: KAUS
iata: AUS

32
app/Models/News.php Normal file
View File

@ -0,0 +1,32 @@
<?php
namespace App\Models;
/**
* Class News
* @package App\Models
*/
class News extends BaseModel
{
public $table = 'news';
public $fillable = [
'user_id',
'subject',
'body',
];
public static $rules = [
'subject' => 'required',
'body' => 'required',
];
/**
* FOREIGN KEYS
*/
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
}