public function doEdit(Request $request, $id)
 {
     $project_input = $request->get('project');
     $project = Project::find($id);
     if (!$project) {
         return redirect('backend/admin/project');
     }
     $project->fill($project_input);
     $project->faculty()->associate(Faculty::find($project_input['faculty']['id']));
     if ($project_input['status']['id'] != "") {
         $project->status()->associate(ProjectStatus::find($project_input['status']['id']));
     } else {
         $project->status()->associate(ProjectStatus::where('key', '=', 'draft')->first());
     }
     $project->save();
     return redirect('/backend/admin/project');
 }
 public function index()
 {
     $statuses = ProjectStatus::all();
     return view('backends.admins.project-status-index')->with('statuses', $statuses);
 }
예제 #3
0
            @endif

        @elseif($role =="ADMIN")
            <div class="field">
                <label>สถานะโครงการ</label>
                <div class="ui selection dropdown" tabindex="0">
                    <input type="hidden" name="project[status][id]" value="{{$project->status_id}}">
                    @if($project->status_id)
                        <div class="text">{{$project->status->name}}</div>
                    @else
                        <div class="default text">กรุณาเลือก</div>
                    @endif
                    <i class="dropdown icon"></i>
                    <div class="menu transition hidden" tabindex="-1">
                        <?php 
$statuses = \App\Models\Project\ProjectStatus::all();
?>
                        @foreach($statuses as $status)
                            <div class="item {{ $project->status_id == $status->id ? "active" : ""  }}"
                                 data-value="{{$status->id}}">
                                {{$status->name}}
                            </div>
                        @endforeach

                    </div>
                </div>
            </div>
        @endif

        @if($type == "ADD")
            <button class="ui button" tabindex="0">บันทึกข้อมูลโครงการใหม่</button>
 public function doReject(Request $request, $id)
 {
     /* @var Project $project */
     $project = Project::with(['status'])->find($id);
     $previousStatus = ProjectStatus::where("key", '=', "draft")->first();
     $approveForm = $request->get('acceptForm');
     $approveComment = new ProjectApproveComment();
     $approveComment->project_id = $id;
     $approveComment->user_id = Auth::user()->id;
     $approveComment->is_accept = false;
     $approveComment->comment = $approveForm['comment'];
     $approveComment->from_status_id = $project->status->id;
     $approveComment->to_status_id = $previousStatus->id;
     $approveComment->save();
     $project->status()->associate($previousStatus)->save();
     return $project;
 }
예제 #5
0
 public function doSubmit(Request $request, $id)
 {
     /* @var Project $project */
     $project = Project::find($id);
     if (!$project) {
         return redirect('backend/admin/project');
     }
     if ($project) {
         $status = ProjectStatus::where('key', '=', 'faculty')->first();
         $project->status()->associate($status)->save();
     }
     return redirect('/backend/project');
 }