ajithlal

ajithlal

Web developer at Ernakulam

Member Since 1 Year Ago

Experience Points
28,950
Total
Experience

1,050 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
96
Lessons
Completed
Best Reply Awards
26
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 6
28,950 XP
May
22
3 days ago
Activity icon

Awarded Best Reply on Disable Global Scope On Model Show?

I hope you can achieve this using RouteServiceProvider. update your RouteServiceProviders boot method

public function boot()
    {
        parent::boot();

        Route::bind('project', function($id) {
            return \App\Project::withoutGlobalScopes()->findOrFail($id);
        });
    }
Activity icon

Awarded Best Reply on Updating Existing Product

try updating your rule

'slug' => 'required|unique:products,slug,'.$id,

make sure that the value of the $id is not null

Activity icon

Replied to Disable Global Scope On Model Show?

I hope you can achieve this using RouteServiceProvider. update your RouteServiceProviders boot method

public function boot()
    {
        parent::boot();

        Route::bind('project', function($id) {
            return \App\Project::withoutGlobalScopes()->findOrFail($id);
        });
    }
Activity icon

Replied to Session::get Blank

@snapey In one of my project I used muti-auth by https://bitfumes.github.io/laravel-multiauth/ package. On that package, we need to specify the guard name to get the authenticated user. when I tried auth()->user()->name it returned an undefined error. After that project, I started using role-based authentication.

Activity icon

Replied to Disable Global Scope On Model Show?

From the documentation

Removing Global Scopes If you would like to remove a global scope for a given query, you may use the withoutGlobalScope method. The method accepts the class name of the global scope as its only argument:

User::withoutGlobalScope(AgeScope::class)->get();

Or, if you defined the global scope using a Closure:

User::withoutGlobalScope('age')->get();

https://laravel.com/docs/7.x/eloquent#global-scopes

Activity icon

Replied to Add Text In Image

I think your font path is not correct. Please check with that

Activity icon

Replied to Session::get Blank

@snapey, @serlyset have guards to differentiate the user who is logging in. so

{{ auth()->user()->name }}

will not return the name right? He has to use

{{ auth('<guard_name>')->user()->name }}

instead to get the authenticated user's name.

Assuming that he is redirecting all the users to a single action or view. Also using single function to attempt to log in all users. I think that's why he is storing the name on the session.

May
21
4 days ago
Activity icon

Replied to Insert Multiple Data To Database

check your $kelas_id returns an array with selected input.

Activity icon

Replied to Session::get Blank

you mean in your database table? if yes then you can access the name using

auth()->guard('guard_name')->user()->name

and set the value to session.

Activity icon

Replied to Session::get Blank

dd($request->all())

and check $request->name have value

Activity icon

Replied to Updating Existing Product

try updating your rule

'slug' => 'required|unique:products,slug,'.$id,

make sure that the value of the $id is not null

Activity icon

Replied to Email Not Working

from the documentation your mail to function is not correct. It should be

Mail::to($request->user())->send(new OrderShipped($order));

check here https://laravel.com/docs/7.x/mail#sending-mail

May
20
5 days ago
Activity icon

Replied to Seeding Error

Found the issue. I was updating the value of created_by on model' boot() method.

Activity icon

Started a new Conversation Seeding Error

I'm getting Integrity constraint violation: 1048 Column 'created_by' cannot be null while seeding data to table. It works fine when submitting form. here is my factory and seeder. factory.php

$factory->define(AddOn::class, function (Generator $faker) {
    return [
        'name' => [
            'en' => $faker->name,
            'ar' => $faker->name
        ],
        'photo' => $faker->image(public_path('add_ons_images'), 160, 160, 'food', false),
        'price' => $faker->randomNumber(3),
        'created_by' => 1,
        'updated_by' => 1,
    ];
});

seeder.php

public function run()
{
   factory(AddOn::class, 1)->create();
 }
May
11
2 weeks ago
Activity icon

Replied to Continue The Process After Authentication

Thanks, @michaloravec. @jlrdw that worked. I was set the redirectTo property on my controller. that's why it was redirecting to user dashboard after login.

Activity icon

Replied to Continue The Process After Authentication

@michaloravec So How can I implement the same logic there?

Activity icon

Replied to Continue The Process After Authentication

@jlrdw & @michaloravec I've added it like below

