afoysal

afoysal

Member Since 4 Years Ago

Experience Points
13,320
Total
Experience

1,680 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-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 3
13,320 XP
Oct
22
3 weeks ago
Activity icon

Started a new Conversation Display Validation Error In Modal

I have a form in Bootstrap Modal. I am validating Form submission data using $request->validate(). My Modal Form input field code is like below

    <div class="form-group {{ $errors->has('firstname') ? 'has-error' : '' }}">

        <label for="firstname">First Name:</label>

        <input type="text" id="firstname" name="firstname" class="form-control" placeholder="Enter First Name" value="{{ old('firstname') }}">

        <span class="text-danger">{{ $errors->first('firstname') }}</span>

    </div>

How can I display Validation Errors in Bootstrap Modal ?

Oct
04
1 month ago
Activity icon

Started a new Conversation Current URL Is Not Printing

I need to print current URL. I am using below code

<a href="{! $request->url() !}">URL</a>

But it is not working.

Activity icon

Started a new Conversation Develop Social Share Button

I am developing social share button. My code is like below

<div class="socialShareWrap">
                  <ul>
                      <li class="fb-share-button" 
                        data-size="large"
                        data-href="{! $request->url() !}" 
                        data-layout="button">
                      </li>
                      <li>
                        <a href="{! $request->url() !}" class="twitter-share-button" data-size="large">Tweet</a>
                        <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                      </li>
                      <li>
                        <a href="https://plus.google.com/share?url={! $request->url() !}" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,height=600,width=600');return false;"><img

