aishahyaacob

aishahyaacob

Member Since 5 Months Ago

Experience Points
1,050
Total
Experience

3,950 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
1,050 XP
06 May
4 months ago
01 May
4 months ago

aishahyaacob left a reply on Property [totalMark] Does Not Exist On This Collection Instance

@SNAPEY - do you mean like this: @foreach ($totalMarks as $totalMark)

{{$user->questionAnswer->sum('totalMark')}} @endforeach

aishahyaacob left a reply on Property [totalMark] Does Not Exist On This Collection Instance

@SNAPEY - it's work. but what i want to do is not to sum up all the mark, i want to display every totalmark for every time the user answer the the questionnaire. for example, if the same user had answered three times, so the list of totalMark will appear three times also. if the first time answered, the totalMatk he got is 4. and for the second totalMark time he answered, he got 3. so i want his name and both of his total Mark is appear . so he can know, for the first time he got 4, and the second time he got 3.

can u give me a help on how to get the totalMark?

30 Apr
4 months ago

aishahyaacob left a reply on Property [totalMark] Does Not Exist On This Collection Instance

@TRAY2 - i had create the relationship. this is user.php

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
//use App\Http\Controllers\Auth;
////use Illuminate\Support\Facades\Auth;

/**
 * @property mixed role
 */
class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'role_id'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function role()
    {
        return $this->belongsTo('App\Role');
    }

    public function isAdmin() {

        if($this->role->name == 'Admin'){

            return true;
        }
        return false;
    }

    public function isStudent() {

        if($this->role->name == 'Student'){

            return true;
        }
        return false;
    }



    public function questionAnswer()
    {
        return $this->hasMany('App\QuestionAnswer');
    }


}

this is QuestionAnswer.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class QuestionAnswer extends Model
{
    
    // to insert data
    protected $fillable = [
        'user_id', 'totalMark',
    ];

    //relationship to user, question,answer
    public function user()
    {
        return $this->belongsTo('App\User');
    }


    public function suggestion()
    {
        return $this->belongsTo('App\Suggestion');
    }

    
    
    
}

can u help me the way how to get the totalMark?

aishahyaacob left a reply on Property [totalMark] Does Not Exist On This Collection Instance

@TRAY2 - i want to display name and totalMark. for example like this https://imgur.com/a/hxJuuyI. right now i only can retrieve name from the table user.i also want to get totalMark to be display

aishahyaacob started a new conversation Property [totalMark] Does Not Exist On This Collection Instance

i want to display name and totalMark, right now able to display name only. i cannot display totalMarl. name is in tableuser while totalMark in table questionAnswer. here is the error https://imgur.com/a/x82Wwsg

this is my list.blade

@extends('layouts.app')

@section('content')
    <div class="col-sm-9">
        <h1 style="text-align:center";>List of student's name</h1>

        {!! Form::open(['method' => 'POST', 'action'=> '[email protected]']) !!}
        <table class="table">
            <thead>
            <tr>
                <th>Name</th>
                <th>Total Mark</th>
            </tr>
            </thead>
            <tbody>
            @foreach ($users as $user)
                <tr>
                    <td>{{ $user->name }}</td>
                    <td>{{ $user->questionAnswer->totalMark }}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
        {{--{!! Form::close !!}--}}
    </div>
@endsection

this is the controller

<?php

namespace App\Http\Controllers;

use App\Question;
use App\Answer;
use App\QuestionAnswer;
use App\Suggestion;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Route;


class QuestionAnswerController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {

        $questions = Question::all();
        $answers = Answer::all();

        return view('student.q_a.index', compact('questions', 'answers'));

    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {


    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $user_id = Auth::user()->id;
        $totalMarks = 0;


        // $key = question number
        // $value = score/scale
        $answer = $request->input('answer');

        foreach ($answer as $key => $value) {
            $totalMarks += $value;
        }

        $questionAnswer = [
            'user_id' => $user_id,
            'totalMark' => $totalMarks / 40 //store in database
        ];

        QuestionAnswer::create($questionAnswer);

        $marks = $questionAnswer['totalMark'];

        if($marks < 1.00){
            return 'No Suggestion';
        }
        else if($marks>=1.00 && $marks <=2.33){
            $suggestions = Suggestion::where('category','Low')->get();
        }
        else if ($marks>=2.34 && $marks <=3.67){
            $suggestions = Suggestion::where('category','Moderate')->get();
        }
        else if ($marks>=3.68 && $marks<=5){
            $suggestions = Suggestion::where('category','High')->get();
        }

       $category=Suggestion::all();
        return view('student.q_a.display', compact('suggestions','category'));

    }


