Mystic

Mystic

Member Since 4 Months Ago

Experience Points
570
Total
Experience

4,430 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 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 1
570 XP
Oct
09
1 month ago
Activity icon

Replied to How To Use React On Laravel 8

I have just done that and i didnt get any error but the issue i have now is where do i write the code for react components...

Activity icon

Replied to How To Use React On Laravel 8

i checked the documentation and i saw dis "Mix can automatically install the Babel plug-ins necessary for React support. To get started, replace your mix.js() call with mix.react():" but i feel if i do that it could throw some exceptions

Activity icon

Started a new Conversation How To Use React On Laravel 8

please i need help on how to use react js on laravel 8. I have checked the documentation but i dnt seem to understand it.

Oct
05
1 month ago
Activity icon

Started a new Conversation Redirecting Users

I am using laravel 8 and i want to redirect users based on their login details....where can i write this logic in laravel 8 as there is no auth controller folder where i can write the logic...

Activity icon

Started a new Conversation Route [dashboard] Not Defined

I am using laravel 8 and i am using jetstream for authentication ... but when users login it doesnt really show what i am expecting as it only shows the text dashboard on the the page.... when a user logs in....here are the codes

class RouteServiceProvider extends ServiceProvider
{

public const HOME = '/dashboard';

 public function boot()
    {
        $this->configureRateLimiting();

        $this->routes(function () {
            Route::prefix('api')
                ->middleware('api')
                ->namespace($this->namespace)
                ->group(base_path('routes/api.php'));

            Route::middleware('web')
                ->namespace($this->namespace)
                ->group(base_path('routes/web.php'));
        });
    }

    /**
     * Configure the rate limiters for the application.
     *
     * @return void
     */
    protected function configureRateLimiting()
    {
        RateLimiter::for('api', function (Request $request) {
            return Limit::perMinute(60);
        });
    }
}

login.blade.php

x-guest-layout>
    <x-jet-authentication-card>
        <x-slot name="logo">
            <x-jet-authentication-card-logo />
        </x-slot>

        <x-jet-validation-errors class="mb-4" />

        @if (session('status'))
            <div class="mb-4 font-medium text-sm text-green-600">
                {{ session('status') }}
            </div>
        @endif

        <form method="POST" action="{{ route('login') }}">
            @csrf

            <div>
                <x-jet-label value="{{ __('Email') }}" />
                <x-jet-input class="block mt-1 w-full" type="email" name="email" :value="old('email')" required autofocus />
            </div>

            <div class="mt-4">
                <x-jet-label value="{{ __('Password') }}" />
                <x-jet-input class="block mt-1 w-full" type="password" name="password" required autocomplete="current-password" />
            </div>

            <div class="block mt-4">
                <label class="flex items-center">
                    <input type="checkbox" class="form-checkbox" name="remember">
                    <span class="ml-2 text-sm text-gray-600">{{ __('Remember me') }}</span>
                </label>
            </div>

            <div class="flex items-center justify-end mt-4">
                @if (Route::has('password.request'))
                    <a class="underline text-sm text-gray-600 hover:text-gray-900" href="{{ route('password.request') }}">
                        {{ __('Forgot your password?') }}
                    </a>
                @endif

                <x-jet-button class="ml-4">
                    {{ __('Login') }}
                </x-jet-button>
            </div>
        </form>
    </x-jet-authentication-card>
</x-guest-layout>

web.php

Route::middleware(['auth:sanctum','verified'])->get('/dashboard',function (){
    return view('dashboard')->name('dashboard');
});
Oct
04
1 month ago
Activity icon

Replied to What Is Public Function Boot

Version 8

Activity icon

Replied to What Is Public Function Boot

The reason for the question is because I am trying to redirect users on my website depending on their role on the website....maybe as an admin or an ordinary user.....so I am trying to figure out what part of my code I need to redirect the users to their respective dashboard

Activity icon

Replied to What Is Public Function Boot

Is this the lifecycle the same for every laravel application

Activity icon

Replied to What Is Public Function Boot

I need to find out the meaning of providers as I am completely new to this

Activity icon

Started a new Conversation What Is Public Function Boot

Please can anyone tell me the function of the public function boot found in appservice container.....

Aug
17
3 months ago
Activity icon

Replied to How To Fetch Data Through Relationships Between Models Using Api

Thank you very much for ur sincere response i really appreciate it.

Activity icon

Replied to How To Fetch Data Through Relationships Between Models Using Api

Thanks so much it helped me in solving the problem...pls i don't know if dis is against the community guideline... i need someone to mentor me in mastering laravel i am a beginner ....I would really love if u can be my mentor

Activity icon

Replied to How To Fetch Data Through Relationships Between Models Using Api