src="https://www.gstatic.com/images/icons/gplus-32.png" alt="Share on Google+"/>

  • I am getting output like below

    enter image description here

    Why Twitter button is slightly upside ? How can I fix this ?

    Oct
    03
    1 month ago
    Activity icon

    Started a new Conversation How To Merge Multiple Value To $request

    How to merge multiple value to $request ? I am using below code. Is it correct syntax ?

    $request->merge(['user_id' => $result->id,'photo' => $imgName]);
    
    Oct
    02
    1 month ago
    Activity icon

    Replied to Conditionally Include CSS In Laravel Blade

    Lots of classes and clashes also. It needs long time to fix all those. Thanks.

    Activity icon

    Replied to Conditionally Include CSS In Laravel Blade

    Thanks @siangboon. I know this. I need for HTML elements. I am facing bootstrap version mismatch issue. Thanks.

    Activity icon

    Started a new Conversation Conditionally Include CSS In Laravel Blade

    Is it possible to include several style sheet for several HTML element in Laravel blade conditionally in a page ?? Like I would like to include style.css for <div class="first"></div>,<div class="second"></div>, <div class="third"></div> and style1.css for <span class="first"></span>,<span class="second"></span>, <span class="third"></span> and style3.css for <p class="first"></p>,<p class="second"></p>, <p class="third"></p>

    Oct
    01
    1 month ago
    Activity icon

    Replied to Display 2 Types Of Data

    Thanks @bobbybouwmann. I edited my Question. Thanks.

    Sep
    30
    1 month ago
    Activity icon

    Started a new Conversation Display 2 Types Of Data

    I have 2 types of user Athletes and Teams. I created 3 tables users,athletes & teams. I am storing username & password in users table and others information in athletes & teams table. I would like to display Athletes and Teams information in home page.

    My User model is like below

    <?php
    
    namespace App;
    
    use Illuminate\Notifications\Notifiable;
    use Illuminate\Foundation\Auth\User as Authenticatable;
    
    class User extends Authenticatable
    {
        use Notifiable;
    
        /**
         * The attributes that are mass assignable.
         *
         * @var array
         */
        protected $guarded = [];
    
        /**
         * The attributes that should be hidden for arrays.
         *
         * @var array
         */
        protected $hidden = ['password', 'remember_token',];
        
        protected $fillable = ['email','password','remember_token','category_id'];
    
        public function team()
        {
            return $this->hasOne(Team::class);
        }
    
        public function athlete()
        {
            return $this->hasOne(Athlete::class);
        }
    }
    

    My Team model is like below

    <?php
    
    namespace App;
    
    use Illuminate\Database\Eloquent\Model;
    
    class Team extends Model
    {    
      public $guarded = [];
    
      protected $fillable = ['first_name','last_name','user_id','how_did_find','social_media',];
    
      public function user()
      {
        return $this->belongsTo(User::class);
      }
    }
    

    My Athlete model is like below

    <?php
    
    namespace App;
    
    use Illuminate\Database\Eloquent\Model;
    
    class Athlete extends Model
    {    
      public $guarded = [];
    
      protected $fillable = ['user_id','social_media','youtube_video','website'];
    
      public function user()
      {
        return $this->belongsTo(User::class);
      }
    }
    

    I am using below code in controller.

    $staff_picks = User::orderBy('id','desc')->take(10)->with('category','athlete','team')->get();
    
    Sep
    26
    1 month ago
    Activity icon

    Replied to How To Use Joined Model Function

    @nakov & @snapey I have a list of category. If user click on a category, user will see a list of users related to that category, users table has a category_id field. This is easy and I done this.

    But there is a link all, if user click on that link user will see all the users of all categories. Both users of single category and all category is using same View. This is little tough for me.

    I put users of all category in an array and iterate it to display users.

    Thanks.

    Activity icon

    Replied to Add Value To $request

    The answer is $request->merge(['photo' => $imgName]);.

    Sep
    25
    1 month ago
    Activity icon

    Started a new Conversation Add Value To $request

    I am trying to do like below

    $request->photo = $imgName;
    

    But it is not working.

    Activity icon

    Replied to Mail Send In Laravel

    Thanks @snapey . Is it possible to know mail is sent from below code ?

    if(Mail::send(new ContactUs($request))){ //some code }

    Activity icon

    Replied to Mail Send In Laravel

    Thanks @joveice. But how can I confirm a Mail is sent ? Thanks.

    Activity icon

    Started a new Conversation Mail Send In Laravel

    I am trying to send mail from Laravel using below code.

    Mail::send(new ContactUs($request));
    

    How to confirm a mail is sent in Laravel ?

    Activity icon

    Replied to How To Use Log::info()

    Thanks @joveice . I have no such file.

    enter image description here

    Activity icon

    Started a new Conversation How To Use Log::info()

    I have a function like below in my controlle

    public function contactUssend(Request $request){
        if($request->method() == 'POST'){
            if($request->ajax()){
                if( $request->post('human_verify') == Session::get('humanverify')){  
                    $confirmation = Mail::send(new ContactUs($request));                    
                    if($confirmation){
                        return response()->json(['result' => 1]);  
                    }
                    else {
                        return response()->json(['result' => 0]);  
                    }
                }else {
                    Log::info('Hello World');
                    return response()->json(['result' => 2]);
                }
            }
        } else { 
            return response()->json(['result' => 0]); 
        }
    }
    

    But I not getting any value in laravel.log

    enter image description here

    Activity icon

    Replied to Get Outer Loop Value Inside Inner Loop

    Thanks @nakov for your reply. Your solution is working. But how can I paginate here ? Thanks

    Sep
    24
    1 month ago
    Activity icon

    Started a new Conversation Get Outer Loop Value Inside Inner Loop

    My code is like below

    $result = array();
        foreach($category as $cat) {
        //$cat->category_name
            foreach($cat->users()->orderBy('id', 'desc')->paginate(20) as $value) {
                    $result[] = $value;
            }
        }
    
    foreach( $result as $spc ) {
            // some code here, 
                // I would like to get $cat->category_name  here
    }
    

    How can I get outer loop value inside inner loop ??

    Activity icon

    Replied to How To Use Joined Model Function

    @nakov & @snapey

    I am using like this.

    $result = array();
        foreach($category as $cat) {
              foreach($cat->users()->orderBy('id', 'desc')->paginate(20) as $value) {
                     $result[] = $value;
              }
         }
    
    foreach( $result as $spc ) {
        //some code here, I would like to get Category_name  here
    }
    
    Activity icon

    Replied to How To Use Joined Model Function

    Thanks @nakov . Your solution is not working. Thanks.

    Activity icon

    Replied to How To Use Joined Model Function

    @nakov , I am getting this error [2019-09-24 13:37:29] laravel.ERROR: Call to undefined method App\Category::getFullNameAttribute(). Thanks.

    Activity icon

    Replied to How To Use Joined Model Function

    Thanks @nakov . Yes, A User has a category ID. Which means a category can have many Users.

    Activity icon

    Started a new Conversation How To Use Joined Model Function

    I have query like below

    $category = Category::join('users', 'users.category_id', '=', 'categories.id')->get();
    

    I have a function in User model like below

    public function getFullName()
        {
            return $this->first_name.' '.$this->middle_name.' '.$this->last_name;
        }
    

    I am using below code in View

    @foreach( $category as $spc ) {
        $spc->about_me   // I am using other attributes like this
        //How can I use getFullName() name here like above code ?
    }
    

    How can I use getFullName() name here like above code ?

    Activity icon

    Replied to Printing Key Of Foreach Loop

    Thanks @nakov . But how can I print the Index ?

    Activity icon

    Started a new Conversation Printing Key Of Foreach Loop

    I have below code

    $result = array();
        $category_name = array();
        foreach($category as $cat) {
            $category_name[] = $cat->category_name;
            $campaigns = $cat->users()->orderBy('id','desc')->paginate(20);
            foreach($campaigns as $campaign) {
                    $result[] = $campaign;
                }
         } 
    

    I am trying to iterate like below

    @foreach( $result as $key => $spc )
                        {{ $key }}     // [2019-09-24 11:45:41] laravel.ERROR: Undefined offset: 6
    @endforeach
    

    Why I am getting error ?

    Sep
    23
    1 month ago
    Activity icon

    Replied to How To Fetch Result From Items: Collection In Blade

    Actually it is a purchased script.

    Activity icon

    Started a new Conversation How To Fetch Result From Items: Collection In Blade

    How to fetch result from below items: Collection in blade ?

    enter image description here

    Activity icon

    Replied to Eloquent Issue In Blade Template

    Yes, correct values.

    Activity icon

    Replied to Eloquent Issue In Blade Template

    Thanks for your reply. But why I am getting 0 ?

    Activity icon

    Started a new Conversation Eloquent Issue In Blade Template

    I have a function in my controller like below

    public function singleCategory($id){
            if($id == 'all') {
                $category = Category::get();
            } else {
                $category = Category::find($id);
            }
            return view('campaigns_by_category', compact('category'));
    }
    

    In blade template I am using below code

    @if(request()->segment(2) == 'all')
                    @php
                        foreach($category as $cat) {
                            $campaigns = $cat->users()->orderBy('id', 'desc')->paginate(20);
                        }
                    @endphp
                @else
                    @php
                        $campaigns = $category->users()->orderBy('id', 'desc')->paginate(20); 
                    @endphp
                @endif
                {{ count($campaigns) }}   // Why I am getting 0 here ?
    

    My Category model has function like below

    public function users(){
            return $this->hasMany(User::class)->where("active_status",1)->where("user_type", 'user');
        }
    
    Activity icon

    Started a new Conversation Display Date In Input Type Date Field

    I am fetching date from Database and Displaying in a input type date field. My code is like below

        <input min="2000-01-01" max="2019-12-31" name="date_of_birth" id="dob" type="date" class="form-control" placeholder="Date of birth" value="{{ date('m/d/Y',strtotime($user->date_of_birth)) }}"/>
    

    But I can't see date in input field.

    enter image description here

    Activity icon

    Replied to Same Function Like ::find($id)

    Thanks @afitriali. Could you please say how can I tweak it in Blade ? Thanks.

    Activity icon

    Replied to Ternery Operator In Blade Template

    You solution also creating error. Thanks.

    Activity icon

    Replied to Ternery Operator In Blade Template

    I am getting error in below line.

    {{ $campaigns->count()? ($campaigns->count() < 20 ? $campaigns->count():20):0 }}

    Activity icon

    Started a new Conversation Ternery Operator In Blade Template

    My code is like below where I am getting error

    {{ $campaigns->count()? ($campaigns->count() < 20 ? $campaigns->count():20):0 }}
    

    I am getting error like below

    [2019-09-23 06:36:44] laravel.ERROR: syntax error, unexpected '}' (View: /var/www/html/js/resources/views/campaigns_by_category.blade.php)

    Activity icon

    Started a new Conversation Same Function Like ::find($id)

    I have a condition in controller like below

    if($id == 'all') {
            $category = Category::get();        // I am getting error with result of this line
        } else {
            $category = Category::find($id);
        }
    

    I am looking for a function like ::find($id) for getting all records, so that I can use that as similar as ::find($id) in blade template.

    Sep
    20
    1 month ago
    Activity icon

    Started a new Conversation Print Multiple Variable Together

    I am trying to print multiple variable together like below, but I am getting error.

    <a href="">{{ $spc->first_name $spc->middle_name $spc->last_name}}</a>
    
    Sep
    19
    1 month ago
    Activity icon

    Replied to HTTP Request Manipulation

    @nakov , I am using below code

    if($request['password'] = '') {
           $request->except(['password']);
        } 
        $result = User::create($request->all());
    

    But I am getting below error

    enter image description here

    Activity icon

    Started a new Conversation HTTP Request Manipulation

    How can I remove $request['password'] from $request->all() ?

    Thanks

    Sep
    18
    2 months ago
    Activity icon

    Replied to 500 Error

    Thanks Your solution is working.

    Activity icon

    Replied to 500 Error

    I have cPanel. How can I check Server Log ? Thanks.

    Activity icon

    Started a new Conversation 500 Error

    Previously the Laravel application is running well. But after I update the whole code I am getting 500 Internal Server Error.

    Do you have any clue why I am getting 500 Internal Server Error ?

    enter image description here

    Activity icon

    Replied to Authentication In Another Contorller

    Thanks @emadiga for your reply. Your solution is not working. I am trying like below

        $result = User::create($request->all());
                $user = $request->all();
                Auth::login($user);
    
                if($result){
                return response()->json(['result' => 1]);
            }else {
                return response()->json(['result' => 0]);
            }
    
    Sep
    17
    2 months ago
    Activity icon

    Started a new Conversation Authentication In Another Contorller

    I need to redirect User to dashboard (which is a authenticated page ) after User registration. My Registration code is like below which is in UserController.php

    $result = User::create($request->all());
    

    Which code should I write to authenticate the User here ?

    Activity icon

    Replied to FaceBook Login

    Thanks @sti3bas . I created Facebook App to get App ID and I have App ID. What to do next ?

    Activity icon

    Started a new Conversation FaceBook Login

    I am working in a purchased Laravel script. I need FaceBook login. In Login page I am getting view like below.

    enter image description here

    If I click on Facebook I am redirected to Facebook and getting view like below

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

    I am new FaceBook login development. How can I develop a FaceBook Login ?

    Activity icon

    Replied to Route Is Not Working

    Thank You. Your solution is working. Thanks.

    Activity icon

    Replied to Route Is Not Working

    @munazzil , why it is going to header.blade.php ? It should die('hello'). Isn't it ? Thanks.

    Activity icon

    Started a new Conversation Route Is Not Working

    My route is like below

    Route::get('/create_user', function()
    {
        die('hello');
    });
    

    I am trying to browse like below

    http://127.0.0.1:8000/create_user
    

    I am getting error like below

    Call to a member function getName() on null (View: /var/www/html/bs/resources/views/layouts/header.blade.php)

    Why I am getting this error ?