afoysal

afoysal

Member Since 5 Years Ago

Experience Points
17,250
Total
Experience

2,750 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
17
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 4
17,250 XP
Oct
21
4 days ago
Activity icon

Started a new Conversation Customize DataTable Sorting Label

How to customize DataTable Sorting Label ?

My sorting looks like below.

error

But I need to remove entries like below

error

Activity icon

Started a new Conversation Change Laravel DataTable Text

How can I change Laravel DataTable text ? Like I would like to show below text.

1 -5 of 13

instead of

Showing 1 to 5 of 13 entries
Oct
20
5 days ago
Activity icon

Started a new Conversation How To Fix CSS Of Laravel Generated Pdf File ?

How to fix CSS of Laravel generated pdf file ?

I am working in a PDF file generated by Laravel. How can I see output of fixed CSS in browser ?

Oct
17
1 week ago
Activity icon

Replied to Alpha_num Validation Message Is Not Working

Thanks @silencebringer . How can I check input contains both - numbers and letters ? Thanks.

Activity icon

Started a new Conversation Alpha_num Validation Message Is Not Working

My validation rule is like below

$rules = array( "password"   => 'required|alpha_num|min:6');

I am validating like below

  $validator = Validator::make($request->all(), $rules);

But I am not getting any error while I am putting 12345678 in password field. Other validation message is working fine.

Oct
16
1 week ago
Activity icon

Replied to Form Validation Error

Thank You @tykus. Your assumption is correct. The Name field is converted to parola_d'ordine. Thanks.

Activity icon

Replied to Form Validation Error

Thanks @tykus . Where did you find name ? Thanks.

Activity icon

Started a new Conversation Form Validation Error

My password field code is like below

<div class="form-group">
                    {{ Form::label("parola d'ordine", "parola d'ordine") }}
                    {{ Form::password("parola d'ordine", array('placeholder' => 'Inserire la password','class' => 'form-control')) }}
                    @if($errors->has("parola d'ordine"))
                    <label class="error" for="parola d'ordine">{{ $errors->first("parola d'ordine") }}</label>
                    @endif
                </div>

My Controller Validation code is like below

$rules = array(
        'e-mail'    => 'required|email', 
       "parola d'ordine" => 'required|alphaNum|min:6' 
 );

$customMessages = ['required' => 'Il campo :attribute รจ obbligatorio.'];

$validator = Validator::make($request->all(), $rules,$customMessages);
        
//dd($validator);   // I am getting all values here. 

 if ($validator->fails()) {
            return Redirect::to('login')
                ->withErrors($validator) 
                ->withInput($request->except(["parola d'ordine"])); 
 }

Why I am getting validation error message in blade file ?

error

Oct
15
1 week ago
Activity icon

Started a new Conversation Use Input Class In Laravel Blade File

I am using Laravel 7.28.3. I am trying to use Input class in Blade file like below.

{{ Form::text('email', Input::old('email'), array('placeholder' => '[email protected]')) }}

I used 'Input' => Illuminate\Support\Facades\Input::class, in aliases array in app.php

But I am getting below error.

Class 'Input' not found

I used php artisan config:cache also.

Activity icon

Started a new Conversation Develop Authentication In Laravel 7

I am using Laravel 7.28.3. I am trying to develop Authentication. I tried to run php artisan make:auth. But this command is not eligible for Laravel 7.

What is the alternative command for Laravel 7 ?

How do you develop Authentication in Laravel 7 ?

Oct
14
1 week ago
Activity icon

Replied to Class 'Yajra\DataTables\DataTablesServiceProvider' Not Found

Thanks @sinnbeck . Yes, I uploaded vendor folder also which is yajra folder. Thanks.

Activity icon

Replied to Class 'Yajra\DataTables\DataTablesServiceProvider' Not Found

Thanks @sinnbeck . I run composer install in my local machine. But I can't run any SSH command in my Server. I can upload files to Server through cPanel.

Project is running perfectly in my local machine.

Thanks.

Activity icon

Started a new Conversation Class 'Yajra\DataTables\DataTablesServiceProvider' Not Found

I am working in a Server where I can't run any SSH command.

I worked on my localhost and installed DataTable using composer require yajra/laravel-datatables-oracle:"~9.0". After completion of Development I uploaded some files and portion of files through cPanel.

