Our Black Friday sale is now live! All individual subscriptions are 50% OFF. This week only!

Dabbash

Dabbash

Member Since 1 Month Ago

Experience Points
6,060
Total
Experience

3,940 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
58
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 2
6,060 XP
Nov
19
4 days ago
Activity icon

Started a new Conversation How To Include Another Function To View ?

Hi everyone,

I build a simple quiz app, and I prepared the route and the controller

this is web.php:

Route::get('/trivia/{slug}', 'Web\[email protected]')->name('trivia-quiz');

This is TriviaQuizController were to view the quiz questions :

class TriviaQuizController extends Controller
{
    public function home(){
        $quizzes = Quiz::where('quiz_type', 'trivia')->latest()->get();
        return view('web.trivia-home', compact('quizzes'));
    }

    public function index($slug)
    {   
        $quiz = Quiz::where('slug', $slug)->first();

        if($quiz){
            $questions = Question::where('quiz_id', $quiz->id)->with('media.children', 'trivia_answers.media.children')->get();
        }else{
            abort(404);
        }
        return view('web.quiz.trivia-quiz', compact('questions', 'quiz'));
    }
}

If I have to include an additional function in the same view that supports to get like "show more quizzes"

How I can do that?

Nov
14
1 week ago
Activity icon

Started a new Conversation What Is Mean 'as' ...., 'uses' ..... In Route ?

Hi,

I found a project well structured in the internet and try to understand how it buid to improve my skills, I want to know what is mean this line in web.php ?

Route::get('profile', ['as' => 'profile.edit', 'uses' => '[email protected]']);
Route::put('profile', ['as' => 'profile.update', 'uses' => '[email protected]']);
Route::put('profile/password', ['as' => 'profile.password', 'uses' => '[email protected]']);

what is mean 'as', 'uses', and is it same as:

Route::get('profile', '[email protected]')->name('profile.edit');
Route::put('profile', '[email protected]')->name('profile.update');
Route::put('profile/password', '[email protected]')->name('profile.password');

Thanks in advance :)

Oct
23
1 month ago
Activity icon

Replied to Property [id] Does Not Exist On This Collection Instance.

Thank you so much, @tykus @sinnbeck, I updated AnswerTable and added 'question_id' in answer function and it works perfectly.

Appreciate your help ^^

Activity icon

Replied to Property [id] Does Not Exist On This Collection Instance.

@tykus & @sinnbeck , thank you for all your response, you will find more details below.

This is all the codes in Answer Model

class Answer extends Model
{
   protected $fillable = [
       'question_id',
       'slug',
       'answer_text',
       'is_correct',
       'background',
       'disc',
   ];

public function sluggable()
{
    return [
        'slug' => [
            'source' => 'answer_text'
        ]
    ];
}

   public function questions(){
       return $this->belongsTo(Questions::class);
   }

}

and here all the code in Questions Model

class Questions extends Model
    {
        protected $fillable = [
        'question_title',
        'slug',
        'quiz_id',
        'background',
        ];

public function sluggable()
{
    return [
        'slug' => [
            'source' => 'question_title'
        ]
    ];
}

public function result(){
    return $this->hasMany(Result::class);
}

public function answers(){
    return $this->hasMany(Answer::class);
}

public function quiz(){
    return $this->belongsTo(Quizzes::class);
}

public function getQuestionById($id){
    return Question::find($id);
}

}

When I view the questions separately in [email protected]()

public function show(Questions $question)

{

    $answers = Answer::where('question_id', $question->id)->get();

    $result = Result::where('question_id', $question->id)->get();

    return view('admin.question.show', compact('question', 'answers', 'result'));
}

it retraive the all the answers without any issues.

But When I want to view all details of the quiz, like questions and answers on the same page it appears the issue

Activity icon

Replied to Property [id] Does Not Exist On This Collection Instance.

This is the code: { class CreateAnswersTable extends Migration { /** * Run the migrations. * * @return void */

public function up()

{

    Schema::create('answers', function (Blueprint $table) {

        $table->bigIncrements('id');

        $table->string('slug');

        $table->integer('question_id');

        $table->string('answer_text');

        $table->string('is_correct');

        $table->string('background');

        $table->string('disc');

        $table->timestamps();

    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::dropIfExists('answers');
}

}

}

Activity icon

Replied to Property [id] Does Not Exist On This Collection Instance.

Thank you @tykus for your quick response, I did what you told me but I got this issue

Illuminate \ Database \ QueryException (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'answers.questions_id' in 'where clause' (SQL: select * from answers where answers.questions_id in (3, 4, 5, 6))

I see that it tries to find questions_id and what I have is question_id, without 's'

Activity icon

Started a new Conversation Property [id] Does Not Exist On This Collection Instance.

Hi everyone,

What I want to achieve is to view all the answers under each question in the quiz,

In web.php:

Route::get('/{slug}', '[email protected]')->name('showQuiz');

In ShowQuiz function:

public function showQuiz($slug)

{

    $quiz = Quizzes::where('slug', $slug)->first();

    $questions = Questions::where('quiz_id', $quiz->id)->get();

    $answers = Answer::where('question_id', $questions->id)->get();

    return view('showQuiz', compact('quiz', 'questions', 'answers'));

}

But it gives me "Property [id] does not exist on this collection instance.", it refer it to -> $answers = Ans...

This is the code in showQuiz.blade.php:

@foreach($questions as $question)

                <p class="font-bold text-xl" style="text-align: right">{{$question->question_title}}</p>

                <img class="mr-2 rounded custom-img" src="{{asset('images/'.$question->background)}}">

            @foreach($answers as $answer)

                <img class="mr-2 rounded custom-img" src="{{asset('images/'.$answer->background)}}">

            @endforeach

    @endforeach
Oct
10
1 month ago
Activity icon

Started a new Conversation How To Achieve /category/{id}/articale/{id}/create ?

Hello all,

I want to do like this, /category/{id}/articale/{id}

When I tried to do it, it work perfectly, but when I want to create, store or updare it doesn't work properly. Can someone give me example or tutorial on how to do it.

Oct
06
1 month ago
Activity icon

Commented on Hello Eloquent

Actually this is the third course I'm joining to understand laravel >.<" I see that Jeffrey used return view('post', ['post' => $post]);

and other course I attended uses something like this return view('post', compact('post'));

and return view('post')->with('post'=>$post);

So, can someone explain for me the difference in easy way.