    /**
     * Display the specified resource.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function show(QuestionAnswer $questionAnswer)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function edit(QuestionAnswer $questionAnswer)
    {

    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, QuestionAnswer $questionAnswer)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function destroy(QuestionAnswer $questionAnswer)
    {
        //
    }


    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function score()
    {
        $user_id = Auth::user()->id;
        $totalMarks= QuestionAnswer::where('user_id',$user_id)->get();
        $timestamps = QuestionAnswer::all();

        return view('student.q_a.score', compact('totalMarks', 'timestamps'));
    }


    public function list()
    {
        $users = User::has('questionAnswer')->with('questionAnswer')->get();
//        $totalMark=QuestionAnswer::all();

        return view('admin.studentList.list', compact( 'users'));

    }



}

aishahyaacob left a reply on How To Retrieve Two Data

@BOBBYBOUWMANN - done. thank you :)

aishahyaacob left a reply on To Display Only Once

@SNAPEY - it has three category which are low, moderate and high. here are my suggestion in database https://imgur.com/a/lcQhNq4 so, the suggestion will display according to the mark, the mark will determine what category of suggestions need to be display. i had also post the controller

29 Apr
4 months ago

aishahyaacob left a reply on To Display Only Once

@SNAPEY - i tried use if only, but the error occured. can you help me how to write it correctly?

aishahyaacob started a new conversation To Display Only Once

i want to display the category only once. this is my view for now, https://imgur.com/a/dYMeVvO i want to get the moderate only once. this is my display.blade

@extends('layouts.app')

@section('content')
    <div class="col-sm-9">
        <h1>Suggestion</h1>
        <p>Your level is:</p>
        @if($suggestions)
            @foreach($suggestions as $suggestion)
            <td>{{$suggestion->category}}</td><br>
            @endforeach
        {{[email protected]}}
      <br>  <p>There are some suggestion for you to reduce your stress:</p>

        {{--{!! Form::open(['method' => 'POST', 'action'=> '[email protected]']) !!}--}}


        <div class="container-fluid" id="dynamic_field">
            {{--store data form in array for multiple question--}}

            <table class="table table-bordered" id="dynamic_field">
                <tr>
                    <th>Suggestion</th>
                    {{--<th>Level of Stress</th>--}}

                {{[email protected]($suggestions)--}}
                    @foreach($suggestions as $suggestion)
                        <tr>
                            <td>{{$suggestion->suggestion}}</td>
                            {{--<td>{{$suggestion->category}}</td>--}}
                        </tr>
                    @endforeach
                @endif

            </table>
        </div>

        <br/>
    </div>

@endsection


this is my controller

<?php

namespace App\Http\Controllers;

use App\Question;
use App\Answer;
use App\QuestionAnswer;
use App\Suggestion;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Route;


class QuestionAnswerController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {

        $questions = Question::all();
        $answers = Answer::all();

        return view('student.q_a.index', compact('questions', 'answers'));

    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {


    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $user_id = Auth::user()->id;
        $totalMarks = 0;


        // $key = question number
        // $value = score/scale
        $answer = $request->input('answer');

        foreach ($answer as $key => $value) {
            $totalMarks += $value;
        }

        $questionAnswer = [
            'user_id' => $user_id,
            'totalMark' => $totalMarks / 40 //store in database
        ];

        QuestionAnswer::create($questionAnswer);

        $marks = $questionAnswer['totalMark'];

        if($marks < 1.00){
            return 'No Suggestion';
        }
        else if($marks>=1.00 && $marks <=2.33){
            $suggestions = Suggestion::where('category','Low')->get();
        }
        else if ($marks>=2.34 && $marks <=3.67){
            $suggestions = Suggestion::where('category','Moderate')->get();
        }
        else if ($marks>=3.68 && $marks<=5){
            $suggestions = Suggestion::where('category','High')->get();
        }

        $category=Suggestion::all();
        return view('student.q_a.display', compact('suggestions','category'));

    }


    /**
     * Display the specified resource.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function show(QuestionAnswer $questionAnswer)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function edit(QuestionAnswer $questionAnswer)
    {

    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, QuestionAnswer $questionAnswer)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function destroy(QuestionAnswer $questionAnswer)
    {
        //
    }


    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function score()
    {
        $user_id = Auth::user()->id;
//      $totalMarks= QuestionAnswer::where('user_id',$user_id);
        $totalMarks= QuestionAnswer::where('user_id',$user_id)->get();
//        $totalMarks = QuestionAnswer::all();
        $timestamps = QuestionAnswer::all();
//

        return view('student.q_a.score', compact('totalMarks', 'timestamps'));
    }


    public function list()
    {


        $users = User::has('questionAnswer')->with('questionAnswer')->get();
//        $totalMarks=QuestionAnswer::all();

        return view('admin.studentList.list', compact( 'users'));

    }



}

aishahyaacob left a reply on How To Retrieve Two Data

@BOBBYBOUWMANN - sorry my bad. thank you for helping me. thank you very much. :)

28 Apr
4 months ago

aishahyaacob left a reply on How To Retrieve Two Data

@SIANGBOON - where should i change? can you help me?

aishahyaacob left a reply on How To Retrieve Two Data

@BOBBYBOUWMANN - this is the error even i had follow your coding https://imgur.com/a/kJ3JrMW

aishahyaacob left a reply on How To Retrieve Two Data

@SIANGBOON - this is the error occured even i had follow the coding given. https://imgur.com/a/kJ3JrMW

aishahyaacob left a reply on How To Retrieve Two Data

@BOBBYBOUWMANN - it still does not working. still has error.

aishahyaacob left a reply on How To Retrieve Two Data

@BOBBYBOUWMANN - this is user.php

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
//use App\Http\Controllers\Auth;
////use Illuminate\Support\Facades\Auth;

/**
 * @property mixed role
 */
class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'role_id'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function role()
    {
        return $this->belongsTo('App\Role');
    }

