Skip to content

Commit

Permalink
50-when create new board we can set owner id as manager
Browse files Browse the repository at this point in the history
  • Loading branch information
saber13812002 committed Jul 31, 2020
1 parent 367caff commit 42ecd64
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ public function getDashboard()
}
//dd($departments->toArray());
}
$users = User::all();

if ($isMojri == true) {
$boards = $this->board->getUserBoards(Auth::id());
$departments = $boards->first()->department()->get();
$starredBoards = $this->board->getUserStarredBoards(Auth::id());
return view('user.home', compact('boards', 'starredBoards', 'departments', 'isMojri'));
return view('user.home', compact('boards', 'starredBoards', 'departments', 'isMojri', 'users'));
} else {
$boards = [];
$starredBoards = [];
return view('user.home', compact('boards', 'starredBoards', 'departments', 'isMojri'));
return view('user.home', compact('boards', 'starredBoards', 'departments', 'isMojri', 'users'));
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/Models/Board.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Board extends Model
protected $table = "board";

protected $fillable = [
'user_id', 'boardTitle', 'boardPrivacyType' , 'department_id',
'user_id', 'boardTitle', 'boardPrivacyType' , 'department_id', 'owner_id',
];

public function getUserBoards($user_id)
Expand All @@ -35,6 +35,7 @@ public function createBoard($input, $user_id)
'boardTitle' => $input->get('boardTitle'),
'boardPrivacyType' => $input->get('boardPrivacyType'),
'department_id' => $department_id,
'owner_id' => $input->get('boardAdminUserId'),
]);
}

Expand Down
31 changes: 31 additions & 0 deletions database/migrations/2020_08_01_212552_update_board_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

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

class UpdateBoardTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('board', function (Blueprint $table) {
$table->unsignedInteger('owner_id')->nullable();
$table->foreign('owner_id')->references('id')->on('users');

});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropColumn('owner_id');
}
}
2 changes: 2 additions & 0 deletions public/js/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,7 @@ $(document).ready(function () {
data: {
boardTitle: that.params["boardTitle"].val(),
boardPrivacyType: that.params["boardPrivacyType"].val(),
boardAdminUserId: that.params["boardAdminUserId"].val(),
},
success: function (data) {
$(that.params["createBoardLink"])
Expand Down Expand Up @@ -1402,6 +1403,7 @@ $(document).ready(function () {
Board.init({
boardTitle: $("#boardTitle"),
boardPrivacyType: $("#boardPrivacyType"),
boardAdminUserId: $("#boardAdminUserId"),
saveBoardBtn: $("#save-board"),
addGroupBtn: $("#add-group"),
createNewBoardModal: $("#create-new-board"),
Expand Down
12 changes: 11 additions & 1 deletion resources/views/layouts/partials/modal.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
</div>
<div class="group-con frame" style="margin-top: 12px; max-height: 235px; overflow: scroll;"></div>

<div class="form-group" id="boardAdminUserIdCon">
<p><span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span> مدیر بورد</p>
<select name="boardAdminUserId" id="boardAdminUserId" class="form-control" required="required">
<option value="">انتخاب یک مدیر...</option>
@foreach($users as $user)
<option value="{{ $user['id'] }}">{{ $user["name"] }}</option>
@endforeach
</select>
</div>

<div class="form-group" id="boardPrivacyTypeCon">
<p><span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span> این بورد خصوصی خواهد بود</p>
<select name="boardPrivacyType" id="boardPrivacyType" class="form-control" required="required">
Expand All @@ -28,7 +38,7 @@
<option value="public">عمومی</option>
</select>
</div>
</form>
</form>
<!-- base_url:8000/postboard -->
</div>
<div class="modal-footer">
Expand Down

0 comments on commit 42ecd64

Please sign in to comment.