ajithlal

ajithlal

Web developer at Ernakulam

Member Since 1 Year Ago

Experience Points
36,510
Total
Experience

3,490 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
125
Lessons
Completed
Best Reply Awards
32
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.

  • community-pillar Created with Sketch.

    Community Pillar

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

Level 8
36,510 XP
Sep
26
2 months ago
Activity icon

Started a new Conversation Livewire Nested Data Binding Not Showing The Value

I have a livewire component for showing profile information. In my form, I'm binding the value to the wire:model as nested data. but it's not showing the value in the textbox. component

<?php

namespace App\Http\Livewire\Profile;

use Livewire\Component;

class BasicInfo extends Component
{
    public $user;

    public function mount()
    {
        $this->user = auth()->user();

    }
    
    public function render()
    {
        return view('livewire.profile.basic-info');
    }
}

blade file

<div class="container">
    <div class="row">
        <div class="col-12">
            <h1>{{ __('Profile Information') }}</h1>
        </div>
        <div class="col-6">
            <form>
                <div class="form-group row">
                    <label for="name" class="form-label">Name</label>
                    <input type="text" wire:model="user.name" class="form-control" disabled>
                </div>

                <div class="form-group row">
                    <label for="phone" class="form-label">Phone</label>
                    <input type="text" wire:model="user.phone" class="form-control" disabled>
                </div>

                <div class="form-group row">
                    <label for="location" class="form-label">Location</label>
                    <input type="text" wire:model="user.location.name" class="form-control" disabled>
                </div>
            </form>
        </div>
    </div>
</div>

when I do dd($user) in the blade file it returning the user object properly.

when I directly assign the value to public property in component and reference it in the blade it is also working.

Sep
21
2 months ago
Activity icon

Replied to Role Based Access Control Using Fortify Or Multiple Authentication System Using Fortify

But even with out of the box auth you can still have 2 endpoints. But it would be using same table.

using the same table.

The above-mentioned method will work for me. But I want to know, is it possible to create two endpoints using fortify. or not?

Sep
19
2 months ago
Activity icon

Replied to Role Based Access Control Using Fortify Or Multiple Authentication System Using Fortify

I think I want to achieve this in another way. I have two users (actually 3. but one is the public user. not part of any authentication) Admin and authenticated user say, author. Author login URL will be website.com/login (provided by jetstream or fortify). Admin login will be website.com/admin/login.

Both users have a different endpoint for login. On earlier versions, we can create these endpoints by copy-pasting the auth provided by laravel. I want to achieve the same using fortify. Is that possible?

Sep
18
2 months ago
Activity icon

Started a new Conversation Role Based Access Control Using Fortify Or Multiple Authentication System Using Fortify

How to add multiple authentications using fortify?. like, if we have admin, registered user and public user, we have to implement different auth for admin and registered user. Jetstream comes with authentication by default. But how to add a different one using fortify?

Sep
04
2 months ago
Activity icon

Awarded Best Reply on LaravelLocalization CurrentLocale Always Returning From Config File When Triggering Event.

the issue was because, Localization will not work because the event is queued. Session and cookie will not work from the queue. So I passed locale as a parameter and now its working.

Activity icon

Replied to LaravelLocalization CurrentLocale Always Returning From Config File When Triggering Event.

the issue was because, Localization will not work because the event is queued. Session and cookie will not work from the queue. So I passed locale as a parameter and now its working.

Activity icon

Started a new Conversation LaravelLocalization CurrentLocale Always Returning From Config File When Triggering Event.

I'm using https://github.com/mcamara/laravel-localization package for localization. URL seems to be working. I have some events that will send emails. I want to set the locale on the mail to send localized mails to the client. I tried setting the locale() method dynamically using LaravelLocalization::getCurrentLocale(). But its returning en that is from the config file.

event file

class NotifyClientBookingCreated implements ShouldQueue
{
    /**
     * Handle the event.
     *
     * @param  ClientBookingCreated  $event
     * @return void
     */
    public function handle(ClientBookingCreated $event)
    {
        Mail::to($event->booking->user->email)
            ->locale(LaravelLocalization::getCurrentLocale())
            ->send(new MailClientBookingCreated($event->booking));
    }
}

I tried triggering the event using URL like

Route::group([
    'prefix' => LaravelLocalization::setLocale(),
    'middleware' => ['localeSessionRedirect', 'localeCookieRedirect', 'localizationRedirect', 'localeViewPath']
], function () {
    Route::get('mailable', function () {
        $booking = Booking::first();
        event(new EventsClientBookingCreated($booking));
    });
});

I'm using queued event

Sep
02
3 months ago
Activity icon

Replied to Missing Required Parameters.

@maaz the error is not from the from. can you show full edit.blade.php file?

Activity icon

Replied to Missing Required Parameters.