/**
    * The user has been authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function authenticated(Request $request, $user)
    {
        return redirect(url()->previous());
    }

but it is not redirecting.

Activity icon

Replied to Continue The Process After Authentication

@jlrdw I tried updating the authenticated() method like below (I don't know you meant this). Nothing happens.

/**
     * The user has been authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function authenticated(Request $request, $user)
    {
        return redirect(url()->previous());
    }

Edit: Before I've edited the wrong function.

Activity icon

Replied to Continue The Process After Authentication

Thanks, @jlrdw . Let me try

Activity icon

Started a new Conversation Continue The Process After Authentication

In my website, a user can see the package. but the user has to register/login to continue the purchase. how can I implement authentication in between this scenario?

I tried setting url()->previous() by overriding the redirectTo() function. Also tried back() instead. But both returning login or register url.

May
07
2 weeks ago
Activity icon

Replied to Which Is The Best Method To Update The Value Of The Fields Created_by And Updated_by

@nolros timestamps are auto-generating there is no problem with that. I want to know about created_by and updated_by fields.

May
06
2 weeks ago
Activity icon

Started a new Conversation Which Is The Best Method To Update The Value Of The Fields Created_by And Updated_by

When I create or update data I'm storing the user ID on DB (created_by and updated_by fields). I found three methods to do this.

  1. Observer.
  2. Overriding the static boot() method.
  3. In the controller itself.

So I'm confused which is the best method to do this?

Activity icon

Replied to Validating Unique Form Exception

@michaloravec Okay. I think then @swimmer can do it like

'email' => 'required|email|unique:users,email,'.auth()->id,
Activity icon

Replied to Validating Unique Form Exception

if you have a FormRequest to validate then

'email' => 'required|email|unique:users,email,'.$this->id,

if you are validating it in your controller, then

'email' => 'required|email|unique:users,email,'.$id,

Assuming that your update() function in your controller is something like update($id,Request $request)

May
05
2 weeks ago
Activity icon

Replied to Database Seeder Array To String Conversion Error

@nakov thanks for the help. @michaloravec it works. thanks

Activity icon

Started a new Conversation Database Seeder Array To String Conversion Error

I'm seeding valid data to my DB using seeder. Below is the code:

<?php

use Illuminate\Database\Seeder;

class HallSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('halls')->insert(
            [
                [
                    'id' => 1,
                    'code' => 'HALL-1001',
                    'name' => [
                        'en' => 'Women\'s Hall',
                        'ar' => 'قاعة المرأة'
                    ],
                    'slug' => 'womens-hall',
                    'description' => 'hall for Women only',
                    'created_by' => 1,
                    'updated_by' => 1,
                ],
                [
                    'id' => 2,
                    'code' => 'HALL-1002',
                    'name' => [
                        'en' => 'Men\'s Hall',
                        'ar' => 'قاعة الرجال',
                    ],
                    'slug' => 'mens-hall',
                    'description' => 'hall for mens only',
                    'created_by' => 1,
                    'updated_by' => 1,
                ],
                [
                    'id' => 3,
                    'code' => 'HALL-1003',
                    'name' => [
                        'en' => 'Men+Women Hall',
                        'ar' => 'صالة رجال ونساء'
                    ],
                    'slug' => 'men-women-hall',
                    'description' => 'hall for both Men+Women',
                    'created_by' => 1,
                    'updated_by' => 1,
                ],
                [
                    'id' => 4,
                    'code' => 'HALL-1004',
                    'name' => [
                        'en' => 'Dinning Hall',
                        'ar' => 'قاعة الطعام'
                    ],
                    'slug' => 'dinning-hall',
                    'description' => 'hall for dinning',
                    'created_by' => 1,
                    'updated_by' => 1,
                ],
            ]
        );
    }
}

While running php artisan db:seed --class=HallSeeder in getting array to string conversion error. I'm using spatie translatable package to use multi language on my website. thats why the name field is array.

Apr
08
1 month ago
Activity icon

Awarded Best Reply on Set Non Expired Session In Laravel 5.7

You can use cookie insted

Mar
20
2 months ago
Activity icon

Replied to Display Model Relationship Data In Blade View

rewrite your code

public function index()
    {
        $users = User::with(['organization', 'profile'])->where('id', 	Auth::user()->id)->get();
        //dd($users);
        return view('home')->with('users', $users);
    }

in view

@if(count($users) > 0)
	@foreach($users as $user)
		<h1>{{ $user->organization->organization_name }}</h1>
		<h1>{{ $user->profile->first_name }}</h1>
		<h1>{{ $user->profile->last_name }}</h1>
	@endforeach
@else
	<h1>No User Found</h1>
@endif

hope this will work

Activity icon

Replied to Migration Error: SQLSTATE[HY000]: General Error: 1215 Cannot Add Foreign Key Constraint

check your migration and confirm container and route_list migration are running before container_logs migration.

Activity icon

Replied to Display Model Relationship Data In Blade View

Can you show us your user model relationships you wrote on your user model for Organization and Profile? A user hasOne organization and one Profile.

with

$users = User::with(['Organization', 'Profile'])->where('id', 	Auth::user()->id)->get();

this line of code I'm assuming that your relationship on your User model is Something like

public function Organization()
{
	$this->hasOne('App\Organization','user_id');
}
public function Profile()
{
	$this->hasOne('App\Profile','user_id');
}

So you have to access it something like:

$user->Organization->organization_name
Mar
18
2 months ago
Activity icon

Replied to Eloquent “with” Returns Null

small update in code

$coursesModel = Course::with(['user', 'reviews:course_id'])->latest()->get();

If this also returns null then try to remove reviews:course_id from with() function and check.

Activity icon

Replied to Eloquent “with” Returns Null

$coursesModel = Course::latest()->with(['user', 'reviews:course_id'])->get();

try this

Mar
17
2 months ago
Activity icon

Replied to My Label Is Blinking While Selecting An Option!

what is the purpose of this class dropdown-language-currency

Mar
13
2 months ago
Activity icon

Replied to Bootstrap Nested Tabs Not Working

make sure that tab navigation works fine by adding some unique text in each tab content and check you are getting value in your inner tab.

Activity icon

Replied to Upgrade Laravel 5.3 To Laravel 7

you are getting the error because of

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

move that closure functionality to some controller and access it. something like:

Route::middleware('auth:api')->get('/user', '[email protected]');
Mar
12
2 months ago
Activity icon

Replied to No Load Script In Blade Template

You didn't added @yield('scripts') in your template file ie dashboard.blade.php

Activity icon

Replied to Bootstrap Nested Tabs Not Working

Tab id should be unique across the tabs. Cross check the ids of the tabs. If the ids are same for nested tabs then make it unique.

Activity icon

Replied to Call To A Member Function Posts() On Null

@henryoladj small update on @tykus code. return $posts instead of null if you want to display post always in the view.

$category=Category::where('url',$category)->first();
$posts = $category ? $category->posts()->latest()->paginate(15) : Post::latest()->paginate(15);
Activity icon

Replied to Laravel 7 View Component

@laran00bie you can nest your components inside deep folders. All the folders should be inside the components folder. Ex. if you want to add Test view components for admin then add your folder inside resources/views/components/admin/Test.php not resources/views/admin/components. and you can access it something like <x-admin.test />.

Read it here: https://laravel.com/docs/7.x/blade#displaying-components

Activity icon

Replied to Upgrade Laravel 5.3 To Laravel 7

in your routes/api.php file there is a default route comment it or remove it and run the command again.

Mar
11
2 months ago
Activity icon

Replied to Call To A Member Function Posts() On Null

You defined $category as null in index() function and you are fetching category with null value and try to access posts that is having category. Check you are passing category value to index function always. And check $category is not empty after fetching the first value when you are passing category to index function. If not empty or null then try to retrieve posts

Activity icon

Replied to Laravel Unique Depends On Other Column

'name' => 'required'.
'branch' => 'required_if:name|unique:school_name,branch'
Mar
10
2 months ago
Activity icon

Replied to How To Limit String Data In View

Are you using laravel 6 or higher. The str_and array_ helpers are moved to new package. Reference https://laravel.com/docs/6.x/upgrade#helpers

Also try to create new thread for your questions.

Activity icon

Replied to Laravel Custom Function In Model Behaves Weird

Then check $ex->key is giving key all the time. Also check the funtion name used in foreach loop

Activity icon

Replied to Laravel Custom Function In Model Behaves Weird

Check the variable key is having value after array_search.

Activity icon

Replied to Using Eloquent To Find Value Of "HasMany" Nested Relationship

Event::with('broadcasts')->whereNotNull('start_at')->whereNull('end_at')->first ()

Hope this will help