-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bookmarks for problems and table styling
- Loading branch information
1 parent
7160029
commit 880da04
Showing
11 changed files
with
112 additions
and
22 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
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
15 changes: 15 additions & 0 deletions
15
...ollers/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemUserBookmarkController.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,15 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\CrowdSourcingProject\Problem; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
|
||
class CrowdSourcingProjectProblemUserBookmarkController extends Controller { | ||
/** | ||
* Create or delete a bookmark for a problem for a user. | ||
*/ | ||
public function createOrDeleteProblemBookmarkForUser(Request $request) { | ||
throw new \Exception('Not implemented'); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
app/Models/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemUserBookmark.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,30 @@ | ||
<?php | ||
|
||
namespace App\Models\CrowdSourcingProject\Problem; | ||
|
||
use App\Models\Language; | ||
use App\Models\User; | ||
use Awobaz\Compoships\Compoships; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
|
||
class CrowdSourcingProjectProblemUserBookmark extends Model { | ||
use Compoships; | ||
|
||
protected $table = 'csp_problem_user_bookmarks'; | ||
protected $fillable = ['problem_id', 'user_id', 'problem_bookmark_language_id']; | ||
protected $primaryKey = ['problem_id', 'user_id']; | ||
public $incrementing = false; | ||
|
||
public function problem(): BelongsTo { | ||
return $this->belongsTo(CrowdSourcingProjectProblem::class, 'problem_id', 'id'); | ||
} | ||
|
||
public function user(): BelongsTo { | ||
return $this->belongsTo(User::class, 'user_id', 'id'); | ||
} | ||
|
||
public function language(): BelongsTo { | ||
return $this->belongsTo(Language::class, 'problem_bookmark_language_id', 'id'); | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
...grations/2024_11_14_104154_create_crowd_sourcing_project_problem_user_bookmarks_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,35 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration { | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void { | ||
Schema::create('csp_problem_user_bookmarks', function (Blueprint $table) { | ||
$table->unsignedBigInteger('problem_id'); | ||
$table->foreign('problem_id')->references('id')->on('crowd_sourcing_project_problems'); | ||
|
||
$table->unsignedInteger('user_id'); | ||
$table->foreign('user_id')->references('id')->on('users'); | ||
|
||
$table->primary(['problem_id', 'user_id'], 'csp_problem_user_bookmarks_primary'); | ||
|
||
// the language in which the user bookmarked the problem | ||
$table->unsignedInteger('problem_bookmark_language_id'); | ||
$table->foreign('problem_bookmark_language_id')->references('id')->on('languages_lkp'); | ||
|
||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void { | ||
Schema::dropIfExists('csp_problem_user_bookmarks'); | ||
} | ||
}; |
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