    public function isAdmin() {

        if($this->role->name == 'Admin'){

            return true;
        }
        return false;
    }

    public function isStudent() {

        if($this->role->name == 'Student'){

            return true;
        }
        return false;
    }



    public function questionAnswer()
    {
        return $this->hasMany('App\QuestionAnswer');
    }


}

this isin questionAnswer.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class QuestionAnswer extends Model
{
    
    // to insert data
    protected $fillable = [
        'user_id', 'totalMark'
    ];

    //relationship to user, question,answer
    public function user()
    {
        return $this->belongsTo('App\User');
    }

//    public function question()
//    {
//        return $this->belongsTo('App\Question');
//    }
//
//    public function answer()
//    {
//        return $this->belongsTo('App\Answer');
//    }

    public function suggestion()
    {
        return $this->belongsTo('App\Suggestion');
    }

    
    
    
}

aishahyaacob started a new conversation How To Retrieve Two Data

i want to retrieve two data from database which are name and totalMark and view it in list.blade. here is my list.blade

@extends('layouts.app')

@section('content')
   <div class="col-sm-9">
       <h1 style="text-align:right";>STUDENT ACADEMIC STRESS SCALE (SASS)</h1>

       {{--{!! Form::open(['method' => 'POST', 'action'=> '[email protected]']) !!}--}}
       <table class="table">
           <thead>
           <tr>
               <th>Name</th>
               <th>Total Mark</th>
           </tr>
           </thead>
           <tbody>

           {{[email protected]($)--}}
               {{[email protected]($user_names as $user_name)--}}
                   {{--<tr>--}}
                       {{--<td>{{$user_name->user_name}}</td>--}}
                   {{--</tr>--}}
               {{[email protected]}}
           {{[email protected]}}

           </tbody>
       </table>
       {{--{!! Form::close !!}--}}
   </div>
@endsection

here is my controller

<?php

namespace App\Http\Controllers;

use App\Question;
use App\Answer;
use App\QuestionAnswer;
use App\Suggestion;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Route;


class QuestionAnswerController extends Controller
{
   /**
    * Display a listing of the resource.
    *
    * @return \Illuminate\Http\Response
    */
   public function index()
   {

       $questions = Question::all();
       $answers = Answer::all();

       return view('student.q_a.index', compact('questions', 'answers'));

   }

   /**
    * Show the form for creating a new resource.
    *
    * @return \Illuminate\Http\Response
    */
   public function create()
   {


   }

   /**
    * Store a newly created resource in storage.
    *
    * @param  \Illuminate\Http\Request $request
    * @return \Illuminate\Http\Response
    */
   public function store(Request $request)
   {
       $user_id = Auth::user()->id;
       $totalMarks = 0;


       // $key = question number
       // $value = score/scale
       $answer = $request->input('answer');

       foreach ($answer as $key => $value) {
           $totalMarks += $value;
       }

       $questionAnswer = [
           'user_id' => $user_id,
           'totalMark' => $totalMarks / 40 //store in database
       ];

       QuestionAnswer::create($questionAnswer);

       $marks = $questionAnswer['totalMark'];

       if($marks < 1.00){
           return 'No Suggestion';
       }
       else if($marks>=1.00 && $marks <=2.33){
           $suggestions = Suggestion::where('category','Low')->get();
       }
       else if ($marks>=2.34 && $marks <=3.67){
           $suggestions = Suggestion::where('category','Moderate')->get();
       }
       else if ($marks>=3.68 && $marks<=5){
           $suggestions = Suggestion::where('category','High')->get();
       }


       return view('student.q_a.display', compact('suggestions','totalMarks'));

   }


   /**
    * Display the specified resource.
    *
    * @param  \App\QuestionAnswer $questionAnswer
    * @return \Illuminate\Http\Response
    */
   public function show(QuestionAnswer $questionAnswer)
   {
       //
   }

   /**
    * Show the form for editing the specified resource.
    *
    * @param  \App\QuestionAnswer $questionAnswer
    * @return \Illuminate\Http\Response
    */
   public function edit(QuestionAnswer $questionAnswer)
   {

   }

