afoysal

Member Since 5 Years Ago

Experience Points
17,880
Total
Experience

2,120 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.

  • Community Pillar

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

Level 4
17,880 XP
Jan
10
1 week ago
Activity icon

Started a new Conversation Delete & Update Record

How can I Delete & Update multiple records in Pivot table through REST Api in Laravel ?

Dec
31
2 weeks ago
Activity icon

Started a new Conversation Optional Inclution Of Template

I have a Master layout like below

<body>
    <div id="main-wrapper">
        @include('layouts.header')
        @include('layouts.sidebar')
        <div class="content-body">
            <div class="container">
                @yield('content')
            </div>
        </div>
    </div>
    @include('modal')
    @include('layouts.footer-script')
</body>

In some of my layout I would like to leave @include('layouts.header') & @include('layouts.sidebar').

How can I do that ?

Dec
24
3 weeks ago
Activity icon

Started a new Conversation MySql Import Error

I am getting below error while I am trying to import .sql file in mysql Database.

error

Dec
12
1 month ago
Activity icon

Started a new Conversation How To Fetch This Week's Record

How to fetch this week's record ?

I am using below code.

Carbon::setWeekStartsAt(Carbon::SUNDAY);
        Carbon::setWeekEndsAt(Carbon::SATURDAY);

        $thisweekTotal = Product::whereHas('events', function ($query) {
            $query->whereDate('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()]);
        })->sum('price');
Dec
11
1 month ago
Activity icon

Replied to Sum() In Many To One Relationship

Thanks @michaloravec . I am getting error Call to undefined method App\Product::events() . Thanks.

Activity icon

Started a new Conversation Sum() In Many To One Relationship

I have two tables events and products. One Product has many Events. created_at column is in events table and price column is in products table. My Event model is like below

class Event extends Model
{
    public function products()
    {
        return $this->belongsTo(Product::class,'data_code','data');
    }
}

I would like to fetch sum of price column of today's event. My controller code is like below.

$today_total = Event::whereDate('created_at', Carbon::today())->products->sum('price');

But I am getting error Property [products] does not exist on the Eloquent builder instance. .

Dec
07
1 month ago
Activity icon

Replied to User Create And Update Using UpdateOrCreate()

Thanks @automica . What is the difference between 'email' => 'required|email|unique:users,email,' . $request->user_id, and 'email' => 'required|email|unique:users', ? Thanks.

Dec
06
1 month ago
Activity icon

Started a new Conversation User Create And Update Using UpdateOrCreate()

I am creating and updating user using below code.

    public function store(Request $request)
    {
        if ($request->ajax()) {
            $request->validate([
                'name'      => 'required',
                'email'     => 'required|email|unique:users,email,' .$request->user_id,
                'password'  => 'required',
                'role'      => 'required',
            ]);

            $user = User::updateOrCreate(['id' => $request->user_id],
            [
                'name'      => $request->name,
                'email'     => $request->email,
                'role'      => $request->role,
                'password'  => Hash::make($request->password)
            ]);
        }
    }

When I am updating record Password is updating also. How can I solve the issue ?

How validation is working here 'email' => 'required|email|unique:users,email,' .$request->user_id, when I am creating a record ? Because when I am creating a record at that time $request->user_id is not available.

Dec
01
1 month ago
Activity icon

Started a new Conversation Fetch Single Record Of Many To Many Relationship

I have user table, machine and machine_user table. One User has many machines. I am using blow code in controller to fetch a User record.

public function edit($id)
    {
        $User = User::with('machines')->find($id);
        return response()->json($User);
    }

I would like to fetch User with machine record. But I am getting only machine records no user record with this code.

Nov
26
1 month ago
Activity icon

Started a new Conversation Delete Record In Many To Many Relationship In Laravel

I am working in a Laravel Application. I have 2 tables users and machines with many to many relationship. I am also using a pivot table machine_user.

I need to delete records from pivot table which are related to a specific user when I delete a user.

How can I do that ?

Activity icon

Started a new Conversation DataTable With Many To Many Relationship

I have 2 tables users and machines which have many to many relationship. I am trying to display Users list with machines using DataTable. My code is like below

if ($request->ajax()) {
            $data = User::with('machines')->select('alias')->latest()->get();
            return Datatables::of($data)
                ->addIndexColumn()
                ->addColumn('action', function($row){
                    $btnAdd = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="edit btn btn-primary btn-sm editMachine">Editar</a> ';
                    $btnDel = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="btn btn-danger btn-sm deleteUser">Eliminar</a> ';
                    $btnRep = '<a href="javascript:void(0)" data-id="'.$row->id.'" class="btn btn-info btn-sm showReport">Reporte</a> ';
                    return $btnAdd . $btnDel . $btnRep;
                })
                ->rawColumns(['action'])
                ->make(true);
        }

How can I display Users list with Machines ?

Activity icon

Started a new Conversation How To Use Attach() With UpdateOrCreate()

I am saving User data using below code.

           User::updateOrCreate(['id' => $request->user_id],
                [
                    'name' => $request->nombre,
                    'email' => $request->email,
                    'password' => Hash::make($request->password)
                ]);

User has Many to Many relationship with Machine. I am trying to use below code with above code.

$user->machines()->attach($request->machines);

How can I use attach() with updateOrCreate() ?

Nov
08
2 months ago
Activity icon

Replied to FaceBook Login

Thanks @martinbean for your nice comment. Did you check the Date of the post when posted ? Thank You. Go ahead. I wish every success of your life. Thanks.

Nov
01
2 months ago
Activity icon

Replied to Add CSS In Laravel 8

Thanks @laracoft . Ha ha ha. What a silly mistake ! You found the issue. Thanks.

Activity icon

Replied to Add CSS In Laravel 8

Thanks @laracoft . Yes, CSS file actually exists.

error

Activity icon

Replied to Add CSS In Laravel 8

Thanks @sinnbeck . No, it is not loading.

error

Activity icon

Replied to Add CSS In Laravel 8

Thanks @laracoft . Should I load http://www.example.com/css/app.css in head section of my application ?

Activity icon

Replied to Add CSS In Laravel 8

Thanks @laracoft . Sorry I couldn't understand,

Activity icon

Started a new Conversation Add CSS In Laravel 8

I put my CSS file inside public/css folder. I added CSS file in head section like below.

<link href="{{ url('/css/app.css') }}" rel="stylesheet">

But CSS is not working.

Oct
21
2 months 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
2 months 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
3 months 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
3 months 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
3 months 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
3 months 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
3 months 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
3 months 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
3 months 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
3 months 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
3 months 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 months 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 months 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 months 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
3 months ago
Activity icon

Replied to GIT Pushing

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

Sep
23
3 months 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
3 months ago
Activity icon

Replied to GIT Pushing

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