GrahamMorbyDev

GrahamMorbyDev

Member Since 2 Years Ago

Portsmouth

Full Stack PHP Developer at Freelance

Experience Points 15,760
Experience Level 4

4,240 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 103
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

04 Jan
5 months ago

GrahamMorbyDev left a reply on Filter Multiple Columns Vue

@HFALUCAS - works perfectly thank you

GrahamMorbyDev left a reply on Filter Multiple Columns Vue

@HFALUCAS - I get

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined

03 Jan
5 months ago

GrahamMorbyDev started a new conversation Filter Multiple Columns Vue

Hey Guys

I have a search that works right now and wanted to search multiple keys in an array.

I have a standard form that takes a keyword

its then hits this function:

searchResults() {
      const search = this.bets.filter(bet => {
        return bet.username.toLowerCase() === this.searchTable;
      });
      this.bets = search;
    }

So in this case im searching username, but id like to add more columns

I have tried

searchResults() {
      const search = this.bets.filter(bet => {
        return bet.username.toLowerCase() || bet.bet_id.toLowerCase === this.searchTable;
      });
      this.bets = search;
    }

Any help would be welcomed

03 Dec
6 months ago

GrahamMorbyDev started a new conversation 'vue-cli-service' Is Not Recognized As An Internal Or External Command, Operable Program Or Batch File.

Im trying to set up a windows environment with the cli but when I hit

npm run serve

I get the following error

'vue-cli-service' is not recognized as an internal or external command, operable program or batch file.

node and npm are both upto date

08 Nov
7 months ago

GrahamMorbyDev left a reply on Adding A / To A Concat String

Awesome ill give it a go

GrahamMorbyDev left a reply on Adding A / To A Concat String

Im trying to build a quick fix search box for someone

 foreach ($dmcas as $key => $dmca) {

                    $output .= '<tr>' .
                        
                        '<td>' . $dmca->id . '</td>' .

                        '<td>' . $dmca->company . '</td>' .

                        '<td>' . $dmca->client . '</td>' .

                        '<td>' . $dmca->created_at . '</td>' .
                        '<td>'.  
                            '<form action="{{url("/view/dmca")}}" method="post">' .
                                '<input type="hidden" name="_token" id="csrf-token" value="{{ Session::token() }}" />'.
                                '<input type="hidden" name="id" id="id" value="' . $dmca->id .'">'.
                                '<button type="submit" class="btn btn-sm btn-success">View</button>'.
                            '</form>'.
                        '</td>'.
                        '</tr>';

                }

Its horrible but its a proof of concept

GrahamMorbyDev left a reply on Adding A / To A Concat String

@CRONIX - this string

'<form action="{{url("/view/dmca")}}" method="post">' .

outputs to

No / in the output so I need to get the / in the output

GrahamMorbyDev left a reply on Adding A / To A String

Its for a live search, i need it to output that when the search happens but the / is outputting

GrahamMorbyDev started a new conversation Adding A / To A String

Hey guys

I'm trying to output a string like so

'<form action="{{URL::asset("' . "/" . 'view' . "/" .'dmca' . '")}}" method="post">' .

but the / are not coming out any ideas??

29 Oct
7 months ago

GrahamMorbyDev started a new conversation "TypeError: Cannot Read Property 'bets' Of Undefined"

A Question, I have a prop which contains an object that is outputting to the view fine but have a console error which reads

vue.runtime.esm.js?2b0e:587 [Vue warn]: Error in render: "TypeError: Cannot read property 'bets' of undefined"```

and 

Cannot read property 'bets' of undefined


My question is why do I have this error yet the data is outputting?

My Component looks like 

  • Bets: {{stats.bets}}
  • Won/Lost: {{stats.wins}} / {{stats.lost}}
  • Wagered: {{stats.wagered}}
  • Profit: {{stats.profit}}

export default { props: { stats: Object }, data() { return{

    }
},
methods: {}

}

```
11 Oct
8 months ago

