azhar_hussain

azhar_hussain

Software Engineer at Lahore

Member Since 11 Months Ago

Pakistan

Experience Points
500
Total
Experience

4,500 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-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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
500 XP
Apr
08
6 months ago
Activity icon

Started a new conversation Laravel Dynamic Input Field

hey everyone trying to add a dynamic input field which could be added more via add button and can deleted via minus button ,also add data to db via controller method if anyone have sample then share .will be thankful

Apr
05
6 months ago
Activity icon

Replied to Save To Laravel Polymorphic Relationship

@SABONZY - thanks you for your response error been solved

Activity icon

Started a new conversation Store Data In Multiple Rows

hi everyone im trying to store data in multiple rows ,data is storing in parent row but when im trying to add data in new row added via plus button data in new row is not storing here is my blade

@include('layouts.header')
@include('layouts.topbar')
@include('layouts.side_bar')
<html>
<head>
</head>
<body>
<div class="container" style="margin-top: 7%;margin-left: 20%">
    <div class="col-sm-12 portlets">
        <div class="widget">
            <div class="widget-header transparent">
                <h2><strong>Add Exercise Type Level</strong></h2>
            </div>
            <div class="widget-content padding">
                <form class="row" method="post" action="{{url('submit-exercise-type-level')}}" id="addExerciseTypeLevel" enctype="multipart/form-data">
                    @csrf
                    @if ($errors->any())
                        <div class="alert alert-danger">
                            <ul>
                                @foreach ($errors->all() as $error)
                                    <li>{{ $error }}</li>
                                @endforeach
                            </ul>
                        </div><br />
                    @endif
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="level_id">Level</label>
                            <select name="level_id" class="form-control" id="level_id" >
                                <option value="">Select Level</option>
                                @foreach($levels as $level)
                                    <option value="{{ $level->id }}">{{ $level->name }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="strength_id">Strength</label>
                            <select name="strength_id" class="form-control" id="strength_id" >
                                <option value="">Select Strength</option>
                                @foreach(App\Strength::all() as $item)
                                    <option value="{{ $item->id }}">{{ $item->name }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="no_of_sets">No Of Sets</label>
                            <input type="text" id="no_of_sets" class="form-control" name="no_of_sets" placeholder="No Of Sets">
                        </div>
                        <div class="form-group">
                            <label for="image_url">Image Url</label>
                            <input type="text" class="form-control" id="image_url" name="image_url" placeholder="Image Url">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="max_power">Maximum Power</label>
                           <input type="text" name="max_power" id="max_power" class="form-control" placeholder="Maximum Power">
                        </div>
                        <div class="form-group">
                            <label for="exercise_type_id" > Exercise Type</label>
                            <select name="exercise_type_id" id="exercise_type_id" class="form-control" >
                                <option value="">Select Exercise Type</option>
                                @foreach(App\ExerciseType::all() as $item)
                                    <option value="{{ $item->id }}">{{ $item->title }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="goal_id" > Goal</label>
                            <select name="goal_id" id="goal_id" class="form-control" >
                                <option value="">Select Gaol</option>
                                @foreach(App\Goal::all() as $item)
                                    <option value="{{ $item->id }}">{{ $item->name }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
<!--row details-->
                    <div class="col-sm-6 col-xs-12 main_div" style="padding: 0px">
                        <div class="col-sm-12 col-xs-12 child_div" style="padding: 0px">
                            <?php $count=0; ?>
                            @if(isset($detail['detail']))
                                @foreach($detail['detail'] as $k=>$item)
                                    <?php
                                    $count=$k;
                                    ?>
                                    <div class="col-xs-12 col-sm-12 grand_child" id="grand_child_0" style="margin-top:10px;padding:0px" >
                                       <div class="row">
                                            <div class="col-sm-3 col-sm-6">
                                                <label for="exercise_no_id_{{  $k }}" class="control-label">
                                                    Exercise No
                                                </label>
                                                <div class="control">
                                                    <select class="form-control required" name="exercise_no_id[]" id="exercise_no_id_{{  $k }}">
                                                        @foreach(App\ExerciseNo::all() as $item)
                                                            <option value="{{ $item->id }}">{{ $item->name }}</option>
                                                        @endforeach
                                                    </select>
                                                    <span class="help-block">{{$errors->first('date','message') }}</span>
                                                </div>
                                            </div>
                                            <div class="col-sm-3 col-sm-6">
                                                <label for="recommended_repetition_{{ $k }}" class="control-label">
                                                    Repetition
                                                </label>
                                                <div class="control">
                                                    <input step="any" type="text" id="recommended_repetition_{{ $k }}" name="recommended_repetition[]" placeholder="Repetition" class="form-control" value="{{isset($item['recommended_repetition'])?$item['recommended_repetition']:''}}">
                                                    <span class="help-block">{{ $errors->first('date', ':message') }}</span>
                                                </div>
                                            </div>
                                            <div class="col-sm-3 col-sm-6">
                                                <label for="rest_time_{{ $k }}" class="control-label">
                                                    Rest Time
                                                </label>
                                                <div class="control">
                                                    <input step="any" type="text"  id="rest_time_{{ $k }}" name="rest_time[]" placeholder="Rest Time" class="form-control" value="{{ isset($item['rest_time'])?$item['rest_time']:'' }}" />
                                                    <span class="help-block">{{ $errors->first('rest_time', ':message') }}</span>
                                                </div>
                                            </div>
                                       </div>
                                    </div>
                                @endforeach
                            @else
                                <div class="col-sm-12 col-xs-12 grand_child" id="grand_child_0" style="margin-top:5px;margin-bottom: 5px;padding:0px">
                                    <div class="col-sm-3 col-sm-6">
                                        <label for="exercise_no_id_0" class="control-label">
                                            Exercise
                                        </label>
                                        <div class="control">
                                            <select class="form-control required" name="exercise_no_id[]" data-bv-notempty data-bv-notempty-message="{{trans('messages.required')}}">
                                                <option value="">
                                                    Choose Exercise
                                                </option>
                                                @foreach(App\ExerciseNo::all() as $item)
                                                    <option value="{{ $item->id }}">{{ $item->name }}</option>
                                                @endforeach
                                            </select>
                                            <span class="help-block">{{ $errors->first('date',':message') }}</span>
                                        </div>
                                    </div>
                                    <div class="col-sm-3 col-sm-6">
                                        <label for="recommended_repetition_0" class="control-label">
                                            Repetition
                                        </label>
                                        <div class="control">
                                            <input step="any" type="text" data-bv-notempty data-bv-notempty-message="{{ trans('messages.required') }}" id="recommended_repetition_0" name="recommended_repetition[]" placeholder=" Repetition" class="form-control" value="">
                                            <span class="help-block">{{ $errors->first('date',':message') }}</span>
                                        </div>
                                    </div>
                                    <div class="col-sm-3 col-sm-6">
                                        <label for="rest_time_0" class="control-label">
                                            Rest Time
                                        </label>
                                        <div class="control">
                                            <input step="any" type="text" data-bv-notempty data-bv-notempty-message="{{ trans('messages.required') }}" id="rest_time_0" name="rest_time[]" placeholder="Rest Time" class="form-control" value="">
                                            <span class="help-block">{{ $errors->first('date','message') }}</span>
                                        </div>
                                    </div>
                                    <div class="col-sm-3 col-sm-6 hide" id="remove_btn">
                                        <label for="" class="label-control">
                                        </label>
                                        <div class="control">
                                            <button type="button" class="btn btn-default removeButton" ><i class="fa fa-minus"></i></button>
                                        </div>
                                    </div>
                                </div><!--end of grand child-->
                            @endif
                        </div><!--child div-->
                        <div class="col-sm-3 col-sm-6">
                            <div class="control"><br>
                                <a type="button" class="btn btn-default addButton"><i class="fa fa-plus"></i></a>
                            </div>
                        </div><!--end of col-sm-12-->
                    </div><!--main div-->
                    <input type="hidden" name="purchase_id" value="{{isset($detail['id'])?$detail['id']:'' }}">
                    <input type="hidden" name="_token" value="{{csrf_token()}}">
                    <div class="clearfix"></div>
                   <!--end of pull right-->
                    <br>
                    <div class="col-md-6">
                        <div class="form-group">
                            <button type="submit" class="btn btn-success">Submit</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@include('layouts.footer')
<script>
    $(document).ready(function () {
        $('#addExerciseTypeLevel').bootstrapValidator({
            fields: {
                no_of_sets: {
                    validators: {
                        notEmpty: {
                            message: 'The  No of Sets is required and can\'t be empty'
                        }
                    }
                },
                max_power: {
                    validators: {
                        notEmpty: {
                            message: '  Max Power is required and can\'t be empty'
                        }
                    }
                },
                recommended_repetition: {
                    validators: {
                        notEmpty: {
                            message: ' Recommended Repetition is required and can\'t be empty'
                        },
                    }
                },
                rest_time: {
                    validators: {
                        notEmpty: {
                            message: ' Rest Time is required and can\'t be empty'
                        },
                    }
                },
                strength_id: {
                    validators: {
                        notEmpty: {
                            message: 'Choose a Strength and can\'t be empty'
                        }
                    }
                },
                level_id: {
                    validators: {
                        notEmpty: {
                            message: 'Select a Level and can\'t be empty'
                        }
                    }
                },
                image_url: {
                    validators: {
                        notEmpty: {
                            message: 'Image url is required and can\'t be empty'
                        }
                    }
                },
                goal_id: {
                    validators: {
                        notEmpty: {
                            message: 'The Goal is required and can\'t be empty'
                        }
                    }
                },
            }
        }).on('click', '.addButton', function() {
            var $template = $('#grand_child_0'),
                $clone    = $template
                    .clone()
                    .removeClass('hide')
                    .removeAttr('id')
                    .insertAfter($template),
                $exercise_no   = $clone.find('[name="exercise_no_id[]"]');
            $recommended_repetition = $clone.find('[name="recommended_repetition[]"]');
            $exercise_no_id = $clone.find('[name="exercise_no_id[]"]');
            $clone.find('[id="remove_btn"]').removeClass('hide');
            // Add new field
            $('#tryitForm').bootstrapValidator('addField', $exercise_no);
            $('#tryitForm').bootstrapValidator('addField', $recommended_repetition);
            $('#tryitForm').bootstrapValidator('addField', $exercise_no_id);
        }).on('click', '.removeButton', function() {
                var $row    = $(this).parents('.grand_child'),
                    $exercise_no = $row.find('[name="exercise_no_id[]"]');
            $recommended_repetition = $row.find('[name="recommended_repetition[]"]');
            $exercise_no_id = $row.find('[name="exercise_no_id[]"]');

                // Remove element containing the option
                $row.remove();
                $('#tryitForm').bootstrapValidator('addField', $exercise_no);
                $('#tryitForm').bootstrapValidator('addField', $recommended_repetition);
                $('#tryitForm').bootstrapValidator('addField', $exercise_no_id);
                // Remove field
            })
    });
</script>
</body>
</html>

and here is my controlller 

 public function saveNewExerciseTypeLevel(Request $request)
    {
        $request->validate([
            'goal_id'=> 'required',
            'max_power'=> 'required',
            'no_of_sets'=> 'required',
            'level_id'=> 'required',
            'strength_id'=> 'required',
            'image_url'=> 'required',
            'exercise_type_id'=>'required',
            'recommended_repetition'=> 'required',
            'rest_time'=> 'required',

        ]);
        $data=array(
            'goal_id'=> $request['goal_id'],
            'exercise_type_id'=> $request['exercise_type_id'],
            'max_power'=> $request['max_power'],
            'no_of_sets'=>$request['no_of_sets'],
            'level_id'=> $request['level_id'],
            'strength_id'=> $request['strength_id'],
            'image_url'=>$request['image_url'],
        );
        $share = new ExerciseTypeLevel();
        $share->fill($data)->save();
        if(count($request['exercise_no_id'])>0) {
            foreach ($request['exercise_no_id'] as $k => $item) {
                $exerciseWithLevel = new ExerciseWithLevel();
                $exerciseWithLevel->recommended_repetition = $request['recommended_repetition'][$k];
                $exerciseWithLevel->rest_time = $request['rest_time'][$k];
                $exerciseWithLevel->exercise_no_id = $request['exercise_no_id'][$k];
                $exerciseWithLevel->save();
            }

            return redirect('/dashboard')->with('success', 'Exercise with level has been added');
    }    }
}



willl be rellay apreciated
Mar
27
6 months ago
Activity icon

Replied to Save To Laravel Polymorphic Relationship

~ "Call to undefined method App\ModelType::likes() 5~ i have defined relationship already but still facing the aboe error

Activity icon

Started a new conversation Save To Laravel Polymorphic Relationship

when im trying to submit then following error comes

"message": "Method Illuminate\Support\Collection::likes does not exist. 100"

my code looks like this


 $type=ModelType::whereId($input['likeable_type'])->pluck('title');
                $this->model=$type;
                $model=new $this->model;
                $model->likes()->create([
                    'user_id'=>Auth::user()->id,
                    'likeable_id'=>$model['likeable_id']
                ]);



willl be appriciated

Mar
25
6 months ago
Activity icon

Started a new conversation Laravel Youtube

how i can find the duration of youtube video in laravel . thank you Best regards Capt.Azhar

Mar
22
6 months ago
Activity icon

Replied to Laravel Eloquent

really appreciate thank u buddy it worked for me

Activity icon

Started a new conversation Laravel Eloquent

how i will write this sql query in laravel eloquent

UPDATE user_levels SET complete_count = complete_count+1 WHERE is_completed=1

thank you every body

Activity icon

Started a new conversation Eloquent

i want to get the complete_count and value in complete_count increments by 1 when is_completed = 1 every time my db table structure is as following LevelUser id is_completed complete_count level_id

Jan
23
8 months ago
Activity icon

Replied to Edit Column In Laravel

public function getProductCategoryList() {

    $productCategory=ProductCategory::select('product_categories.*');
    return DataTables::of($productCategory)




        ->editColumn('company_id',function($user)
        {
            return $user->user->company_name;
        })




    ->editColumn('status',function($productCategory)
    {



            if($productCategory->status == 1)



            {
                return 'Enabled';
            }
            else


            {
                return 'Disabled';
            }
    })->make(true);

}
Activity icon

Replied to Edit Column In Laravel

its working fine but same way when im trying to edit another column it fails

Activity icon

Replied to Edit Column In Laravel

public function getProductCategoryList() {

    $productCategory=ProductCategory::select('product_categories.*');
    return DataTables::of($productCategory)
    ->editColumn('status',function($productCategory)
    {






            if($productCategory->status == 1)
            {
                return 'Enabled';
            }







            else
            {
                return 'Disabled';
            }
    })->make(true);

}
Activity icon

Replied to Edit Column In Laravel

public function getProductCategoryList() { $productCategory=ProductCategory::select('product_categories.*'); return DataTables::of($productCategory) ->editColumn('company_id',function($user) { return $user->user->company_name; }) ->editColumn('status',function($productCategory) { if($productCategory->status == 1) { return 'Enabled'; } else { return 'Disabled'; } })->make(true);

}
Activity icon

Started a new conversation Edit Column In Laravel

i want to edit column company_id and wanna show company_name instead ,without using relationship

Nov
13
11 months ago
Activity icon

Replied to 1048 Column 'post1' Cannot Be Null In Laravel

i dont want to pass a nullable value through post1 so where i should make changes?

Activity icon

Replied to 1048 Column 'post1' Cannot Be Null In Laravel

@TAKDW - let me check thanks for your responce

Activity icon

Started a new conversation 1048 Column 'post1' Cannot Be Null In Laravel

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'post1' cannot be null (SQL: insert into shares (share_name, share_price, share_qty, post1, name, f_name, cnic, mobile_no, email, dob, religion, gender, martial_status, district, blood_group, nationality, address, updated_at, created_at) values (sfkl, 344, 344, , , arif, 34301, 0315, [email protected], 2018-11-27, islam, male, unmarried, hafiz, b+, pak, abc, 2018-11-14 07:37:44, 2018-11-14 07:37:44))