I placed Yajra\DataTables\DataTablesServiceProvider::class, in Providers array and 'DataTables' => Yajra\DataTables\Facades\DataTables::class, in Alias array.

I uploaded datatables.php file in config folder.

Now I am getting Class 'Yajra\DataTables\DataTablesServiceProvider' not found error when I am trying to run the application.

Activity icon

Started a new Conversation .click() Inside Another .click() In Mobile Menu

I am working on a Mobile Menu. I have a .click() method inside another .click(). How can I show and hide elements when second .click() working ?

My code is like below

    if (window.innerWidth <= 1000) { // For mobile view
        $("#hamburger").click(function () {
            $("#nav_links, #search_bar").slideToggle(1000); //alternate between showing and hiding navbar
            $("#hamburger i").toggleClass('fa-bars').toggleClass('fa-times'); //switching between bars and times

            $('.header-links').toggle();
            $('.links').toggle("slide", { direction: "bottom" }, 1000);

            $('.user-name').click(function () {
    
                // How can I show and hide elements here ?
    
                $('.top_nav').css("height", "470px");
                $('body header .dropdown-container ul.dropdown-menu').css("display", "block");
            });
        });
    }

Here is my HTML code

    <nav class="header-links top_nav">
                <ul id="nav_links" class="links text-center">
                    <li><a href="">Home</a></li>

                    <li><a href="">About Us</a></li>

                    <li><a href="">Membership</a></li>

                    <li><a href="">One Off Support</a></li>

                    <li><a href="">Coverage</a></li>

                    <div class="dropdown-container" component="dropdown">
                        <span class="user-name py-s hide-under-l" refs="[email protected]" aria-haspopup="true"
                            aria-expanded="false" tabindex="0">
                            DIY Guides
                        </span>
                        <ul refs="[email protected]" class="dropdown-menu" role="menu">
                            <li>
                                <a href="{{ url('/') }}"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
                                        viewBox="0 0 24 24">
                                        <path
                                            d="M20 7.093l-3-3v-2.093h3v5.093zm4 5.907h-3v10h-18v-10h-3l12-12 12 12zm-10 2h-4v6h4v-6z" />
                                    </svg>DIY Home</a>
                            </li>
                            <li>
                                <a
                                    href="{{ url('/categories') }}">@icon('bookshelf'){{ trans('entities.categories') }}</a>
                            </li>
                            <li>
                                <a href="{{ url('/guides') }}">@icon('books'){{ trans('entities.guides') }}</a>
                            </li>
                            @if(!signedInUser())
                            <li>
                                <a href="{{ url('/login')  }}">@icon('login'){{ trans('auth.log_in') }}</a>
                            <li>
                                @endif
                        </ul>
                    </div>
          </ul>
    </nav>
Oct
11
2 weeks ago
Activity icon

Replied to Display DataTable With Other Data

Thanks @laracoft for your reply. But may be you didn't get my issue. I searched a lot in Google but didn't get any solution regarding my issue. Actually I would like to send 2 types of data to blade file. One is DataTable and another is without DataTable. I am writing controller function again for you.

public function getProduct($id) {
        $product = Product::where('product_id',$id)->with('product_log')->first();  //If I use DataTable how can I send this $product data

        $data = Product_log_view::where('sku',$product->sku)->get();
        
        return Datatables::of($data)
        ->addIndexColumn()
        ->addColumn('action', function($row){
            $btn = '<a href="javascript:void(0)" class="edit btn btn-success btn-sm">Edit</a> <a href="javascript:void(0)" class="delete btn btn-danger btn-sm">Delete</a>';
            return $btn;
        })
        ->rawColumns(['action'])
        ->make(true);
    }
Oct
10
2 weeks ago
Activity icon

Replied to Display DataTable With Other Data

Hello @laracoft . Are you there ?

Activity icon

Started a new Conversation Convert Result To JSON Object

I have below function in my controller.

public function getProduct($id) {

        $product = Product::where('product_id',$id)->with('product_log')->first();

        $product_log_views = Product_log_view::where('sku',$product->sku)->with('user')->all();

        return view('welcome.product-details', ['product_log_views' => $product_log_views, 'product' => $product, 'active_menu' => 'products']);
    }