   /**
    * Update the specified resource in storage.
    *
    * @param  \Illuminate\Http\Request $request
    * @param  \App\QuestionAnswer $questionAnswer
    * @return \Illuminate\Http\Response
    */
   public function update(Request $request, QuestionAnswer $questionAnswer)
   {
       //
   }

   /**
    * Remove the specified resource from storage.
    *
    * @param  \App\QuestionAnswer $questionAnswer
    * @return \Illuminate\Http\Response
    */
   public function destroy(QuestionAnswer $questionAnswer)
   {
       //
   }


   /**
    * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
    */
   public function score()
   {
       $user_id = Auth::user()->id;
//      $totalMarks= QuestionAnswer::where('user_id',$user_id);
       $totalMarks= QuestionAnswer::where('user_id',$user_id)->get();
//        $totalMarks = QuestionAnswer::all();
       $timestamps = QuestionAnswer::all();
//

       return view('student.q_a.score', compact('totalMarks', 'timestamps'));
   }


   public function list()
   {

       $user_name = QuestionAnswer::all();

       return view('admin.studentList.list', compact('user_name', 'totalMarks'));

   }

}

this is the database in questionAnswer https://imgur.com/a/YXHMyQH

how can i retrieve user name through the user id?

aishahyaacob left a reply on Same Page

@SERGIU17 - its okay. i had solve it. thank you

aishahyaacob started a new conversation Same Page

why when i successful login, it will display the login page again. here are my image when i had login https://imgur.com/a/fYM74Bi

can somebody help me?

25 Apr
4 months ago

aishahyaacob left a reply on How Can I Get Data From Database?

@BRAUNSON - yes. i want to display the totalmark in my suggestion view

20 Apr
5 months ago

aishahyaacob left a reply on Add Image As Background

@SAFEMOOD - i already put the image and run the command but still does not working https://imgur.com/a/YtgbUkR

aishahyaacob left a reply on Add Image As Background

@SUCCESSDAV - i saved the image in sms folder

aishahyaacob left a reply on Add Image As Background

@SUCCESSDAV - what is mean by cannot resolve file for image. https://imgur.com/a/YIoxiGJ

aishahyaacob left a reply on Add Image As Background

@ANDREA95 - why it still doesn't work?

aishahyaacob started a new conversation How Can I Get Data From Database?

i want to display also totalmarks in suggestion view, my plan is this view display the totalmarks also with the suggestion. here is my display.blade. this is my display view. https://imgur.com/a/yU7wszR

@extends('layouts.app')

@section('content')
    <div class="col-sm-9">
        <h1>Suggestion</h1>

        
        <p>There are some suggestion for you to reduce your stress:</p>

        {{--{!! Form::open(['method' => 'POST', 'action'=> '[email protected]']) !!}--}}


        <div class="container-fluid" id="dynamic_field">
            {{--store data form in array for multiple question--}}

            <table class="table table-bordered" id="dynamic_field">
                <tr>
                    <th>Suggestion</th>
                    <th>Level of Stress</th>

                @if($suggestions)
                    @foreach($suggestions as $suggestion)
                        <tr>
                            <td>{{$suggestion->suggestion}}</td>
                            <td>{{$suggestion->category}}</td>
                        </tr>
                    @endforeach
                @endif

            </table>
        </div>

        <br/>
    </div>

@endsection


here is my controller

<?php

namespace App\Http\Controllers;

use App\Question;
use App\Answer;
use App\QuestionAnswer;
use App\Suggestion;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Route;


class QuestionAnswerController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {

        $questions = Question::all();
        $answers = Answer::all();

        return view('student.q_a.index', compact('questions', 'answers'));

    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {


    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $user_id = Auth::user()->id;
        $totalMarks = 0;


        // $key = question number
        // $value = score/scale
        $answer = $request->input('answer');

        foreach ($answer as $key => $value) {
            $totalMarks += $value;
        }

        $questionAnswer = [
            'user_id' => $user_id,
            'totalMark' => $totalMarks / 40 //store in database
        ];

        QuestionAnswer::create($questionAnswer);

        $marks = $questionAnswer['totalMark'];

        if($marks < 1.00){
            return 'No Suggestion';
        }
        else if($marks>=1.00 && $marks <=2.33){
            $suggestions = Suggestion::where('category','Low')->get();
        }
        else if ($marks>=2.34 && $marks <=3.67){
            $suggestions = Suggestion::where('category','Moderate')->get();
        }
        else if ($marks>=3.68 && $marks<=5){
            $suggestions = Suggestion::where('category','High')->get();
        }

//        return $marks;
        return view('student.q_a.display', compact('suggestions','totalMarks'));

    }