GrahamMorbyDev left a reply on "message": "SQLSTATE[23000]: Integrity Constraint Violation: 1062 Duplicate Entry '' For Key 'users_email_unique'

I don't get why it's trying to update the email?? I'm simply asking it to log in and create a token?? Or did I do something wrong

GrahamMorbyDev started a new conversation "message": "SQLSTATE[23000]: Integrity Constraint Violation: 1062 Duplicate Entry '' For Key 'users_email_unique'

Hey so I have a login module that is suddenly giving me an error

"message": "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'users_email_unique' (SQL: insert into `users` (`updated_at`, `created_at`) values (2018-10-11 13:17:54, 2018-10-11 13:17:54))",

the login code looks like

 //The createToken method is one of the methods Laravel Passport adds to the user model.
    public function login(Request $request) {

        if(Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('password')])) {
            $status = 200;
            $response = [
                'user' => Auth::user(),
                'token' => Auth::user()->create(['bigStore'])->accessToken,
            ];
        return response()->json($response, $status);
        }else {
            $status = 401;
            $response = ['error' => 'Unauthorised'];
            return response()->json($response, $status);
        }

    }

and the front end is

handleSubmit(e) {
                e.preventDefault();
                if (this.password.length > 0) {
                    let email = this.email;
                    let password = this.password;

                    axios.post('api/login', {email, password}).then(response => {
                        let user = response.data.user;
                        let is_admin = user.is_admin;

                        localStorage.setItem('bigStore.user', JSON.stringify(user));
                        localStorage.setItem('bigStore.jwt', response.data.token);

                        if (localStorage.getItem('bigStore.jwt') != null) {
                            this.$emit('loggedIn');
                            if (this.$route.params.nextUrl != null) {
                                this.$router.push(this.$route.params.nextUrl)
                            } else {
                                this.$router.push((is_admin === 1 ? 'admin' : 'dashboard'))
                            }
                        }
                    });
                }
            }
17 Sep
9 months ago

GrahamMorbyDev left a reply on The File "/home/forge/default/public/storage/app/videos/testingvideo12.mp4" Does Not Exist

of course, The videos are storing as

 //Validate the Video
        $this->validateVideo($request);

        //Image
        $imagepath = $request->file('featuredimage')->store('videoimages');

        $title = $request->get('title') . ".mp4";

        //Video
        $videopath = $request->file('filename')->storeAs('videos', $title);

        //Open Video Model
        $video = new Video();

        //Video Params
        $video->title = $request->get('title');
        $video->description = $request->get('description');
        $video->featuredimage = $imagepath;
        $video->filename = $videopath;
        $video->storeId = $request->get('storeId');
        $video->filesize = $request->get('filesize');

        //Save Video
        $video->save();

        //Return Statement
        return 200;

GrahamMorbyDev started a new conversation The File "/home/forge/default/public/storage/app/videos/testingvideo12.mp4" Does Not Exist

I have an API that's uploading and downloading videos and I have the issue in the title.

The file exists and as I uploaded it yet it's saying its not there

Code is :

$get = new Transaction();
        $get = $get->where('salesId', $request->get('salesId'))->firstOrFail();

        if($get->downloadAttempts <= 3) {
            $filename = $request->get('filename');
            $filePath = public_path('storage/app/videos/' . $filename);
            return response()->download($filePath, $request->get('filename'));
        }else {
            return 403;
        }

The filename matches the stored one in the post to get the file

Thanks in advance

GrahamMorbyDev started a new conversation Issue With File Download For An API

Hey folks,

First time I have tried this so working through the issues. So I have a get request that has params being sent.

Download Controller

//Download Video
    public function Download(Request $request) {
        $download = new Transaction();
        $download = $download->where('salesId', $request->get('salesId'))->increment('downloadAttempts');


        $get = new Transaction();
        $get = $get->where('salesId', $request->get('salesId'))->get();

        if($get->downloadAttempts <= 3) {
            $filename = $request->get('filename');
            $filePath = public_path('storage/' . $filename);
            return response()->download($filePath, $request->get('filename'));
        }else {
            return 403;
        }
    }