where you are calling category.update route?. You have a typo in your form action url.

<form role="form" action="{{route('category.updated',$productCategory->id)}}" method="post">

it should be

<form role="form" action="{{route('category.update',$productCategory->id)}}" method="post">
Aug
24
3 months ago
Activity icon

Replied to Array_map(): Expected Parameter 2 To Be An Array, Int Given

I think the issue is with the assigning the password. Since $data is having an array of values, you can add password to array like below.

$data = $request->validate([
            'nationalCode' => ['required', 'regex:/^[0-9]{10}$/', 'unique:users,nationalCode'],
            'username'     => "required|min:3|max:40|unique:users,username",
            'email'        => ['regex:/[^@][email protected][^\.]+\..+/', "unique:users,email"],
            'mobile'       => ['required','regex:/09(1[0-9]|3[1-9]|2[1-9])-?[0-9]{3}-?[0-9]{4}/',],
            'firstName'    => 'required|min:3|max:40',
            'lastName'     => 'required|min:3|max:40',
            'province'     => 'required',
            'role'         => 2,
            'isActive'     => 1,
        ]);

        // generate password automatically 
        $data['password'] =  bcrypt('password_star');

        User::create($data);

        alert()->success('مدبر مورد نظر با موفقیت ایجاد شد', 'موفقیت آمیز');

        return redirect(route('admin.user.index'));
Aug
22
3 months ago
Activity icon

Awarded Best Reply on Laravel Media Library Error While Adding Media To Database

you should implement HasMedia interface to your model class. check docs here https://docs.spatie.be/laravel-medialibrary/v8/basic-usage/preparing-your-model/

Activity icon

Replied to Undefined Index: Respondent_id

@noblemfd the above error is coming from your unique validation

Activity icon

Replied to Uploading Laravel Project On The Server But It Through An Error

@hadayat if you updated the php version you have to close the currently open terminal and open it again

Activity icon

Replied to Uploading Laravel Project On The Server But It Through An Error

@hadayat try enabling php-intl and php-mbstringextenstions in server

Activity icon

Replied to Vue Js Formdata Append Not Working

What is the result of console.log(formData)?

Activity icon

Replied to Uploading Laravel Project On The Server But It Through An Error

@hadayat If composer install didn't work, try enabling the extensions php-intl, php-mbstring

Activity icon

Replied to Uploading Laravel Project On The Server But It Through An Error

@hadayat Small suggestion, don't put your project file inside the public_html folder. That is because We can easily access our .env file from the URL. you can check your env file like http://yourdomain.com/UOM/.env. That's not good at all. You can move your UOM folder outside the public_html folder and move the files inside the public folder to public_html and update the autoload and bootstrap path in your index.php

Activity icon

Replied to Uploading Laravel Project On The Server But It Through An Error

@hadayat Are you sure you uploaded the vendor folder also? If not then you can run composer install from the terminal provided in your cpanel. On your cpanel you can search for terminal on your cpanel. A prompt will appear for the first time. click understood. Go to your project path and run composer install. If you already have a vendor folder delete it and run the command

Aug
20
3 months ago
Activity icon

Replied to Auth() User() Returns Record Id, Not User Id. Laravel 7

@ajsmith_codes one more doubt. How will you return the data to vue after this?

Activity icon

Replied to Auth() User() Returns Record Id, Not User Id. Laravel 7

@snapey @jlrdw weird doubt. @ajsmith_codes using vue as frontend. So, If @ajsmith_codes using laravel as api then will not get the id by Auth::user()->id right?. Because in one of my thread @snapey helped mee in this. I was using laravel as api and wrote the routes in api.php file. So I'm not able to get the id of auth user in my controller.

Aug
19
3 months ago
Activity icon

Replied to Edit & Create Form

I'm doing it like

{{ old('id', optional($event)->id) }}

this

Aug
18
3 months ago
Activity icon

Replied to Why Do I Get This Problem When I Want To Filter Project

I checked your code on my local environment. It's working after commenting the setlocale middleware. Since I don't have the middleware code. So the issue is not with the Branding link I think.

Aug
11
3 months ago
Activity icon

Replied to How To Remove Class Name On Javascript

what about

document.querySelector('#items').classList.remove('active');
Aug
08
3 months ago
Activity icon

Replied to Undefined Index: User

I think you have to check your notification model relationship with user model.

Activity icon

Replied to Undefined Index: User

@webfuelcode because you are doing echo on user array. If you want to print the name of the user then do {{ $notification->data['thread']['user']['name'] }}. It will return "Rick" in your case

Activity icon

Replied to Undefined Index: User

@webfuelcode what you are getting when dd($notification->data['thread']['user'])?.

Aug
06
3 months ago
Activity icon

Replied to Can't Import Images Using Laravel Excel