    /**
     * Display the specified resource.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function show(QuestionAnswer $questionAnswer)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function edit(QuestionAnswer $questionAnswer)
    {

    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, QuestionAnswer $questionAnswer)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function destroy(QuestionAnswer $questionAnswer)
    {
        //
    }


    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function score()
    {
        $user_id = Auth::user()->id;
//      $totalMarks= QuestionAnswer::where('user_id',$user_id);
        $totalMarks= QuestionAnswer::where('user_id',$user_id)->get();
//        $totalMarks = QuestionAnswer::all();
        $timestamps = QuestionAnswer::all();
//

        return view('student.q_a.score', compact('totalMarks', 'timestamps'));
    }



}

aishahyaacob left a reply on How To Apply Auth?

@ASHRAAM - thank you very much. now its work like i want.

aishahyaacob started a new conversation How To Apply Auth?

how can i display the score based on the user id? now, i had problem when user 2 login for the first time, basically it must only show one score. but right now it also display score of user 1. below are my code in score.blade

@extends('layouts.app')

@section('content')


    <div class="col-sm-9">
        <h1 style="text-align:center;">Result</h1>
        {{--<p>Your score (average) of stress level shown below:</p>--}}
        <p>Guideline:</p>
        <p>1.00 - 2.33 (Low)</p>
        <p>2.34 - 3.67 (Moderate)</p>
        <p>3.68 - 5.00 (High)</p>

        {{--{!! Form::open(['method' => 'POST', 'action'=> '[email protected]']) !!}--}}

        <div class="container">
        <table class="table table-striped table-bordered">
            <tr>
                <th>Total Mark</th>
                <th>Date</th>
            </tr>
            </thead>

            <tbody>
            {{[email protected](Auth::user()->user_id)--}}

                @if($totalMarks)
                @foreach($totalMarks as $totalMark)
                    <tr>
                        <td>{{$totalMark->totalMark}}</td>
                        <td>{{$totalMark->created_at}}</td>
                    </tr>
                @endforeach
                    @endif
                    {{[email protected]}}

            </tbody>
        </table>
    </div>
    </div>

@endsection


here is my controller

<?php

namespace App\Http\Controllers;

use App\Question;
use App\Answer;
use App\QuestionAnswer;
use App\Suggestion;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Route;


class QuestionAnswerController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {

        $questions = Question::all();
        $answers = Answer::all();

        return view('student.q_a.index', compact('questions', 'answers'));

    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {


    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $user_id = Auth::user()->id;
        $totalMarks = 0;


        // $key = question number
        // $value = score/scale
        $answer = $request->input('answer');

        foreach ($answer as $key => $value) {
            $totalMarks += $value;
        }

        $questionAnswer = [
            'user_id' => $user_id,
            'totalMark' => $totalMarks / 40 //store in database
        ];

        QuestionAnswer::create($questionAnswer);

        $marks = $questionAnswer['totalMark'];

        if($marks < 1.00){
            return 'No Suggestion';
        }
        else if($marks>=1.00 && $marks <=2.33){
            $suggestions = Suggestion::where('category','Low')->get();
        }
        else if ($marks>=2.34 && $marks <=3.67){
            $suggestions = Suggestion::where('category','Moderate')->get();
        }
        else if ($marks>=3.68 && $marks<=5){
            $suggestions = Suggestion::where('category','High')->get();
        }

//        return $marks;
        return view('student.q_a.display', compact('suggestions','totalMarks'));

    }


    /**
     * Display the specified resource.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function show(QuestionAnswer $questionAnswer)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function edit(QuestionAnswer $questionAnswer)
    {

    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, QuestionAnswer $questionAnswer)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\QuestionAnswer $questionAnswer
     * @return \Illuminate\Http\Response
     */
    public function destroy(QuestionAnswer $questionAnswer)
    {
        //
    }


    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function score()
    {
        $user_id = Auth::user()->id;
        $totalMarks= QuestionAnswer::where('user_id',$user_id);
        $totalMarks = QuestionAnswer::all();
        $timestamps = QuestionAnswer::all();
//

        return view('student.q_a.score', compact('totalMarks', 'timestamps'));
    }



}

18 Apr
5 months ago

aishahyaacob left a reply on Read All Data

@JLRDW - ok thank you

aishahyaacob left a reply on Read All Data

@JLRDW - can you show to me, how i need to use it?

aishahyaacob left a reply on Add Image As Background

@VANDAN - where should i save the image?

aishahyaacob started a new conversation Read All Data

how can i display the score based on the user id? now, i had problem when user 2 login for the first time, basically it must only show one score. but right now it also display score of user 1. below are my code in score.blade

@extends('layouts.app')