So it gets the sales ID and updates the download attempts by 1 and then checks if the attempts are less than 3 and allow the download.

and I'm getting an error of

Property [downloadAttempts] does not exist on this collection instance.

06 Sep
9 months ago

GrahamMorbyDev started a new conversation Laravel Cashier - No Such Token

Hey I'm trying to set up laravel cashier and getting an error of

No such token:

My Form looks like

<div class="col-md-12">
            <form action="/subscribe_process" method="POST">
                <script
                        src="https://checkout.stripe.com/checkout.js" class="stripe-button"
                        data-key="{{ env('STRIPE_PUBLISHABLE_SECRET') }}"
                        data-amount="1999"
                        data-name="Retro Gamer Crate"
                        data-description="Online course about integrating Stripe"
                        data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
                        data-locale="auto"
                        data-currency="usd">
                </script>
            </form>
        </div>

and my controller like so

public function subscribe_process(Request $request)
    {

        try {
            Stripe::setApiKey(env('STRIPE_SECRET'));

            $user = User::find(3);

            $customer = Customer::create(array(
                'email' => $request->stripeEmail,
                'source' => $request->stripeToken
            ));

            $user->newSubscription('retrogamercrate', 'prod_DYZ07fQJTO3F4J')->create($request->stripeToken);

            return 'Subscription successful, you get the course!';
        }
        catch (\Exception $ex) {
            return $ex->getMessage();
        }

    }

I have set the plan up in stripe on test data

28 Aug
9 months ago

GrahamMorbyDev left a reply on Undefined Property: StdClass::$cover

my Controller looks like

 //Coming Soon
    public function comingsoon() {
        $game = IGDB::searchGames('fallout');
        $game  = json_decode($game, true);
        //dd($game);
        return view('comingsoon', compact('game'));
    }

GrahamMorbyDev left a reply on Undefined Property: StdClass::$cover

So I did as suggested and get

json_decode() expects parameter 1 to be string, array given

GrahamMorbyDev started a new conversation Undefined Property: StdClass::$cover

I have a json object that contains 10 results and I want to loop through and display the data to the user

a example looks like this:

9 => {#670 ▼
    +"id": 10300
    +"name": "Fallout 3: Mothership Zeta"
    +"slug": "fallout-3-mothership-zeta"
    +"url": "https://www.igdb.com/games/fallout-3-mothership-zeta"
    +"created_at": 1431649834920
    +"updated_at": 1532126985619
    +"summary": "Defy hostile alien abductors and fight your way off of the massive Mothership Zeta, orbiting Earth miles above the Capital Wasteland. Mothership Zeta takes Fall ▶"
    +"collection": 3
    +"rating": 77.763623864376
    +"popularity": 1.3333333333333
    +"total_rating": 77.763623864376
    +"total_rating_count": 29
    +"rating_count": 29
    +"game": 15
    +"games": array:10 [▶]
    +"tags": array:4 [▶]
    +"developers": array:1 [▶]
    +"publishers": array:1 [▶]
    +"category": 1
    +"player_perspectives": array:1 [▶]
    +"game_modes": array:1 [▶]
    +"themes": array:1 [▶]
    +"genres": array:2 [▶]
    +"first_release_date": 1249257600000
    +"platforms": array:3 [▶]
    +"release_dates": array:3 [▶]
    +"screenshots": array:7 [▶]
    +"cover": {#681 ▼
      +"url": "//images.igdb.com/igdb/image/upload/t_thumb/btawsi7cbgcmqlw67tpn.jpg"
      +"cloudinary_id": "btawsi7cbgcmqlw67tpn"
      +"width": 1061
      +"height": 1158
    }
  }

So I do a foreach loop and put

  @foreach($game as $games)
            <div class="col-md-2">
                <img src="" alt="">
                <p>{{$games->name}}</p>
                <p>{{$games->cover->url}}</p>
            </div>
        @endforeach         

