david001

david001

Member Since 5 Years Ago

Experience Points
13,250
Total
Experience

1,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
3
Lessons
Completed
Best Reply Awards
1
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 3
13,250 XP
Oct
17
3 days ago
Activity icon

Replied to Upgrade PHP Version On Mac

Error: No such keg: /usr/local/Cellar/[email protected]

Activity icon

Replied to Upgrade PHP Version On Mac

got error Error: No such keg: /usr/local/Cellar/[email protected]

Activity icon

Replied to Upgrade PHP Version On Mac

Thanks, @snapey for sharing the link. But it is not working. I hope you can help me. Based on the above article, these were the steps I have followed.

step1:

brew unlink php && brew link php I got this


Unlinking /usr/local/Cellar/php/7.4.11... 24 symlinks removed
Linking /usr/local/Cellar/php/7.4.11... 24 symlinks created

step 2:


cd ~
$ vi .zshrc

However, I have not got the following line in a terminal export PATH=/usr/local/php5/bin:$PATH

echo $PATH SHOWS

/usr/local/opt/[email protected]/sbin:/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/bin:/usr/local/php5/bin:/usr/local/php7.3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/php5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Activity icon

Replied to Upgrade PHP Version On Mac

it shows

/usr/local/php5/bin/php

Activity icon

Replied to Upgrade PHP Version On Mac

I even restarted my computer. It shows PHP 7.2

Activity icon

Started a new Conversation Upgrade PHP Version On Mac

I am using a mac. I need to install laravel so I want to upgrade to PHP 7.3 or higher I did brew install [email protected] and when I checked my PHP version in another terminal it still shows me PHP 7.2 .Again I run the command brew upgrade PHP, it gives me a warning

 brew upgrade php
Updating Homebrew...
Warning: php 7.4.11 already installed

but php -v shows me 7.2 . can anyone help me how to get php 7.4? Thanks

Oct
14
6 days ago
Activity icon

Started a new Conversation Upgrade Php Version

I am using mac os and I have PHP 7.2.21 To install Laravel8v,I need a minimum PHP version 7.3

I want to upgrade to PHP 7.3 or 7.4 from 7.2. I tried a lot of times but nothing happened. I am unable to upgrade PHP version. I run the following command

brew upgrade
brew install php73
brew install [email protected]

Please guide me

Oct
06
2 weeks ago
Activity icon

Started a new Conversation How To Use Xampp Php Instead Of Built-in Php?

Hi, I want to start with laravel8 and it need PHP version above 7.3 My terminal shows PHP version 7.2 and my xampp shows PHP version 7.4

I want use xampp php instead of build in php so that i can use laravel 8. How can i achieve this.

Please help me. Thanks

Oct
02
2 weeks ago
Activity icon

Started a new Conversation Php 7.2 To 7.3

Hi, I am a mac user. I want to try laravel 8 but it requires PHP 7.3 or above. However, I have PHP version 7.2.21. How can I upgrade to PHP 7.3?

I have followed lots of steps to upgrade to PHP 7.3. But unfortunately, I could not. Can you please provide me some suggestions to get PHP 7.3 in my mac,

Thanks

Sep
06
1 month ago
Activity icon

Replied to Two Registration Form

Hi, anyone can give me hints. Thanks

Sep
05
1 month ago
Activity icon

Started a new Conversation Two Registration Form

I have a two types of registration form , job seeker and employer

in url for registration I want

domain.com?user_type=seeker

and this should render seeker signup form

and domain.com?user_type=employer

this should render the employer signup form

in db in have user_type filed: this should save either seeker or employer based on user_type in URL while creating account. How can i achieve this.? looking for help

Aug
30
1 month ago
Activity icon

Replied to Vue Model Binding For Jquery Datapicker

I have already used jquery datepicker

Activity icon

Started a new Conversation Vue Model Binding For Jquery Datapicker

I am using jQuery date picker and its working perfectly. I am in Vue component. when I click the date input field it shows date picker but when I choose one date and see the result in the console I got nothing. Date is not bind.

<form @submit.prevent="search()">
    <div class="card">
        <div class="card-body">
            <div class="card-header"></div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-8">
                        <input type="text" v-model="date"  class="form-control" id="datepicker" >
                    </div>
                    <div class="col-md-4">
                        <button class="btn btn-primary" >Search</button>

                    </div>
                    
                </div>
                
            </div>
        </div>
        
    </div>
    </form>