I would like to pass JSON object of $product_log_views = Product_log_view::where('sku',$product->sku)->with('user')->all(); to blade file.

How can I do that ?

Activity icon

Replied to Display DataTable With Other Data

Thanks @laracoft for your reply. But may be you didn't get my issue. I searched a lot in Google but didn't get any solution regarding my issue. Actually I would like to send 2 types of data to blade file. One is DataTable and another is without DataTable. I am writing controller function again for you.

public function getProduct($id) {
        $product = Product::where('product_id',$id)->with('product_log')->first();  //If I use DataTable how can I send this $product data

        $data = Product_log_view::where('sku',$product->sku)->get();
        
        return Datatables::of($data)
        ->addIndexColumn()
        ->addColumn('action', function($row){
            $btn = '<a href="javascript:void(0)" class="edit btn btn-success btn-sm">Edit</a> <a href="javascript:void(0)" class="delete btn btn-danger btn-sm">Delete</a>';
            return $btn;
        })
        ->rawColumns(['action'])
        ->make(true);
    }
Activity icon

Replied to Display DataTable With Other Data

Hello @laracoft . Are you there ?

Oct
09
2 weeks ago
Activity icon

Replied to Display DataTable With Other Data

Thanks @laracoft . This is my controller function.

public function getProduct(Request $request,$id) {

        $product = Product::where('product_id',$id)->with('product_log')->first();

        $product_log_views = Product_log_view::where('sku',$product->sku)->paginate(5);

        return view('welcome.product-details', ['product_log_views' => $product_log_views, 'product' => $product, 'active_menu' => 'products']);
    }