And get the error

Undefined property: stdClass::$cover

I am trying to loop through 10 objects the one above is just an example of one of those objects

23 Aug
9 months ago

GrahamMorbyDev started a new conversation Custom Login Route Error With Passport And Vue.Js

So I have a front end Vue connecting to a Laravel backend with Passport

I have a custom Login Controller which looks like so

//Authenticates a user and generates an access token for that user.
    //The createToken method is one of the methods Laravel Passport adds to the user model.
    public function login(Request $request) {
        $status = 401;
        $response = ['error' => 'Unauthorised'];

        if(Auth::attempt($request->only('email', 'password'))) {
            $status = 200;
            $response = [
                'user' => Auth::user(),
                'token' => Auth::user()->create('bigstore')->accessToken,
            ];
        }

        return response()->json($response, $status);
    }

then on the login it looks like

methods: {
            handleSubmit(e) {
                e.preventDefault()
                if (this.password.length > 0) {
                    let email = this.email
                    let password = this.password

                    axios.post('api/login', {email, password}).then(response => {
                        let user = response.data.user
                        let is_admin = user.is_admin

                        localStorage.setItem('bigStore.user', JSON.stringify(user))
                        localStorage.setItem('bigStore.jwt', response.data.token)

                        if (localStorage.getItem('bigStore.jwt') != null) {
                            this.$emit('loggedIn')
                            if (this.$route.params.nextUrl != null) {
                                this.$router.push(this.$route.params.nextUrl)
                            } else {
                                this.$router.push((is_admin == 1 ? 'admin' : 'dashboard'))
                            }
                        }
                    });
                }
            }
        }

and I get this error

"message": "Argument 1 passed to Illuminate\Database\Eloquent\Builder::create() must be of the type array, string given, called in /Users/grahammorby-raybould/sites/peach/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 1570",
12 Aug
10 months ago

GrahamMorbyDev started a new conversation Bootstrap Vue Models

Hey Folks

Here is a question: I have started to build a Vue Js store, Using Laravel on the back end. I have installed Bootstrap Vue to use its models and loaded it into the page but it's showing up behind everything. The only way I know its there is by doing Inspect Element and hunting for it. Any help would be wonderful, or a different way of doing it? Open to all as I'm learning this stuff:

<template>
    <div>
    <div>
        <b-modal ref="myModalRef" hide-footer title="Using Component Methods">
            Hello From Modal!
        </b-modal>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="col-md-4">
                    <h3>Welcome To Our Store</h3>
                </div>
                <div class="col-md-4"></div>
                <div class="col-md-4">
                    <a href="#" class="btn btn-sm btn-success pull-right">View Cart</a>
                </div>
            </div>
        </div>
        <div class="row justify-content-center">
            <div class="col-md-12">
                <div v-for="infos in info">
                    <div class="col-md-4">
                        <div class="product-item">
                            <div class="pi-img-wrapper">
                                <img src="http://keenthemes.com/assets/bootsnipp/k1.jpg" class="img-responsive"
                                     alt="Berry Lace Dress">
                                <div>
                                    <a href="#" class="btn">Zoom</a>
                                    <a @click="showModal()" class="btn">View</a>
                                </div>
                            </div>
                            <h3><a href="#">{{infos.title}}</a></h3>
                            <div class="pi-price">${{infos.price}}</div>
                            <a href="javascript:" class="btn add2cart">Add to cart</a>
                            <div class="sticker sticker-new"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
</template>

<script>

    import BootstrapVue from 'bootstrap-vue'
    import bModal from 'bootstrap-vue/es/components/modal/modal'
    Vue.use(BootstrapVue);

    export default {
        components: {
            bModal,
        },
        data() {
            return {
                info: [],
                modalShow: false
            }
        },
        mounted() {
            console.log('Component mounted.');
            axios.get('/store/get/products')
                .then(response => (this.info = response.data)).catch(error => console.log(error))
        },
        methods: {
            showModal () {
                this.$refs.myModalRef.show();
                console.log('here');
            },
            hideModal () {
                this.$refs.myModalRef.hide()
            }},
    }