@section('content')


   <div class="col-sm-9">
       <h1 style="text-align:center;">Result</h1>
       {{--<p>Your score (average) of stress level shown below:</p>--}}
       <p>Guideline:</p>
       <p>1.00 - 2.33 (Low)</p>
       <p>2.34 - 3.67 (Moderate)</p>
       <p>3.68 - 5.00 (High)</p>

       {{--{!! Form::open(['method' => 'POST', 'action'=> '[email protected]']) !!}--}}
       <div class="container">
       <table class="table table-striped table-bordered">
           {{--<thead class="thead-dark">--}}
           <tr>
               <th>Total Mark</th>
               <th>Date</th>
           </tr>
           </thead>

           <tbody>

           @if($totalMarks)
               @foreach($totalMarks as $totalMark)
                   <tr>
                       <td>{{$totalMark->totalMark}}</td>
                       <td>{{$totalMark->created_at}}</td>
                   </tr>
               @endforeach
           @endif

           </tbody>
       </table>
   </div>

@endsection


here are my controller

<?php

namespace App\Http\Controllers;

use App\Question;
use App\Answer;
use App\QuestionAnswer;
use App\Suggestion;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Route;


class QuestionAnswerController extends Controller
{
   /**
    * Display a listing of the resource.
    *
    * @return \Illuminate\Http\Response
    */
   public function index()
   {

       $questions = Question::all();
       $answers = Answer::all();

       return view('student.q_a.index', compact('questions', 'answers'));

   }

   /**
    * Show the form for creating a new resource.
    *
    * @return \Illuminate\Http\Response
    */
   public function create()
   {


   }

   /**
    * Store a newly created resource in storage.
    *
    * @param  \Illuminate\Http\Request $request
    * @return \Illuminate\Http\Response
    */
   public function store(Request $request)
   {
       $user_id = Auth::user()->id;
       $totalMarks = 0;


       // $key = question number
       // $value = score/scale
       $answer = $request->input('answer');

       foreach ($answer as $key => $value) {
           $totalMarks += $value;
       }

       $questionAnswer = [
           'user_id' => $user_id,
           'totalMark' => $totalMarks / 40 //store in database
       ];

       QuestionAnswer::create($questionAnswer);

       $marks = $questionAnswer['totalMark'];

       if($marks < 1.00){
           return 'No Suggestion';
       }
       else if($marks>=1.00 && $marks <=2.33){
           $suggestions = Suggestion::where('category','Low')->get();
       }
       else if ($marks>=2.34 && $marks <=3.67){
           $suggestions = Suggestion::where('category','Moderate')->get();
       }
       else if ($marks>=3.68 && $marks<=5){
           $suggestions = Suggestion::where('category','High')->get();
       }

//        return $marks;
       return view('student.q_a.display', compact('suggestions','totalMarks'));

   }


   /**
    * Display the specified resource.
    *
    * @param  \App\QuestionAnswer $questionAnswer
    * @return \Illuminate\Http\Response
    */
   public function show(QuestionAnswer $questionAnswer)
   {
       //
   }

   /**
    * Show the form for editing the specified resource.
    *
    * @param  \App\QuestionAnswer $questionAnswer
    * @return \Illuminate\Http\Response
    */
   public function edit(QuestionAnswer $questionAnswer)
   {

   }

   /**
    * Update the specified resource in storage.
    *
    * @param  \Illuminate\Http\Request $request
    * @param  \App\QuestionAnswer $questionAnswer
    * @return \Illuminate\Http\Response
    */
   public function update(Request $request, QuestionAnswer $questionAnswer)
   {
       //
   }

   /**
    * Remove the specified resource from storage.
    *
    * @param  \App\QuestionAnswer $questionAnswer
    * @return \Illuminate\Http\Response
    */
   public function destroy(QuestionAnswer $questionAnswer)
   {
       //
   }


   /**
    * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
    */
   public function score()
   {
//
       $totalMarks = QuestionAnswer::all();
       $timestamps = QuestionAnswer::all();
//

       return view('student.q_a.score', compact('totalMarks', 'timestamps'));
   }



}

17 Apr
5 months ago

aishahyaacob started a new conversation Add Image As Background

how can i add image as a background? below is the code