Ok here are the codes for the relationship between my user model and mathematics model

User Model

class User extends Authenticatable
{
 
public function mathematics(){
        return $this->hasMany('App\Mathematics');
    }
}

MathematicsController model

use App\User;

use Illuminate\Http\Request;

use App\Mathematics;
class MathematicsController extends Controller
{

 public function teachersUploads($id){
        $maths = User::find($id)->maths;
        return MathResource::collection($maths);
    }

}

Mathematics model

class Mathematics extends Model
{
public function user()
    {
        return $this->belongsTo('App\User');
    }
}

The error I am getting is from this line of code in MathemicsController class

 $maths = User::find($id)->maths;

The error is Call to a member function first() on null in file /opt/lampp/htdocs/schoolApp/vendor/laravel/framework/src/Illuminate/Http/Resources/CollectsResources.php on line 24

This is what d code for my Mathematics database

 public function up()
    {
        Schema::create('mathematics', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedBigInteger('user_id')->nullable();
            $table->string('subject')->nullable();
            $table->string('topic')->nullable();
            $table->index('user_id')->nullable();
            $table->text('content')->nullable();

            $table->timestamps();
        });
    }
Activity icon

Started a new Conversation How To Fetch Data Through Relationships Between Models Using Api

I am creating a mobile app with react native as the front end and using laravel to create API which I can use to connect with my backend. I am trying to fetch data using relationships between the different models in my database but I keep getting the error (Call to a member function get() on null). Pls anyone have any idea on how I can solve this

Aug
05
3 months ago
Activity icon

Replied to Unauthorized Action

I just found out that there is no user_id in my profile model $fillable array and there is user_id in my table column for the profile in d database......anyways I expect dis to throw mass assignment error if it was responsible for d problem .....could dis be the problem

Activity icon

Replied to Unauthorized Action

The policy class


namespace App\Policies;

use App\User;
use App\Profile;
use Illuminate\Auth\Access\HandlesAuthorization;

class ProfilePolicy
{
 public function update(User $user, Profile $profile){
    
        return $user->id === $profile->user_id ;  
}
} 

Also for the Model class it looks like dis

namespace App;

use Illuminate\Database\Eloquent\Model;

class Profile extends Model
{
protected $fillable = ['title','description','image'];
    public function user(){
            return $this->belongsTo(User::class);
        
    }//

    public function profileImage(){
       if($this->image){
           return '/storage/'.$this->image;
       }else{
           return '/storage/profile/DkOHCbAYaHjML0u16H3ulFFIGNeRUp6Vy0yNwJfr.png';
       }
    }


}


Activity icon

Replied to Unauthorized Action

Also I checked the database to see if d profile was created ....and I saw a table for d profile but what baffles me is that the database name does not list out d name of this table unless I click on it ....but it lists out all other tables name as drop down.. and in my view I am also using a value I saved in the profile table when user registers and it shows the value in the view..

Activity icon

Replied to Unauthorized Action

I have dd the data but it seems it never got to call the update method in the policy class as I got no response.... it was still showing the action unauthorized exception

Aug
03
3 months ago
Activity icon

Replied to Unauthorized Action

but i already have a function that creates profile for new registered user

protected static function boot() {

    parent::boot();
    static::created(function($user){
        $user->profile()->create([
            'title'=> $user->username,
        ]);
    });
}
Activity icon

Replied to Unauthorized Action

ok tanks

Activity icon

Replied to Unauthorized Action

ok

Activity icon

Replied to Where Are You All From?

Am from Nigeria

Activity icon

Replied to Unauthorized Action

For my policy dis is it

class ProfilePolicy {

public function update(User $user, Profile $profile) {

    return $user->id === $profile->user_id ;
            
}

}

And myProfileController looks like dis

class ProfileController extends Controller {

public function edit(User $user){

    $user = User::findorfail($user);

    $this->authorize('update',$user->profile);
    

    return view('profile.edit',[
        'user'=>$user
    ]);


}

}

Activity icon

Started a new Conversation Unauthorized Action

I am a beginner with Laravel. I am working on policy, I created different profiles for different users. They can all update their profiles but I realised there was some security breach so I decided to use policy so that only users whose id is equal to their profile user_id can only update their profile. Now each time the register user signs in to their account and try to update their profile they keep getting an unauthorized action exception. Please help me how can I solve this

Jul
30
3 months ago
Activity icon

Replied to Images Not Saving To Path When I Update My Database?

Thanks very much dis worked for me

Jul
28
4 months ago
Activity icon

Replied to Creating Different Views For Users And Admin

Thank you very much

Activity icon

Started a new Conversation Creating Different Views For Users And Admin

Please can anyone help me on how u can create redirect users and admin to different routes when they login