-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from fleetbase/dev-v1.3.13
v1.3.13
- Loading branch information
Showing
40 changed files
with
453 additions
and
108 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
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,46 @@ | ||
<?php | ||
|
||
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() | ||
{ | ||
Schema::create('comments', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->uuid('uuid')->nullable()->index(); | ||
$table->string('public_id')->nullable()->unique(); | ||
$table->foreignUuid('company_uuid')->references('uuid')->on('companies')->onUpdate('CASCADE')->onDelete('CASCADE'); | ||
$table->foreignUuid('author_uuid')->references('uuid')->on('users')->onUpdate('CASCADE')->onDelete('CASCADE'); | ||
// $table->foreignUuid('parent_comment_uuid')->nullable()->references('uuid')->on('comments')->onUpdate('CASCADE')->onDelete('CASCADE'); | ||
$table->uuid('subject_uuid'); | ||
$table->string('subject_type')->nullable(); | ||
$table->mediumText('content'); | ||
$table->json('tags')->nullable(); | ||
$table->json('meta')->nullable(); | ||
$table->timestamps(); | ||
$table->softDeletes(); | ||
}); | ||
|
||
Schema::table('comments', function (Blueprint $table) { | ||
$table->foreignUuid('parent_comment_uuid')->nullable()->after('author_uuid')->references('uuid')->on('comments')->onUpdate('CASCADE')->onDelete('CASCADE'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('comments'); | ||
} | ||
}; |
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
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,15 @@ | ||
<?php | ||
|
||
namespace Fleetbase\Http\Controllers\Internal\v1; | ||
|
||
use Fleetbase\Http\Controllers\FleetbaseController; | ||
|
||
class CommentController extends FleetbaseController | ||
{ | ||
/** | ||
* The resource to query. | ||
* | ||
* @var string | ||
*/ | ||
public $resource = 'comments'; | ||
} |
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
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
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,30 @@ | ||
<?php | ||
|
||
namespace Fleetbase\Http\Filter; | ||
|
||
use Fleetbase\Support\Utils; | ||
use Illuminate\Support\Str; | ||
|
||
class CommentFilter extends Filter | ||
{ | ||
public function queryForInternal() | ||
{ | ||
$this->builder->where('company_uuid', $this->session->get('company')); | ||
} | ||
|
||
public function parent(string $id) { | ||
if (Str::isUuid($id)) { | ||
$this->builder->where('parent_comment_uuid', $id); | ||
} | ||
|
||
if (Utils::isPublicId($id)) { | ||
$this->builder->whereHas('parent', function ($query) use ($id) { | ||
$this->builder->where('public_id', $id); | ||
}); | ||
} | ||
} | ||
|
||
public function withoutParent() { | ||
$this->builder->whereNull('parent_comment_uuid'); | ||
} | ||
} |
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
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
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,37 @@ | ||
<?php | ||
|
||
namespace Fleetbase\Http\Resources; | ||
|
||
use Fleetbase\Support\Http; | ||
|
||
class Author extends FleetbaseResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* | ||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable | ||
*/ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id), | ||
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid), | ||
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id), | ||
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid), | ||
'avatar_uuid' => $this->when(Http::isInternalRequest(), $this->avatar_uuid), | ||
'name' => $this->name, | ||
'email' => $this->email, | ||
'phone' => $this->phone, | ||
'country' => $this->country, | ||
'avatar_url' => $this->avatar_url, | ||
'company_name' => $this->company_name, | ||
// 'type' => $this->type, | ||
'is_admin' => $this->is_admin, | ||
'timezone' => $this->timezone, | ||
'updated_at' => $this->updated_at, | ||
'created_at' => $this->created_at, | ||
]; | ||
} | ||
} |
Oops, something went wrong.