<!doctype html>
<html lang="{{ app()->getLocale() }}">
   <head>
       <meta charset="utf-8">
       <meta http-equiv="X-UA-Compatible" content="IE=edge">
       <meta name="viewport" content="width=device-width, initial-scale=1">

       <title>Laravel</title>

       <!-- Fonts -->
       <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">

       <!-- Styles -->
       <style>
           html, body {
               background-image: url("/sms/image.jpg");
               background-color: #87CEEB;
               color: #636b6f;
               /*font-family: 'Raleway', sans-serif;*/
               font-weight: 100;
               height: 100vh;
               margin: 0;
           }

           .full-height {
               height: 100vh;
           }

           .flex-center {
               align-items: center;
               display: flex;
               justify-content: center;
           }

           .position-ref {
               position: relative;
           }

           .top-right {
               position: absolute;
               right: 10px;
               top: 18px;
           }

           .content {
               text-align: center;
           }

           .title {
               font-size: 60px;
           }

           .links > a {
               color: #636b6f;
               padding: 0 25px;
               font-size: 12px;
               font-weight: 600;
               letter-spacing: .1rem;
               text-decoration: none;
               text-transform: uppercase;
           }

           .m-b-md {
               margin-bottom: 30px;
           }
       </style>
   </head>
   <body>
       <div class="flex-center position-ref full-height">
           @if (Route::has('login'))
               <div class="top-right links">
                   @auth
                       <a href="{{ url('/home') }}">Home</a>
                   @else
                       <a href="{{ route('login') }}">Login</a>
                       <a href="{{ route('register') }}">Register</a>
                   @endauth
               </div>
           @endif

           <div class="content">
               <div class="title m-b-md">
                  WEB BASED STRESS MANAGEMENT SYSTEM USING STUDENT ACADEMIC STRESS SCALE (SASS)
               </div>

               <div class="links">
                   <a href="https://laravel.com/docs"></a>
                   <a href="https://laracasts.com"></a>
                   <a href="https://laravel-news.com"></a>
                   <a href="https://forge.laravel.com"></a>
                   <a href="https://github.com/laravel/laravel"></a>
               </div>
           </div>
       </div>
   </body>
</html>



14 Apr
5 months ago

aishahyaacob left a reply on Bootstrap

@BOBBYBOUWMANN - its working, thank you very much.

aishahyaacob left a reply on Bootstrap

@BOBBYBOUWMANN - this is my full coding