</script>

Thanks Again

07 Jul
11 months ago

GrahamMorbyDev started a new conversation Vue Parallax Ontop Of Parallax

So here is a question and I'm not really sure how to do it.

I have a parallax image background and I want to load ahead tag on top to have both move away at different speeds.

So the image will be the background and the text the foreground but both have parallax

<parallax :parallax="true" :direction="up" :containerClass="mainHead" :speedFactor="1">
        <img src="img/header.jpg" alt="Welcome to butterfly software developments" height="600px"/>
        <h1>Lipsum Text</h1>
    </parallax>

That's my code

and the package I'm using is

https://github.com/apertureless/vue-parallax

Thanks

02 Jul
11 months ago

GrahamMorbyDev left a reply on Error On Templating

Perfect, the one thing I never tried!

GrahamMorbyDev started a new conversation Error On Templating

So I have a strange one that has never happened before

I have a template file that looks like:

<template>

        <parallax><img src="img/header.jpg" alt="Welcome to butterfly software developments"/></parallax>

</template>
<script>
    import Parallax from 'vue-parallaxy'
    export default {
        components: {
            Parallax
        }
    }
</script>

Now if I place any more HTML or code under the tags and within the tags I get the following error

ERROR in ./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-3e2113e2","hasScoped":false,"buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./resources/assets/js/views/Hello.vue
(Emitted value instead of an instance of Error) 
  Error compiling template:
  
      <parallax>
          <img src="img/header.jpg" alt="Welcome to butterfly software developments">
      </parallax>
  dfgdfgsdf
  
  - text "dfgdfgsdf" outside root element will be ignored.

 @ ./resources/assets/js/views/Hello.vue 6:23-261
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

Any help woiuld be great

19 Jun
11 months ago

GrahamMorbyDev left a reply on Server IP Address Could Not Be Found.

one of the domains was actually already live I just moved server, its strange

GrahamMorbyDev left a reply on Server IP Address Could Not Be Found.

I did indeed

both have A records

GrahamMorbyDev started a new conversation Server IP Address Could Not Be Found.

So I have an issue im not really sure what to do with

I have set up new apps on each of my servers using the domain name, deleted the default app. Set up domains in digital ocean to push to the correct droplets and set up my nameservers on my domains.