@sinnbeck thank you. I implemented it inside my ProductImport class. its works fine.

Activity icon

Replied to Can't Import Images Using Laravel Excel

@sinnbeck I read that one. but I don't know where to implement it. Is it in my Import class? or in controller?

Activity icon

Replied to Can't Import Images Using Laravel Excel

@spjoshis this is the excel file I'm trying to import. https://pasteboard.co/Jl6YdDa.png

Activity icon

Replied to Can't Import Images Using Laravel Excel

@spjoshis on my controller

Excel::import(new ProductImport(), request()->file('import'));

On my product import class

public function model(array $row)
    {
        $product = new Product([
            'category_id' => $row['category'],
            'storename' => storename(),
            'code' => $row['code'],
            'name' => $row['name'],
            'slug' => Str::slug($row['name']),
            'description' => $row['description'],
            'retail_price' => $row['retail_price'],
            'wholesale_price' => $row['wholesale_price'],
            'created_by' => auth()->id(),
        ]);

        return $product;
    }

I tried dd($row) and I'm getting null value on image field.

Activity icon

Replied to File Upload Fails Using Vue.js Laravel

@pazitron change it to your previous code. and try my solution. it will work.

Activity icon

Replied to File Upload Fails Using Vue.js Laravel

@pazitron you are not getting your image as a file. As @marianomoreyra mentioned it is base64 encoded. So you have to extract the image so you can save it. Here is a small piece of code that will extract the image from a base64 file and save it.

 $image = str_replace('data:image/jpeg;base64,', '', $file); //$file is your companyLogo. I'm accepting only jpg,jpeg format images.
 $image = str_replace(' ', '+', $image);

$fileName = sprintf('%s.%s', uniqid(), '.jpeg');
\File::put( 'uploads/' . $fileName, base64_decode($image));

Note: updated the code

Activity icon

Started a new Conversation Can't Import Images Using Laravel Excel

I'm using maatwebsite/excel package to import from excel file. I can't import images using that package. Any solutions. on my controller

Excel::import(new ProductImport(), request()->file('import'));

On my product import class

public function model(array $row)
    {
        $product = new Product([
            'category_id' => $row['category'],
            'storename' => storename(),
            'code' => $row['code'],
            'name' => $row['name'],
            'slug' => Str::slug($row['name']),
            'description' => $row['description'],
            'retail_price' => $row['retail_price'],
            'wholesale_price' => $row['wholesale_price'],
            'created_by' => auth()->id(),
        ]);

        return $product;
    }

I tried dd($row) and I'm getting null value on image field.

This is the excel file I'm trying to import https://pasteboard.co/Jl6YdDa.png

Edited:

Jul
30
4 months ago
Activity icon

Replied to Laravel Validation Custom Field On Where Condition

@michaloravec I was checking the latest documentation. After small modification on your given code, it works fine.

            'code' => ['required', 'string', 'min:1', 'alpha_num','unique:products,code,'.$this->route('product').',id,storename,'.storename()],

Thank you.

Activity icon

Started a new Conversation Laravel Validation Custom Field On Where Condition

I'm trying to validate one field as unique using a custom field.

'code' => ['required', 'string', 'min:1', 'alpha_num','unique:products,code,null,id,storename,'.storename()],

this is my rule. It works on create but it fails on update. If I simply click on the update button it showing the code is already taken.

Jul
24
4 months ago
Activity icon

Replied to 404, Non-objects

@hekmatyar are you sure the $slug returns the value test? if yes then, what is output of the blow code

$offer = Offer::where('slug', $slug)
        ->where('status', 'PUBLISHED')
        ->firstOrFail();
dd($offer);
Jul
23
4 months ago
Activity icon

Replied to Dynamic Carousel Doesn't Work

did you check your console for errors?

Jul
22
4 months ago
Activity icon

Replied to Need A Little Help Here Please

So check the relation and confirm that you added a foreign key to your relationship

Activity icon

Replied to Need A Little Help Here Please

@jeremiah can you show us your cases_user model. Probably you have a relation to cases table and you didn't add the foreign key to your relationship.

Activity icon

Replied to Need A Little Help Here Please

check you have value in your cases_id. Also, check the cases_id field added to fillable array

Jul
21
4 months ago
Activity icon

Replied to Laravel 7 Deploy In Shared Hosting (hostgator) Error

@wahidulalam

I have removed the files under cache folder inside bootstrap folder.

did you run composer dump-autoload after this?

Activity icon

Replied to Laravel 7 Deploy In Shared Hosting (hostgator) Error

check APP_NAME on your .env file. if your app name has spaces wrap it in the double-quotes. Maybe that will be the problem. Also, check your passwords. Wrap them inside double-quotes.

Activity icon

Replied to Problem In Accessing "/" Route With HTTPS

@blackmercury remove the RootRoute from web.php and check