<nav class="navbar navbar-default navbar-static-top">
    <div class="container">
        <a class="navbar-brand" href="{{ url('/') }}">
            {{ config('dev.name', 'SMS') }}
        </a>
        {{--<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">--}}
        {{--<span class="navbar-toggler-icon"></span>--}}
        {{--</button>--}}

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <!-- Left Side Of Navbar -->
            @if(Auth::user())

                @if(Auth::user()->isAdmin() == "Admin")
                    <ul class="nav navbar-nav navbar-left ">
                        <li class="nav-item dropdown">
                            <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
                                Question <span class="caret"></span>
                            </a>
                            <div class="dropdown-menu dropdown-menu-right " aria-labelledby="navbarDropdown">
                                <a class="dropdown-item" href="{{route('question.index')}}">
                                    List of Question
                                </a> <br/>
                                <a class="dropdown-item" href="{{route('question.create')}}">
                                    Create Question
                                </a>
                            </div>
                        </li>
                        <li class="nav-item dropdown">
                            <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
                                Suggestion <span class="caret"></span>
                            </a>
                            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                                <a class="dropdown-item" href="{{route('suggestion.index')}}">
                                    List of Suggestion
                                </a> <br/>
                                <a class="dropdown-item" href="{{route('suggestion.create')}}">
                                    Create Suggestion
                                </a> <br/>
                            </div>
                        </li>
                        {{--<li class="nav-item">--}}
                            {{--<a class="nav-link" href="{{route('staff.admin.report')}}">Report</a>--}}
                        {{--</li>--}}
                        {{--untuk admin buat ap2 yg kluar terus--}}


                    </ul>

                @elseif(Auth::user()->isStudent() == "student")
                    <ul class="nav navbar-nav navbar-left ">
                        <li class="nav-item">
                            <a class="nav-link" href="{{route('student.q_a.index')}}">Answering Questionnaire</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{route('student.q_a.score')}}">History of Score</a>
                        </li>
                    </ul>
            @endif

        @endif

        <!-- Right Side Of Navbar -->
            <ul class="nav navbar-nav navbar-right">
                <!-- Authentication Links -->
                @guest
                    <li class="nav-item">
                        <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
                    </li>
                    @if (Route::has('register'))
                    <li class="nav-item">
                    <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
                    </li>
                    @endif
                @else
                    <li class="nav-item dropdown">
                        <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
                            {{ Auth::user()->name }} <span class="caret"></span>
                        </a>

                        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                            <a class="dropdown-item" href="{{ route('logout') }}"
                               onclick="event.preventDefault();
                                                     document.getElementById('logout-form').submit();">
                                {{ __('Logout') }}
                            </a>

                            <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                {{ csrf_field() }}
                            </form>
                        </div>
                    </li>
                @endguest
            </ul>
        </div>
    </div>
</nav>

aishahyaacob left a reply on SQLSTATE

@NAKOV - yes because of your answer , i able to solve my problem.

13 Apr
5 months ago

aishahyaacob left a reply on Bootstrap

@BOBBYBOUWMANN - not as i expected

aishahyaacob left a reply on SQLSTATE

@NAKOV - thank you. now i'm able to solve the problem.

aishahyaacob started a new conversation SQLSTATE

i want to create new suggestion, but it show the error below https://imgur.com/a/MoBXpgX

database for suggestion shown below https://imgur.com/a/B31h2U8

this is my create.blade

@extends('layouts.app')

@section('content')
    <div class="col-sm-9">
        <h1>Create Suggestion</h1>

        {!! Form::open(['method' => 'POST', 'action' => ['[email protected]']]) !!}


        <div class="container-fluid" id="dynamic_field">
            {{--store data form in array for multiple suggestion--}}

            <table class="table table-bordered" id="dynamic_field">
                <tr>
                    <td>
                        {!! Form::textarea('suggestion', null , ['class' => 'form-control', 'placeholder' => 'Suggestion']) !!}

                    </td>
                    <td>
                        {!! Form::text('category', null , ['class' => 'form-control', 'placeholder' => 'Category']) !!}
                    </td>
                </tr>
            </table>
        </div>

        <br/>
        {{--{!! Form::submit('Create Suggestion', ['class'=>'btn btn-primary btn-lg col-sm-12']) !!}--}}
        <button type="submit" class="btn btn-danger" onclick="return confirm('Successful creating !')">Create Suggestion</button>
        {!! Form::close() !!}

    </div>

@endsection


this is my controller

<?php

namespace App\Http\Controllers;

use App\Suggestion;
use Illuminate\Http\Request;

class SuggestionController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $suggestions = Suggestion::all();


        return view('admin.suggestion.index',compact('suggestions'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.suggestion.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
//        return $request->all();

//        $suggestions = $request->input('suggestion');

        $suggestion = [
            'suggestion', 'category' => $request->input('suggestion','category')
        ];

        Suggestion::create($suggestion);

        return redirect()->back();
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Suggestion  $suggestion
     * @return \Illuminate\Http\Response
     */
    public function show(Suggestion $suggestion)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Suggestion  $suggestion
     * @return \Illuminate\Http\Response
     */
    public function edit(Suggestion $suggestion)
    {
        $id=$suggestion->id;
        $suggestion=Suggestion::findOrFail($id);
        return view('admin.suggestion.edit', compact('suggestion'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Suggestion  $suggestion
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $suggestion= Suggestion::findOrFail($id);
        $suggestions=$request->input('suggestion');
        $suggestion->update(['suggestion'=>$suggestions]);

        return redirect()->back();
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Suggestion  $suggestion
     * @return \Illuminate\Http\Response
     */
    public function destroy(Suggestion $suggestion)
    {
        $id=$suggestion->id;
        Suggestion::findOrFail($id)->delete();
        return redirect('/suggestion');
    }
}


aishahyaacob left a reply on Bootstrap

@BOBBYBOUWMANN - i try. thank you for your answers.

aishahyaacob left a reply on Bootstrap

@BOBBYBOUWMANN - this is my json.file view https://imgur.com/a/Ezzj0tt

aishahyaacob left a reply on Bootstrap

@BOBBYBOUWMANN - what about npm? do i need to create a new project?

aishahyaacob left a reply on Bootstrap

@BOBBYBOUWMANN - i am using laravel 5.4, which one is better for me to use? 3 or 4?

aishahyaacob started a new conversation Bootstrap

how to change the dropdown menu by apply bootsrap. i show the dropdown menu below. i wan to change it to be more attractive https://imgur.com/a/W9EJjKH

11 Apr
5 months ago
10 Apr
5 months ago

aishahyaacob left a reply on Trying To Get A Property 'name' Of Non-object

@SABONZY - one user can have one role only.

aishahyaacob started a new conversation Trying To Get A Property 'name' Of Non-object

i try to register,error occur but it sill connect to database

the error https://imgur.com/a/uYCz4jG

this is my user.php

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Http\Controllers\Auth;
//use Illuminate\Support\Facades\Auth;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'role_id'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function isAdmin() {

        if($this->role->name == 'Admin'){

            return true;
        }
        return false;
    }

    public function isStudent() {

        if($this->role->name == 'Student'){

            return true;
        }
        return false;
    }

    public function role() {
        return $this-> belongsTo ('App\Role');
    } 

    public function questionAnswer()
    {
        return $this->hasMany('App\QuestionAnswer');
    }

    // Check if current user is admin
//    public function isAdmin(){
//        if(Auth::user()->role_id==1){
//            return true;
//        }
//
//        return false;
//    }
}

09 Apr
5 months ago

aishahyaacob left a reply on Error : No Message

@SERGIU17 - ``` Auth::routes();

Route::get('/home', '[email protected]')->name('home');

Route::get('/admin/user/roles', ['middleware'=>'role', function(){ return"Middleware role"; }]);

Route::resource('/QuestionAnswer', 'QuestionAnswerController');

Route::resource('/question', 'QuestionController');

Route::resource('/QuestionAnswer', 'QuestionAnswerController');

Route::resource('/suggestion', 'SuggestionController');

Route::resource('/answer', 'AnswerController');

Route::resource('/QuestionAnswer', 'QuestionAnswerController');

Route::get('/q_a/score', '[email protected]')->name('student.q_a.score');

Route ::post('/q_a/display', '[email protected]')->name('student.q_a.display');