But getting the error server IP address could not be found.

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/watermelon.solutions/before/*;

server {
    listen 80;
    listen [::]:80;
    server_name watermelon.solutions;
    root /home/forge/watermelon.solutions/public;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DO NOT REMOVE!)
    include forge-conf/watermelon.solutions/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/watermelon.solutions-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/watermelon.solutions/after/*;

and name servers are normal

ns1.digitalocean.com etc ete

25 May
1 year ago

GrahamMorbyDev left a reply on Getting Data Range

man I couldnt see it! Thanks

GrahamMorbyDev left a reply on Getting Data Range

sorry yeah

$today = Carbon::now(); $lastWeek = Carbon::now()->subDays(7);

GrahamMorbyDev started a new conversation Getting Data Range

So I'm trying to get data within a 7-day date range

The data exists but I have no returning results

    $sageWorkers = DB::table('workers')
                         ->leftJoin('assign_worker_contracts', 'workers.id', '=', 'assign_worker_contracts.worker_id')
                         ->where('assign_worker_contracts.created_at', '=>' , $lastWeek)->where('assign_worker_contracts.created_at', '<=', $today)
                         ->get();

I'm sure I'm missing something easy but I have been staring at it for some time now

24 May
1 year ago

GrahamMorbyDev left a reply on Where Clause Is Ambiguous

Perfect thank you! Right in front of me!

GrahamMorbyDev started a new conversation Where Clause Is Ambiguous

Trying to get some data that sits between a 7 day period

DB::table('workers')
                         ->leftJoin('assign_worker_contracts', 'workers.id', '=', 'assign_worker_contracts.worker_id')
                         ->where('created_at', '>=' , $today)->where('created_at', '<=', $lastWeek)
                         ->get();

1052 Column 'created_at' in where clause is ambiguous is the error it spits at me

Any ideas? Never had this one before

18 May
1 year ago

GrahamMorbyDev left a reply on Return Foreach Loop

I get a Undefined variable: messages on the call

GrahamMorbyDev started a new conversation Return Foreach Loop

Hey folks, using a package to get some emails from GMail need to return the results as really an object but an array will work.

So far I'm here :

  //Testing get messages
    public function getMailbox() {
        $messages = LaravelGmail::message()->unread()->preload()->all();
        foreach($messages as $message) {
            $id = $message->getId();
            $date = $message->getDate();
            $from = $message->getFromEmail();
            $email = $message->getPlainTextBody();
        }
        return compact(array('email', 'date', 'from', 'id'));
    }

All I get is one result and there should be four

any ideas

15 May
1 year ago

GrahamMorbyDev left a reply on Socialite Hitting 404 Page

Yep changed that and still a 404

GrahamMorbyDev started a new conversation Socialite Hitting 404 Page

Hey new to this feature and I'm almost there but need to be steered int he right direction

So I have made Auth and have the login controller :

To which i have built in the following:

public function socialLogin($social) {
        return Socialite::driver($social)->redirect();
    }

    public function handleProviderCallback($social) {
        $userSocial = Socialite::driver($social)->user();
        $user = User::where(['email' => $userSocial->getEmail()])->first();

        if($user) {
            Auth::login($user);
            return redirect()->action('[email protected]');
        } else {
            return view('auth.register', ['name' => $userSocial->getName(),
                                                'email' => $userSocial->getEmail()]);

        }
    }

These two functions are controlled by the following routes:

Route::get('login/{social}', 'Auth\[email protected]')
            ->where('social','twitter|facebook|linkedin|google|github');
Route::get('login/{social/callback}', 'Auth\[email protected]')
            ->where('social','twitter|facebook|linkedin|google|github');

And i hit the link below:

<a href="{{ url('/login/twitter') }}" class="btn btn-twitter"><i class="fa fa-twitter"></i> Twitter</a>

The redirect URL is :

TWITTER_URL=http://localhost:8888/twitter/callback

Which I have added to the APP on the twitter console

And im getting a 404 on return from twitter

10 May
1 year ago

GrahamMorbyDev left a reply on PHP-imap Get All Mail

I think i was confusing how I return the data cause the app is using Vue on the front end and using axios requests to get the response

Simply couldn't see the wood from the trees!

GrahamMorbyDev left a reply on PHP-imap Get All Mail

yeah im getting there I moved on a bit now , Thanks again for your help buddy

GrahamMorbyDev left a reply on PHP-imap Get All Mail

Kinda wish id just giving them google mail in the browser lol

Im currently here

 //Get all mail
    public function GetMail() {

        $mail = new Imap(array(
            'host' => 'imap.gmail.com',
            'user' => '[email protected]',
            'password' => 'kimi07Ferrari',
            'ssl' => 'ssl',
            'port' => 993
        ));

        $mail->countMessages();
        $content = array([ ]);
        foreach ($mail as $messageNum => $message) {
            $content = array([
               'from' => $message->from,
                'subject' =>$message->subject
            ]);
        }
        return $content;
    }

Here is where I'm lost what is the id returned ie $message-> id, cause that doesn't exist and also why am I only getting one message

Sorry for so many questions and really do appreciate your help

GrahamMorbyDev left a reply on PHP-imap Get All Mail

One last question @Nash , any ideas how to return all messages as an object and not just the count ?

GrahamMorbyDev left a reply on PHP-imap Get All Mail

That worked! Thank you very much , now I need to play to get stuff out!

GrahamMorbyDev left a reply on PHP-imap Get All Mail

I have indeed ,

 public function GetMail() {

        $mail = new Imap(array('host'     => 'imap.gmail.com',
            'user'     => '[email protected]',
            'port'     => '993',
            'password' => '********',
            'ssl'      => 'tls',
            'auth'     => 'login'
        ));

        echo $mail->countMessages() . " messages found\n";
        foreach ($mail as $message) {
            printf("Mail from '%s': %s\n", $message->from, $message->subject);
        }
    }

GrahamMorbyDev left a reply on PHP-imap Get All Mail

Totally just getting this 'cannot read - connection closed? ' at the moment

GrahamMorbyDev left a reply on PHP-imap Get All Mail

Do you have much experience with the above?

GrahamMorbyDev started a new conversation PHP-imap Get All Mail

Hi Guys

Another question on Email. I m using php-imap package to get all mail from a Gmail account.

Now I can get a single message but what I'm struggling to do is get all mail at once

public function GetMail() {
        $mailbox = new PhpImap\Mailbox('{imap.gmail.com:993/imap/ssl}INBOX', '[email protected]', 'password', __DIR__);
        // Read all messaged into an array:
        $mailsIds = $mailbox->searchMailbox('ALL');
        if(!$mailsIds) {
            return ('Mailbox is empty');
        }
        // Get the first message and save its attachment(s) to disk:
        $mail = $mailbox->getMail($mailsIds[1]);
        dd($mail);
    }

if I remove the [1] I get the error of 'cant get property of non-object'

The docs are pretty slim to be honest so just wondering if anyone has any experience with the package and have managed to do what I'm trying to do

09 May
1 year ago

GrahamMorbyDev left a reply on Use Of Undefined Constant STDIN - Assumed 'STDIN' Issue

Yeah Tired that and I get

fgets() expects parameter 1 to be resource, string given

GrahamMorbyDev started a new conversation Use Of Undefined Constant STDIN - Assumed 'STDIN' Issue

I'm trying to work with Google's Gmail API to get and send emails

I'm using there Quickstart PHP example and I'm getting a issue here

$authCode = trim(fgets(STDIN)); 

Which errors: Use of undefined constant STDIN - assumed 'STDIN'

The full script looks like so:

  $client = new Google_Client();
        $client->setApplicationName('Gmail API PHP Quickstart');
        $client->setScopes(Google_Service_Gmail::GMAIL_READONLY);
        $client->setAuthConfig(public_path('/gmail/client_secret.json'));
        $client->setAccessType('offline');

        // Load previously authorized credentials from a file.
        $credentialsPath = public_path('/gmail/credentials.json');
        if (file_exists($credentialsPath)) {
            $accessToken = json_decode(file_get_contents($credentialsPath), true);
        } else {
            // Request authorization from the user.
            $authUrl = $client->createAuthUrl();
            printf("Open the following link in your browser:\n%s\n", $authUrl);
            print 'Enter verification code: ';
            $authCode = trim(fgets(STDIN));

            // Exchange authorization code for an access token.
            $accessToken = $client->fetchAccessTokenWithAuthCode($authCode);

            // Store the credentials to disk.
            if (!file_exists(dirname($credentialsPath))) {
                mkdir(dirname($credentialsPath), 0700, true);
            }
            file_put_contents($credentialsPath, json_encode($accessToken));
            printf("Credentials saved to %s\n", $credentialsPath);
        }
        $client->setAccessToken($accessToken);

        // Refresh the token if it's expired.
        if ($client->isAccessTokenExpired()) {
            $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
            file_put_contents($credentialsPath, json_encode($client->getAccessToken()));
        }
        return $client;

Any help would be greatly appreciated

GrahamMorbyDev left a reply on SSL For Multiple Domains Variations

Worked perfectly thank you!!

08 May
1 year ago

GrahamMorbyDev started a new conversation SSL For Multiple Domains Variations

Hey Folks

I have a domain that has an SSL via forge which is on working fine on a

example.com

But I need it to work also for

www.example.com

At the moment I get the non-secure warning for the www.

Anyone have any ideas