-
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
30 changed files
with
785 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,5 @@ | ||
<?php | ||
|
||
return [ | ||
'name' => 'Events' | ||
]; |
60 changes: 60 additions & 0 deletions
60
Modules/Events/Database/Migrations/2019_12_10_212140_create_events_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,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'); | ||
} | ||
} |
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 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"); | ||
} | ||
} |
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,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(); | ||
} | ||
} |
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,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) | ||
{ | ||
} | ||
} |
Oops, something went wrong.