Skip to content

Commit

Permalink
start event
Browse files Browse the repository at this point in the history
  • Loading branch information
fgoldoni committed Dec 10, 2019
1 parent ebbd75c commit 964ea53
Show file tree
Hide file tree
Showing 30 changed files with 785 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .idea/laravel.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ migrate: optimize ## migrate
$(PHP) artisan migrate:refresh

refresh: migrate ## refresh + php artisan module:seed Admin & php artisan module:seed Support
php artisan module:seed Roles & php artisan module:seed Users & php artisan module:seed Categories & php artisan module:seed Posts
php artisan module:seed Posts & php artisan module:seed Categories & php artisan module:seed Users & php artisan module:seed Roles
routes: optimize
$(PHP) artisan laroute:generate

Expand Down
5 changes: 5 additions & 0 deletions Modules/Events/Config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'name' => 'Events'
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateEventsTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('events', function (Blueprint $table) {
$table->increments('id');
$table->string('title')->default('');
$table->text('description')->nullable();
$table->longText('content')->nullable();
$table->string('address')->nullable();
$table->timestamp('start')->nullable();
$table->timestamp('end')->nullable();
$table->string('url')->nullable();
$table->string('color')->default('#00695C');
$table->boolean('all_day')->default(true);
$table->boolean('online')->default(false);
$table->integer('user_id')->nullable()->unsigned()->index();
$table->morphs('eventable');
$table->softDeletes();
$table->timestamps();
});

Schema::create('event_user', function (Blueprint $table) {
$table->increments('id');
$table->integer('event_id')->unsigned()->index();
$table->integer('user_id')->unsigned()->index();
$table->foreign('event_id')->references('id')->on('events')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
});

Schema::create('event_tag', function (Blueprint $table) {
$table->integer('tag_id')->nullable()->unsigned()->index();
$table->integer('event_id')->nullable()->unsigned()->index();
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
$table->foreign('event_id')->references('id')->on('events')->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*/
public function down()
{
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
Schema::dropIfExists('events');
Schema::dropIfExists('event_tag');
Schema::dropIfExists('event_user');
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
}
}
19 changes: 19 additions & 0 deletions Modules/Events/Database/Seeders/EventsDatabaseSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Modules\Events\Database\Seeders;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;

class EventsDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run()
{
Model::unguard();

// $this->call("OthersTableSeeder");
}
}
114 changes: 114 additions & 0 deletions Modules/Events/Entities/Event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

namespace Modules\Events\Entities;

use App\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;
use Modules\Attachments\Traits\AttachableTrait;
use Modules\Tags\Traits\TaggableTrait;
use Nicolaslopezj\Searchable\SearchableTrait;
use Spatie\Activitylog\Traits\LogsActivity;
use willvincent\Rateable\Rateable;

class Event extends Model
{
use SoftDeletes;
use LogsActivity;
use SearchableTrait;
use AttachableTrait;
use TaggableTrait;
use Rateable;

public $guarded = [];

protected $date = ['start', 'end', 'deleted_at', 'reminder_at'];

protected static $logAttributes = ['title', 'description', 'content', 'start', 'end', 'url', 'address', 'reminder_at'];

protected static $logOnlyDirty = true;

protected $casts = [
'all_day' => 'boolean',
'online' => 'boolean',
];

public $appends = ['slug', 'old', 'average_rating', 'user_average_rating'];

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

/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function attendees()
{
return $this->belongsToMany(User::class)->withTimestamps();
}

/**
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function eventable()
{
return $this->morphTo();
}

public function scopePublished($query, $published)
{
$query->where('online', $published);

return $query;
}

/**
* Searchable rules.
*
* @var array
*/
protected $searchable = [
/*
* Columns and their priority in search results.
* Columns with higher values are more important.
* Columns with equal values have equal importance.
*
* @var array
*/
'columns' => [
'events.id' => 10,
'events.title' => 10,
'events.start' => 10,
'users.first_name' => 10,
'users.last_name' => 10,
],
'joins' => [
'users' => ['events.user_id', 'users.id'],
],
];

/**
* @param $value
*
* @return mixed
*/
public function getSlugAttribute()
{
return str_slug($this->title);
}

/**
* @param $value
*
* @return mixed
*/
public function getOldAttribute()
{
return $this->start < Carbon::now();
}
}
88 changes: 88 additions & 0 deletions Modules/Events/Http/Controllers/EventsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

namespace Modules\Events\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;

class EventsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return view('events::index');
}

/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
return view('events::create');
}

/**
* Store a newly created resource in storage.
*
* @param Request $request
*
* @return Response
*/
public function store(Request $request)
{
}

/**
* Show the specified resource.
*
* @param int $id
*
* @return Response
*/
public function show($id)
{
return view('events::show');
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
{
return view('events::edit');
}

/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
*
* @return Response
*/
public function update(Request $request, $id)
{
}

/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
{
}
}
Loading

0 comments on commit 964ea53

Please sign in to comment.