<script>
    export default {
        data(){
            return{
                date:''
            }
        },
        mounted() {
            console.log('Component mounted.')
        },
        methods:{
            search){
                console.log(this.date)
            },
          

        },
   
    }
</script>

when i click the search button , i should get the date in console but i got nothing, How to get current selected date by user? Thank you

Jun
01
4 months ago
Activity icon

Replied to Update Unique Email Error

yes you are right. My mistake , I used create() instead of update() in update method

Activity icon

Started a new Conversation Update Unique Email Error

Hi, I am logged in as a user id 1 which is admin, so now to update user with 8 record and I want to change his email so in update method i used validation like this:

public function update(Request $request, $id)
    {
        $this->validate($request,[
            'email'=>'required|unique:users,email,'.$id
        ]);

    }

but I got below error. I want to make unique email in DB but if admin is not changing users email it should let same email for that id to be in users table


Integrity constraint violation: 1062 Duplicate entry '[email protected]' for key 'users_email_unique' (SQL: insert into `users`
May
30
4 months ago
Activity icon

Started a new Conversation How To Validate With Condition

I have a ClientFormRequest file in Request folder I want to validate image while storing a record and want to make it required. However, for update method I don't want the image to be required


public function rules()
    {
        return [
          
            'description'=>'required',
    //......
            'image'=>'required|mimes:jpeg,png,jpg'

        ];
    }

store method


  public function store(ClientFormRequest $request)
    {
        // i want to validate image here
        
    }
public function update(ClientFormRequest $request,$id)
    {
        // i dont want to make image required here but want to validate rest of other fields with ClientFormRequest.php
        
    }
May
23
4 months ago
Activity icon

Started a new Conversation How To Add Click Event Of Date: Jquery Datepicker

Hi, how can I add a click event to the days of this calendar? It shows all the days of this month of May 2020, Now when I click any date it should show me today's date as 2020-5-24. I want to send ajax request and get data based on today's date.


<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Datepicker - Display inline</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"defer></script>
  <script>
  $( function() {
    $( "#datepicker" ).datepicker();
  } );
  </script>
</head>
<body>
Date: <div id="datepicker"></div>
May
20
5 months ago
May
18
5 months ago
Activity icon

Started a new Conversation How To Load Data With Ajax

Hi I am new to ajax. I have to fetch data in view with laravel. Currently the view page shows all departments but I want to implement a filter and search data. My filter will have a dropdown with different departments and submit button and when the user chooses one department and submit button it should only show those departments in the view file.

my view file


<div>
<form action="{{route('department.filter')}}" method="post">@csrf
  <select name="department" class="form-control">
      <option value="1">IT Department</option>
       <option value="2">Sales Department</option>
       <button type="submit" class="bnt btn-primary">Filter</button>

  </select>
  
</form>

</div>

<table class="table">
  <thead class="thead-dark">
    <tr>
      
      <th scope="col">Name</th>
      <th scope="col">Description</th>
      <th scope="col">Status</th>
      <th scope="col">Created</th>
    </tr>
  </thead>
  <tbody>
  @foreach($departments as  $department)
    <tr>
      
      <td>{{$department->name}}</td>
      <td>{{$department->description}}</td>
      <td>{{$department->created_at}}</td>
    </tr>
  @endforeach
    
  </tbody>
</table>

I Have changed the filter as below for ajax request


<form >
  <select name="department" id="department"class="form-control">
      <option value="1">IT Department</option>
       <option value="2">Sales Department</option>
       <button type="submit" class="bnt btn-primary" id="filter">Filter</button>

  </select>
  
</form>
and ajax
<script type="text/javascript">
    $(document).ready(function(){
        $("#filter").click(function(e){
            e.preventDefault();
            var departmentId = $("#department").val()
	
		$.ajax({
                 
                    url: '/search',
                    type: 'POST',
               
                    data:{departmentId:departmentId},
                    dataType: 'JSON',
                   
                    success: function (data) { 
                       
                    }
                }); 

            //I AM STUCK HERE , HOW TO UPDATE MY PAGE WITH THE DATA
        })
    })
</script>

CONTROLLER:


public function index(){
$departments = Department::get();
return view('index',compact('departments'));
}



for /search url


public function filter(Request $request){
return Department::where('id',$request->department)->get();
}

I am stuck in ajax part and not sure how to get data and update page. Any help?

Activity icon

Replied to Edit : Maintain Checkbox State

Thank you. appreciated!!

Activity icon

Started a new Conversation Edit : Maintain Checkbox State

Hi, I am stuck. I need help to solve this problem. I want to make checkbox state checked if that value exist in db.

create.blade.php

<input type="checkbox" name="time[] " value="6:00" >6:00
     <input type="checkbox"name="time[]" value="6:20"  >6:20
    <input type="checkbox"name="time[]" value="6:40">6:40

These value stored in the table in time field of database

Now in a different view file (different route), I want to show all this 3 checkbox and at the time i want to check whether 6:00,6:10: and 6:40 are already in time field of schedules table and if yes just check the checkbox and if not leave uncheck the checkbox.

my table is schedules and time store these time

method:

public function getallSchedule(){

	$schedules=Schedule::get();
	return view('index',compact['schedules]);
}

index.blade.php: need to mark check if the value exist in db

<input type="checkbox" name="time[] " value="6:00" >6:00
     <input type="checkbox"name="time[]" value="6:20"  >6:20
    <input type="checkbox"name="time[]" value="6:40">6:40
May
13
5 months ago
Activity icon

Started a new Conversation Limiting String Str::limit

Hi, I have displayed a description in the following format and I want to show only 100 characters.

{!! $post->body !!} instead of {{ $post->body }} because i want to display exact text that admin has posted ie: some text bold, some with link... with text editior summernote

Now I want to limit the characters so I did this {!! Str::limit($post->body, 100) !!} But this shows me p tag, div tag . which i don;'t want to display. I Only want to show the text of 100 characters. Any help?

May
11
5 months ago
Activity icon

Started a new Conversation FormData Is Null

Hi, I need help in image upload with vuejs and Laravel. I am using this package to upload image https://github.com/lekhang2512/vue-upload-multiple-image

<template>
<div>

    <vue-upload-multiple-image
      @upload-success="uploadImageSuccess"
      @before-remove="beforeRemove"
      @edit-image="editImage"
      @data-change="dataChange"
      ></vue-upload-multiple-image>
</div>
</template>

methods:{
        
       
    uploadImageSuccess(formData, index, fileList) {
        //console.log('data', formData, index, fileList)
    

axios.post('/images',fileList,{headers: {
        'Content-Type': 'multipart/form-data' }
         }).then(response => {
            console.log(response);
    })},
    beforeRemove (index, done, fileList) {
      console.log('index', index, fileList)
      var r = confirm("remove image")
      if (r == true) {
        done()
      } else {
      }
    },
    editImage (formData, index, fileList) {
      console.log('edit data', formData, index, fileList)
    },
    dataChange (data) {
      console.log(data)
    }

controller:

public function Images(Request $request){
       return($request->formData);
	
     
    }

I want to get filename and save in file in public directory and image in db But I am getting null form data.

May
03
5 months ago
Activity icon

Started a new Conversation Summernote Update Throws Error:Undefined Offset: 1

I have used summer note in my project.https://summernote.org/

I can create the post with summernote. I can attach the images to my content as well. However, when I click the edit button and add a few photos in textarea and click the update button, it gives me an error

Undefined offset: 1

update:


$service = Service::find($id);

        $detail = $request->get('description');
        libxml_use_internal_errors(true);

        $dom = new \DomDocument();

        $dom->loadHtml($detail, LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD);  
          

        $images = $dom->getElementsByTagName('img');

        foreach($images as $k => $img){

            $data = $img->getAttribute('src');

            list($type, $data) = explode(';', $data);

            list(, $data)      = explode(',', $data);

            $data = base64_decode($data);

            $image_name= "/upload/" . time().$k.'.png';

            $path = public_path() . $image_name;

            file_put_contents($path, $data);

            $img->removeAttribute('src');

            $img->setAttribute('src', $image_name);

        }

        $detail = $dom->saveHTML();
        $service->description = $dom->saveHTML();
        $service->name = $request->get('name');
        $service->save();

Any help would be hightly appreciate

Apr
30
5 months ago
Activity icon

Started a new Conversation Can We Get Free Google Map Api Key For Testing

Hi, can we get a free Google map API key for testing? My google map is not loaded. it gives me the error

This page can't load Google Maps correctly.```


<script src="https://maps.googleapis.com/maps/api/js?key=&libraries=places&callback=initialize" async defer></script>
Apr
23
5 months ago
Activity icon

Started a new Conversation Unable To Display Image In Vue Component Form Storage Of Laravel

Hi developers, I am unable to display the image in vue component from the Storage directory of Laravel. Please help me to solve this issue:

images are stored in DB as public/avatar/TSD50oeYXnkrX1nQ38N9zljP1FRdP42yPhJOrEKg.png

if I remove public path and do this <img :src="'../storage/avatar/31deG4gnbO3EwO2s26lnUe0KzJjskFfm8lPIGFeM.jpeg'" width="100">

i can see image diplayed in vue component from storage/public/avatar folder

method to get details of single user


public function user($id){
		return $user = User::find($id);
	}

methods to save image


public function profilePic(Request $request){
		$this->validate($request,[
			'image'=>'required|mimes:jpeg,jpg,png'
		]);
		$image = $request->image->store('public/avatar');
		$authUser = auth()->user()->id;
		$user = User::where('id',$authUser)->update([
			'profilePic'=> $image
		]);
		return redirect()->back();
	}

vue:



<template>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-header">Profile Component</div>

			{{user.profilePic}}
//how can i display image here
 			

<div class="card-body">
                        <form @submit.prevent="updateProfilePic" method="post" enctype="multipart/form-data">
                            <input type="file" name="image" class="form-control"v-on:change="onImageChange">
                            <button type="submit" class="btn btn-primary">Submit</button>

                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        props:['userid'],
        data(){
            return{
                image:'',
                user:[]

            }
        },
        mounted() {
            this.getUser()
            console.log('Component mounted.')
        },
        methods:{
            onImageChange(e){
                console.log(e)
                this.image = e.target.files[0];
                
                },
            updateProfilePic(){
                const config={
                    headers:{
                        "content-type":"multipart/form-data"
                    }
                }
                let formData = new FormData();
                formData.append('image',this.image);
             
                axios.post('/profile-pic',formData,config).then((response)=>{
                    this.image='';
                    this.getUser()
                   
                   

                }).catch((error)=>{
                    console.log(error)
                    this.allerrors = error.response.data.errors
                })
            },
            getUser(){
                axios.get('/user/'+this.userid).then((response)=>{
                    this.user = response.data
                }).catch((error)=>{
                    alert('some error')
                })
            },
        }
    }
</script>
Activity icon

Replied to How To Send Multiple Attachment In Laravel

Updated

@amaury , Thankyou for a reply. I am wondering how to get the dynamic path here. Each time user send email with different files. He will browse the file from his computer, will be stored in a public folder directory and path in db.


->attach('/path/to/another/file')
->attach('/path/to/a/third/file');

Thanks

Apr
22
5 months ago
Activity icon

Started a new Conversation How To Send Multiple Attachment In Laravel

Hi, I am able to send mail to the user email. However i don't know how to send multiple attachments(images/pdf/docs). Any help would be appreciated. I am using laravel 7 method:

public function mailsend(Request $request)
	{
		if($request->hasFile('file')){
            $image = $request->file->hashName();
            $request->image->move(public_path('profile'),$image);
        }
		$details = [
            'body' => $request->body];

			$people = User::get();
			foreach($people as $p){
				\Mail::to($p->email)
     			->send(new SendMail($details));
        	
			}
		}
		return redirect()->back();
    }

sendmail.php

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class SendMail extends Mailable
{
    use Queueable, SerializesModels;
    public $details;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($details)
    {
        $this->details = $details;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Mail from Real Programmer')
                    ->view('admin.emails.sendmail')
                   ;
    }
}

sendmail.blade.php

<!DOCTYPE html>
<html>
<head>
    
</head>
<body>
    <h1></h1>
    <p>{{ $details['body'] }}</p>
    <p>Thank you</p>
</body>
</html>

form

<form action="" method="post" enctype="multipart/form-data">@csrf

    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">General Information</div>
                <div class="card-body">
                    <div class="form-group">
                
                    
                    <div id="person">

                        <select name="person" class="form-control">
                            <option value="">select</option>
                            @foreach(App\User::all() as $user)
                                <option value="{{$user->id}}">{{$user->name}}</option>
                            @endforeach
                        </select>
                    </div>
                        
                    </div>
                    <input type="file" name="file[]">
                    <div class="form-group">
                        <textarea name="body" class="form-control"></textarea>
                    </div>
                    
            <br>
            <div class="form-group">
                <button class="btn btn-primary " type="submit">Submit</button>
            </div>
        </div>
      
    </div>
</form>