I would like to display data of below portion using DataTables in blade file. (https://github.com/yajra/laravel-datatables). How can I do that ?

$product_log_views = Product_log_view::where('sku',$product->sku)->paginate(5);

Thanks.

Oct
08
2 weeks ago
Activity icon

Started a new Conversation Display DataTable With Other Data

I am going to display DataTable. My controller code for DataTable is like below,

$data = Student::latest()->get();
            return Datatables::of($data)
                ->addIndexColumn()
                ->addColumn('action', function($row){
                    $btn = '<a href="javascript:void(0)" class="edit btn btn-success btn-sm">Edit</a> <a href="javascript:void(0)" class="delete btn btn-danger btn-sm">Delete</a>';
                    return $btn;
                })
                ->rawColumns(['action'])
                ->make(true);

But I have to show results of below data also in View file.

$product = Product::where('product_id',$id)->with('product_log')->first();
Oct
05
2 weeks ago
Activity icon

Started a new Conversation Find Highest Value Of A Column

I am trying to find out highest value of a Column. My Query is like below.

class Product extends Model
{
    protected $table = 'Product';

    public function product_log()
    {
        return $this->hasMany('App\Product_log','Product_id','product_id')->max('log_id')->first();
    }
}

But I am getting error like below.

Call to a member function first() on int 
Oct
03
3 weeks ago
Activity icon

Started a new Conversation `access-dashboard` For Guard `api`

I am working in this application. But when I am trying to add companies I am getting below error.

error

Oct
01
3 weeks ago
Activity icon

Replied to Using Voyager

Thanks @bobbybouwmann . I created controller also. but it is not working.

https://i.stack.imgur.com/wqAGx.png

Activity icon

Started a new Conversation Using Voyager

I installed this package. I am trying to create Product BREAD.

error

But I am getting below error when I click on product.

error

Here is my Database settings.

error

Here is my BREAD settings.

error

Sep
29
3 weeks ago
Activity icon

Started a new Conversation URL Issue

My anchor tag is like below

<a href="/category/{{ $category->slug }}/all" class="category_anchor">{{ $category->name }}</a>

Which output is like below

<a href="/category/hair/all" class="category_anchor">Hair</a>

If I click on it I redirect to http://perfectparlour.com/category/hair/all.

But I would like to be redirected to http://perfectparlour.com/glam/public/category/hair/all.

How can I do that ?

Sep
25
1 month ago
Activity icon

Replied to GIT Pushing

Thanks @laracoft . Should I pull before push if there changes on the GitHub repository ? Thanks.

Sep
23
1 month ago
Activity icon

Started a new Conversation Dexie With IndexedDB

I am new in Dexie with indexedDB.

I am trying to develop an application using Vue.js.I need feature like once submit a Form Dexie stores the information in indexedDB, later syncs with MySql database once online.

Can anyone help me in this regard ?

Sep
21
1 month ago
Activity icon

Replied to GIT Pushing

Thanks @laracoft . Should I pull before git push and after commit ?

Activity icon

Started a new Conversation GIT Pushing

How to push code to github after development ?

I cloned a repo from github then I worked on it. I am in Master branch in my local Machine. I have to push in another branch.

Should I pull first then push ?

Activity icon

Replied to Route Placement

Thanks @sergiu17. Why Order of the routes matter ?

Activity icon

Replied to Route Placement

Thanks @automica. Why one route is clashing with another ?

Activity icon

Started a new Conversation Route Placement

If I place below route at the start of the web.php file it is working.

Route::get('login', 'Auth\[email protected]');

But if I place at the end of the web.php file it is not working.

Sep
20
1 month ago
Activity icon

Started a new Conversation Title Settings

I am working in a Vue.js project.

How can I change below settings ?

<title><%= htmlWebpackPlugin.options.title %></title>
Sep
16
1 month ago
Activity icon

Replied to Route From Variable

Thanks @silencebringer. Your solution is working. Thanks.

Activity icon

Started a new Conversation Route From Variable

I have a route like below

<a href="{{route('startRun')}}">

But I would like to use Variable like below

<a href="{{route("start".$last_word)}}">

I am getting error like below

Route [startRun ] not defined.

My route in web.php file is like below

Route::get('/run','[email protected]')->name('startRun');
Sep
09
1 month ago
Activity icon

Started a new Conversation Condition In Route File.

I would like to put condition like below in route file.

                       if(Auth::user()->user_type_id == 2) {
				Route::get('account', '[email protected]');
			}
			else {
				Route::get('companyprofile', '[email protected]_profile');  
			}

But I am getting error like below

Trying to get property 'user_type_id' of non-object
Sep
08
1 month ago
Activity icon

Started a new Conversation Using Old()

I have below code

<option value="{{ old('city',$user->city) }}" selected></option>

How to know old() is empty here ?

Activity icon

Replied to Debug $.ajax() In Laravel 7

Thanks @automica . Here is the output https://i.stack.imgur.com/B0JFC.png. Thanks.

Activity icon

Replied to Debug $.ajax() In Laravel 7

Thanks @automica . I changed my code like below

$('select[id="state"]').on('change', function() {
				var stateID =  $(this).val();
				if(stateID) {
					$.ajax({
						url: '/cities/'+7,
						type: "GET",
						success:function(data) {
							$('select[name="city"]').empty();
							$.each(data, function(key, value) {
								$('select[name="city"]').append('<option value="'+ key +'">'+ value +'</option>');
							});
						},
						error: function(xhr, status, error){
							var errorMessage = xhr.status + ': ' + xhr.statusText
							alert('Error - ' + errorMessage);
						}
					});
				}else{
					$('select[name="city"]').empty();
				}
			});

My route is like below

Route::get('/cities/{id}', '[email protected]');

My controller function is like below

public function getSelectedCityajax($id)
	{
		return response()->json(['success'=>$id]);
	}

But I am getting error Error - 400: Bad Request.

Sep
07
1 month ago
Activity icon

Replied to Debug $.ajax() In Laravel 7

Thanks @automica . Actually I working in a purchased script. You can say I am copy pasting code. I am getting Error - 400: Bad Request from your code. Why it is happening ? Why I am getting this error.

What will be the route if I use url: '/cities?code='+stateID, this URL ?

Thanks.

Activity icon

Started a new Conversation Debug $.ajax() In Laravel 7

My AJAX code is like below

$('select[id="state"]').on('change', function() {
				var stateID =  $(this).val();	
				alert(stateID);	// I am getting value here		
				if(stateID) {
					$.ajax({
						url: '/cities?code='+stateID,
						type: "GET",
						dataType: "json",
						success:function(data) {
							alert('hello');
							$('select[name="city"]').empty();
							$.each(data, function(key, value) {
								$('select[name="city"]').append('<option value="'+ key +'">'+ value +'</option>');
							});
						}
					});
				}else{
					$('select[name="city"]').empty();
				}
			});

My route is like below

Route::get('countries/{countryCode}/cities/{id}', 'Ajax\[email protected]');

My controller function is like below

public function getSelectedCity($countryCode, $cityId)
	{
		// Get the City by its ID
		$cacheId = $countryCode . '.city.with.admins' . $cityId;

		Log::info($cityId);  // Value is not logging here. No log file generate for this.

		$city = Cache::remember($cacheId, $this->cacheExpiration, function () use ($countryCode, $cityId) {
			return City::countryOf($countryCode)->with(['subAdmin1', 'subAdmin2'])->where('id', $cityId)->first();
		});
		
		if (!empty($city)) {
			$text = $city->name;
			if (isset($city->subAdmin2) && !empty($city->subAdmin2)) {
				$text .= ', ' . $city->subAdmin2->name;
			} else {
				if (isset($city->subAdmin1) && !empty($city->subAdmin1)) {
					$text .= ', ' . $city->subAdmin1->name;
				}
			}
			$cityArr = ['id' => $city->id, 'text' => $text];
		} else {
			$cityArr = ['id' => 0, 'text' => t('select_a_city', [], 'global', request()->get('languageCode'))];
		}
		return response()->json($cityArr, 200, [], JSON_UNESCAPED_UNICODE);
	}

I used use Illuminate\Support\Facades\Log; at the start of the controller.

How to debug $.ajax() in Laravel 7 ?

Sep
04
1 month ago
Activity icon

Replied to Gravatar

Thanks @automica . I am not getting any image. But I need this URL http://127.0.0.1:8000/images/user.jpg.

Which mistake am I doing ? Thanks.

Activity icon

Replied to Gravatar

Thanks @automica . Actually I would like to find out where is the issue using my code. It is not returning a gravatar. It is returning what inside alt attribute.

Activity icon

Replied to Gravatar

Thanks @automica . I found below words here (https://en.gravatar.com/site/implement/images/)

If you'd prefer to use your own default image (perhaps your logo, a funny face, whatever), then you can easily do so by supplying the URL to an image in the d= or default= parameter. The URL should be URL-encoded to ensure that it carries across correctly, for example:

<img src="https://www.gravatar.com/avatar/00000000000000000000000000000000?d=https%3A%2F%2Fexample.com%2Fimages%2Favatar.jpg" />

I am getting HTML like below

<img id="userImg" class="userImg" src="https://secure.gravatar.com/avatar/a516098e1de8e2756fa4bf045c7a4cb2.jpg?s=150&amp;d=http%3A%2F%2F127.0.0.1%3A8000%2Fimages%2Fuser.jpg&amp;r=g" alt="user">
Activity icon

Replied to Debug PayPal

Thanks @automica . Yes, I am using Valid Credentials. I am working in a project where other developers worked. I have to follow them. Thanks.

Activity icon

Started a new Conversation Debug PayPal

I am using this composer require paypal/rest-api-sdk-php. I put below code in .env file.

PAYPAL_MODE=sandbox
PAYPAL_SANDBOX_CLIENT_ID=dummyIDfornow
PAYPAL_SANDBOX_SECRET=dummysecretfornow

I put below code in config/paypal.php file

'sandbox_client_id' => env('PAYPAL_SANDBOX_CLIENT_ID', 'dummyIDfornow'),
 'sandbox_secret' => env('PAYPAL_SANDBOX_SECRET', 'dummysecretfornow'),
    

I am getting below error.

You do not have permissions to make this API call

https://i.stack.imgur.com/yp1tc.png

How to debug this situation ?

Activity icon

Started a new Conversation Gravatar

I am using this ( https://github.com/creativeorange) package. My controller code is like below.

$data['gravatar'] = (!empty(auth()->user()->email)) ? Gravatar::fallback(url('images/user.jpg'))->get(auth()->user()->email) : null;

dd($data['gravatar']);

I am getting output like below

"https://secure.gravatar.com/avatar/a516098e1de8e2756fa4bf045c7a4cb2.jpg?s=150&d=http%3A%2F%2F127.0.0.1%3A8000%2Fimages%2Fuser.jpg&r=g"

But I would like to get output like below

http://127.0.0.1:8000/images/user.jpg