Lordgreymaul

Full Stack PHP Developer at Lendy.co.uk

Experience

11,480

0 Best Reply Awards

  • Member Since 1 Year Ago
  • 82 Lessons Completed
  • 0 Favorites

21st September, 2017

Lordgreymaul left a reply on Displaying AJAX Response • 23 hours ago

So a little bit of an update

I changed the controller to

public function searching() {
        $search_keyword = $_POST['search_keyword'];
        $searchClients = DB::table('clients')->where('company', 'like', '%'.$search_keyword.'%')->get();

        return response()->json($searchClients);

    }

Which is now providing results, just need to work out populating the screen

20th September, 2017

Lordgreymaul started a new conversation Displaying AJAX Response • 1 day ago

Hey Guys

So I have a 'Live Search' form Im working on and all returns are coming in ok with 200 codes but im getting no front end updates!

Front end

<div class="col-md-6 col-md-offset-3">
                <form action="/clientsearchresults" method="post">
                    <div class="form-group">
                        {{ csrf_field() }}
                        <label for="search">Search</label>
                        <input type="text" class="search_keyword" id="search" name="search" class="form-control" placeholder="Enter Clients Name">
                    </div>
                </form>

                <div id="result">

                </div>
            </div>

JS

$(".search_keyword").keyup(function () {
    var search_keyword_value = $(this).val();
    var dataString = 'search_keyword=' + search_keyword_value;
    if(search_keyword_value != '') {
        $.ajax({
            type: "POST",
            url: "/searching",
            data: dataString,
            cache: false,
            headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
            success: function (html) {
                $("#result").html(html).show();
            },
            error: function () {
                alert('Not Okay');
            }
        });
    }
    return false;
});
$("#result").on("click", function (e) {
    console.log('Im Here');
    var $clicked = $(e.target);
    if (e.target.nodeName == "STRONG")
        $clicked = $(e.target).parent().parent();
    else if (e.target.nodeName == "SPAN")
        $clicked = $(e.target).parent();
    var $name = $clicked.find('.name').html();
    var decoded = $("<div/>").html($name).text();
    $('#search_keyword_id').val(decoded);
});

$(document).on("click", function (e) {
    var $clicked = $(e.target);
    if (!$clicked.hasClass("search_keyword")) {
        $("#result").fadeOut();
    }
});

$('#search_keyword_id').click(function () {
    $("#result").fadeIn();
});

and the controller

// Live Search
    public function searching() {
        $search_keyword = $_POST['search_keyword'];
        $searchClients = DB::table('clients')->where('company', $search_keyword)->get();

        $bold_search_keyword = '<strong>' . $search_keyword . '</strong>';

        if($searchClients) {
            foreach ($searchClients as $rows) {
                echo '<div class="show" align="left"><span class="name">' . str_ireplace
                    ($search_keyword, $bold_search_keyword, $rows['company']) . '</span></div>';
            }
        }
    }

Have no errors what so ever but simply have no display on typing

18th September, 2017

Lordgreymaul left a reply on Loading Vue Into 5.5 • 4 days ago

I actually ran php artisan make:auth and it all fired into place! No idea what I did wrong or why in never worked but its working fine now

15th September, 2017

Lordgreymaul left a reply on Loading Vue Into 5.5 • 1 week ago

So I have tried that

<div id="app">
                    <Example></Example>
                </div>

I have added the script still at the bottom

Node modules contains Vue as does my package.json and still nothing

Vue Dev tools isnt picking it up either

14th September, 2017

Lordgreymaul started a new conversation Loading Vue Into 5.5 • 1 week ago

Hey Guys

So I always used to bring Vue in via a CDN or some otherway and now I understand VUE is in webpack with 5.5.

So I have npm run watch and compiled

my Vue code is

const app = new Vue({
    el: '#app',
    data: {
        message:'This is a note!'
    }
});

and I have added it to my front end along with my public/js/app.js compiled file

 <div id="app">
                    <p>{{ message }}</p>
                    <input type="text" v-model="message">
                </div>

<script href="{{URL::asset('js/app.js')}}"></script>

And get nothing and just the string output of message!? and Vue Dev tools isnt picking up a instance

I no im missing a step here just cant seem to find it

13th September, 2017

Lordgreymaul left a reply on Laravel Vs Plan PHP With No Framework • 1 week ago

I went the other way and Learnt Laravel before learning plain old PhP and having now worked in both environments! I always come back to Laravel , I mean always.

I have used Codeigniter, Phalcon and Zend also and Laravel wins for me hands down every time. Its simple to understand and offers so much in terms of speed and its written in a way that it some how understands what it is we do and how quick we need to do it.

Laravel made my transition from Front end to Back end a simple one, Hope that helps in any way

23rd July, 2017

Lordgreymaul left a reply on Getting A Single Item From List Of Data • 1 month ago

So the fix as it would seem is

Route::get('/members/video/{id}', 'MembersController@video');

Remove the dollar sign!

Lordgreymaul left a reply on Getting A Single Item From List Of Data • 1 month ago

updated function

public function video($id) {
        $video = DB::table('videos')->where()->first($id);
        return view('members/video', ['video' => $video]);
    }

Still same issue as above

Lordgreymaul left a reply on Getting A Single Item From List Of Data • 1 month ago

So the error is

URL comes out as http://localhost:8888/membership/public/members/video/10

NotFoundHttpException```

Lordgreymaul started a new conversation Getting A Single Item From List Of Data • 1 month ago

Hey guys

Been a while since I did this and got stuck, Im trying to click through to an item by id from a list

Route

Route::get('/members/video/{$id}', 'MembersController@video');

Controller

 public function video($id) {
        $video = DB::table('videos')->where('id' , $id)->find();
        return view('members/video', ['video' => $video]);
    }

View

<a href="{{URL::asset('members/video/' . $video->id)}}" class="btn btn-success">Watch Now</a>

Thanks in advance guys

3rd July, 2017

Lordgreymaul started a new conversation Null Values From API In Vue • 2 months ago

Hey Guys

Have an issue i havent seen before , so grabbing data via an API and trying to output via Vue and getting an error in Vue of :

TypeError: Cannot read property 'reference' of null

Any one have any idea how to get around this?

Thanks

21st June, 2017

Lordgreymaul started a new conversation Issue With Vue • 3 months ago

Hey Guys

So im learning vue and have an issue where its not picking up my added array data and only giving me flat {{}} text in the html

Its a basic bulletin board type thing I'm building

Please check out this codepen and you will see what my error is straight away

https://codepen.io/GrahamMorbyDev/pen/yXbQBx

Thanks

19th April, 2017

Lordgreymaul left a reply on TokenMismatchException In VerifyCsrfToken.php Line 68: • 5 months ago

Within this form?

I added {{ csrf_field() }} to it and it threw me a new error so that seems legit

Thanks

Lordgreymaul started a new conversation TokenMismatchException In VerifyCsrfToken.php Line 68: • 5 months ago

So im playing with Cashier trying to set up a subscription form

form looks like

<div>
    <form action="/" method="POST">
       <script
                src="https://checkout.stripe.com/checkout.js" class="stripe-button"
                data-key="pk_test_ylThVfhN9BlO4pdm4evJTeWi"
                data-amount="2181"
                data-name="OG Pokemon"
                data-description="monthly UK"
                data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
                data-locale="auto"
                data-currency="gbp">
        </script>
    </form>
</div>

Posts to this route

Route::post('/', function() {
    $token = Input::get('stripeToken');
    Auth::user()->subscription('monthly')->create($token);
    return 'DONE';
});

and get this error

TokenMismatchException in VerifyCsrfToken.php line 68:

any ideas?

Thanks guys

6th April, 2017

Lordgreymaul left a reply on Router Controlling CSS And Images • 5 months ago

it was a HTaccess fix

Lordgreymaul started a new conversation Router Controlling CSS And Images • 5 months ago

Hey Guys

Been following along with the PHP series and hit a snag when I try and load images and style sheets.

so it looks like the router is looking for routes for everything

#0 /Users/Graham/Projects/OGPokedex/index.php(7): Router->direct('css/bootstrap.c...')
#1 {main}
  thrown in /Users/Graham/Projects/OGPokedex/core/Router.php on line 21
[06-Apr-2017 09:08:28 Europe/Berlin] PHP Fatal error:  Uncaught Exception: No route defined for this URI. in /Users/Graham/Projects/OGPokedex/core/Router.php:21
Stack trace:
#0 /Users/Graham/Projects/OGPokedex/index.php(7): Router->direct('css/bootstrap.c...')
#1 {main}
  thrown in /Users/Graham/Projects/OGPokedex/core/Router.php on line 21
[06-Apr-2017 09:08:28 Europe/Berlin] PHP Fatal error:  Uncaught Exception: No route defined for this URI. in /Users/Graham/Projects/OGPokedex/core/Router.php:21
Stack trace:
#0 /Users/Graham/Projects/OGPokedex/index.php(7): Router->direct('media/logo.png')
#1 {main}
  thrown in /Users/Graham/Projects/OGPokedex/core/Router.php on line 21
[06-Apr-2017 09:08:28 Europe/Berlin] PHP Fatal error:  Uncaught Exception: No route defined for this URI. in /Users/Graham/Projects/OGPokedex/core/Router.php:21
Stack trace:
#0 /Users/Graham/Projects/OGPokedex/index.php(7): Router->direct('js/bootstrap.mi...')
#1 {main}
  thrown in /Users/Graham/Projects/OGPokedex/core/Router.php on line 21

As you can see it cant loads routes for any of this

this is the router class

<?php

class Router {
    protected $routes = [];

    public static function load($file) {
        $router = new static;
        require $file;
        return $router;
    }

    public function define($routes){
        $this->routes = $routes;
    }

    public function direct($uri){
        if (array_key_exists($uri, $this->routes)){
            return $this->routes[$uri];
        }

        throw new Exception('No route defined for this URI.');
    }
}

and my routes look like this

<?php

$router->define([
    '' => 'controllers/index.php',
    'about' => 'controllers/about.php',
    'culture' => 'controllers/about-culture.php',
    'contact' => 'controllers/contact.php',
    'search' => 'controllers/search.php'
]);

Any help with this would be great

13th March, 2017

Lordgreymaul started a new conversation A Community Question • 6 months ago

Hey Guys

I'm after some advice and just a general picking people's brains. I want to build a streaming service, like Youtube Gaming and Twitch.

Im thinking Technology and what to build it in.

Any suggestions

Thanks

G

1st March, 2017

Lordgreymaul left a reply on Guzzle Error Connecting To Github API • 6 months ago

Thank you guys and I got it working a different way and its down to the Guzzle docs being a little different on 6.2

Lordgreymaul started a new conversation Guzzle Error Connecting To Github API • 6 months ago

Hey guys

Trying guzzle for the first time and have an issue with an error im getting

#0 /Users/Graham/Projects/zendesktest/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 /Users/Graham/Projects/zendesktest/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 /Users/Graham/Projects/zendesktest/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#3 /Users/Graham/Projects/zendesktest/vendor/guzzlehttp/guzzle/s in /Users/Graham/Projects/zendesktest/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 186

This is the error and here is the code

require_once 'vendor/autoload.php';
use GuzzleHttp\Client;


$client = new GuzzleHttp\Client([
    //Base URL
    'base_url' => 'https://api.github.com'
]);

$response = $client->get('user/lordgreymaul');

var_dump($response);

Hopefully easy fix

11th February, 2017

Lordgreymaul started a new conversation Issue Adding Deploying The Repo • 7 months ago

Hey guys

So set up a new server with digital ocean , added mariaDB etc , set up .ENV and connected to bitbucket

I get this error on deploy

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
Generating optimized class loader
Compiling common classes

                               
  [InvalidArgumentException]   
  Database [] not configured.  

Im sure its something simple but cant see where its wrong

22nd January, 2017

Lordgreymaul left a reply on TypeError: Elixir.ready Is Not A Function • 7 months ago

Ok updated my gulp file to

var elixir = require('laravel-elixir');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

elixir(function(mix) {
    mix.sass('app.scss');
});

and worked perfectly

Lordgreymaul left a reply on TypeError: Elixir.ready Is Not A Function • 7 months ago

Yep tired that already, I have Googled everything and nothing worked

Lordgreymaul left a reply on TypeError: Elixir.ready Is Not A Function • 7 months ago

var elixir = require('laravel-elixir');

require('laravel-elixir-vue-2');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

elixir(mix => {
    mix.sass('app.scss')
       .webpack('app.js');
});

Lordgreymaul started a new conversation TypeError: Elixir.ready Is Not A Function • 7 months ago

So I have this error on a project, trying to compile my SASS and its freaking out when i run Gulp in the Terminal

Running on Ubuntu(Not sure if this matters)

I have googled and tried everything

/var/www/html/padnellrover/node_modules/laravel-elixir-vue-2/index.js:3
Elixir.ready(function () {
       ^

TypeError: Elixir.ready is not a function
    at Object.<anonymous> (/var/www/html/padnellrover/node_modules/laravel-elixir-vue-2/index.js:3:8)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/var/www/html/padnellrover/gulpfile.js:3:1)
    at Module._compile (module.js:571:32)

Package.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.3.*"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.0",
        "symfony/css-selector": "3.1.*",
        "symfony/dom-crawler": "3.1.*"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

12th January, 2017

Lordgreymaul left a reply on Shuffle() Expects Parameter 1 To Be Array, Null Given • 8 months ago

yeah its not returning anything just that error

Lordgreymaul started a new conversation Shuffle() Expects Parameter 1 To Be Array, Null Given • 8 months ago

So this error keeps happening and Im not sure why and I havent looked at the project for an age

ErrorException in MarvelController.php line 49:
shuffle() expects parameter 1 to be array, null given

the error is on this else statement

else{
            $comics = Cache::get('comics');
            shuffle($comics);
            $comics = array_slice($comics, 0, 20);
        }

9th January, 2017

Lordgreymaul left a reply on Php Artisan Migrate , Windows PDO Exception Could Not Find Driver • 8 months ago

I have enabled it in the php.ini

;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll

Lordgreymaul left a reply on Php Artisan Migrate , Windows PDO Exception Could Not Find Driver • 8 months ago

the actual error is PDO Exception could not find driver ill try to install sqlsrv

Lordgreymaul started a new conversation Php Artisan Migrate , Windows PDO Exception Could Not Find Driver • 8 months ago

Does any one have any experience with this?

Using MAMP on windows 10 and get this error when Migrating to database on local host

3rd January, 2017

Lordgreymaul left a reply on Your Local Changes To The Following Files Would Be Overwritten By Merge • 8 months ago

Yah it was the fact I had the .env committing and not on git ignore. I just started my repo again and made sure the .env etc was on git ignore

21st December, 2016

Lordgreymaul left a reply on MethodNotAllowedHttpException • 9 months ago

From that question I got it

I had :Route::get('/contactorm' , 'HomeController@contact');

now changed to

Route::post('/contactorm' , 'HomeController@contact');

and works!

Lordgreymaul started a new conversation MethodNotAllowedHttpException • 9 months ago

Hey Guys

Trying to convert a flat php site to Laravel and hitting a snag on the Contact Form

So the error is : MethodNotAllowedHttpException

Controller:

public function contact(){
        $response = [
            'success' => false,
            'errors' => []
        ];
        $errors = [];

        // Validate form

        if (empty($_POST['name'])) {
            $errors['name'] = 'Your Name is required';
        }

        if (null === $_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) || '' === $_POST['email']) {
            $errors['email'] = 'Please enter a valid email address';
        }


        if (count($errors) == 0) {

            $emailSubject = 'Lendy Finance contact form request';
            $webmaster = 'lf-web-enquiry@lendyfinance.com';

            $name = $_POST['name'];
            $email = $_POST['email'];
            $company = $_POST['company'];
            $website = $_POST['website'];
            $message = $_POST['message'];

            $body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Company: $company<br>
Website: $website<br>
Message: $message <br>
EOD;
            $headers = "MIME-Version: 1.0" . "\r\n";
            $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
            $headers = "From: noreply@lendyfinance.com\r\n";
            $headers .= "Reply-To: $email\r\n";
            $headers .= "Return-Path: noreply@lendyfinance.com\r\n";
            $headers .= "Content-type: text/html\r\n";

            $res = mail($webmaster, $emailSubject, $body, $headers);

            if( !$res)
            {
                $errors['sys'] = "Unable to submit your enquiry, Please email us directly at enquiries@lendyfinance.com";
            }
            $response['success'] = $res;


        }
        $response['errors'] = $errors;

        echo json_encode($response);

    }

The view:

 {!! Form::open(['url' => '/contactorm']) !!}
                    <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                {!! Form::label('name' , 'Name') !!}
                                {!! Form::text('name', null , array('class' => 'form-control' , 'placeholder' => 'Enter Name')) !!}
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                {!! Form::label('email' , 'Email') !!}
                                {!! Form::email('email', null , array('class' => 'form-control' , 'placeholder' => 'Enter Email')) !!}
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                {!! Form::label('website' , 'Website') !!}
                                {!! Form::text('website', null , array('class' => 'form-control' , 'placeholder' => 'Enter Website')) !!}
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                {!! Form::label('company' , 'Company') !!}
                                {!! Form::text('company', null , array('class' => 'form-control' , 'placeholder' => 'Enter Company')) !!}
                            </div>
                        </div>
                    </div>
                <div class="col-md-12">
                    <div class="col-md-12">
                        {!! Form::label('message' , 'Message') !!}
                        {!! Form::textarea('message', null , array('class' => 'form-control' , 'placeholder' => 'Enter Message')) !!}
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="col-md-4">
                        <br>
                        {!! Form::submit('Submit', array('class'=>'btn btn-warning center-block')) !!}
                    </div>
                </div>
                {!! Form::close() !!}

and the some JS:

<script>
    $(function() {

        $("#submit").click(function (e) {

            // Validate & prep data here
            var formData = $('form').serialize();

            var div = $('#errors');
            div.empty();

            $.ajax("config/emailform.php",
                    {
                        data: formData,
                        dataType: "json",
                        type: "POST",
                        success: function (response) {
                            // Show success message
                            if (response.success) {
                                $('form').hide();
                                $('#successMessage').show();
                            } else {

                                for (var key in response.errors){
                                    div.append($('<p>' + response.errors[key] + '</p>'));
                                }
                            }
                        }
                    });

        });

    });

</script>

12th December, 2016

Lordgreymaul left a reply on FatalErrorException In OAuthExceptionHandlerMiddleware.php Line 13: • 9 months ago

It does, but looks like i may have this issue elsewhere with other files! I guess the only other way is to downgrade to 5.0 and start over

Lordgreymaul left a reply on FatalErrorException In OAuthExceptionHandlerMiddleware.php Line 13: • 9 months ago

ok cool

so my next question is how do i fix the file

I tried removing the class name and calling just middleware but fails and im at a loss on this now

Lordgreymaul started a new conversation FatalErrorException In OAuthExceptionHandlerMiddleware.php Line 13: • 9 months ago

Hey

I m running through a TuT on OAuth Api with Lumen and hit a snag

The TUT is here : http://esbenp.github.io/2015/05/26/lumen-web-api-oauth-2-authentication/

FatalErrorException in OAuthExceptionHandlerMiddleware.php line 13: Interface 'Illuminate\Contracts\Routing\Middleware' not found

<?php

namespace LucaDegasperi\OAuth2Server\Middleware;

use Closure;
use Illuminate\Http\JsonResponse;
use Illuminate\Contracts\Routing\Middleware;
use League\OAuth2\Server\Exception\OAuthException;

/*
* OAuthExceptionHandlerMiddleware
*/
class OAuthExceptionHandlerMiddleware implements Middleware
{
    public function handle($request, Closure $next)
    {
        try {

            return $next($request);

        } catch (OAuthException $e) {

            return new JsonResponse([
                    'error'             => $e->errorType,
                    'error_description' => $e->getMessage()
                ],
                $e->httpStatusCode,
                $e->getHttpHeaders()
            );
        }
    }
}

10th October, 2016

Lordgreymaul left a reply on Passing Returns From API To View • 11 months ago

Its cool got it!

Thanks for you help!

 @foreach($zendesks->tickets as $zendesk)
                <p>{{$zendesk->url}}</p>
                <p>{{$zendesk->subject}}</p>
            @endforeach 

Lordgreymaul left a reply on Passing Returns From API To View • 11 months ago

So now its

Cannot use object of type stdClass as array

Lordgreymaul left a reply on Passing Returns From API To View • 11 months ago

its the array i posted above?

#883 ▼
  +"tickets": array:100 [▼
    0 => {#187 ▼
      +"url": "Something/v2/tickets/5097.json"
      +"id": 5097
      +"external_id": null
      +"via": {#185 …2}
      +"created_at": "2016-02-09T17:57:24Z"
      +"updated_at": "2016-06-27T21:01:14Z"
      +"type": null
      +"subject": "Something"
      +"raw_subject": "Something"
      +"description": """
        Something
        """
      +"priority": null
      +"status": "closed"
      +"recipient": "support@savingstream.co.uk"
      +"requester_id": 1141596301
      +"submitter_id": 1141596301
      +"assignee_id": 712346221
      +"organization_id": null
      +"group_id": 24119601
      +"collaborator_ids": []
      +"forum_topic_id": null
      +"problem_id": null
      +"has_incidents": false
      +"is_public": true
      +"due_at": null
      +"tags": []
      +"custom_fields": array:1 [ …1]
      +"satisfaction_rating": null
      +"sharing_agreement_ids": []
      +"fields": array:1 [ …1]
      +"followup_ids": []
      +"brand_id": 450021
      +"allow_channelback": false
    }

Lordgreymaul left a reply on Passing Returns From API To View • 11 months ago

I get a return of all the arrays

Lordgreymaul left a reply on Passing Returns From API To View • 11 months ago

controller

 // Zendesk View
    public function zendesk()
    {
        $zendesks = Zendesk::tickets()->findAll()->get(10);
        return view('zendesk' , compact('zendesks'));
    }

Lordgreymaul left a reply on Passing Returns From API To View • 11 months ago

my code is this

@foreach($zendesks as $zendesk)
           <p>{{$zendesk->url}}</p>
               <p>{{$zendesk->subject}}</p>
            @endforeach 

Lordgreymaul started a new conversation Passing Returns From API To View • 11 months ago

I'm sure this is a very simple thing to do , yet I dont understand how to do it. I have a number of different arrays returning from an api and need to post them to the screen in a for each loop . i can vardump then but doing a simple

@foreach($something as $somethingelse)

@endforeach

I end up with the error Trying to get property of non-object

An example of the array

["tickets"]=>
  array(100) {
    [0]=>
    object(stdClass)#187 (32) {
      ["url"]=>
      string(57) "URL"
      ["id"]=>
      int(5097)
      ["external_id"]=>
      NULL
      ["via"]=>
      object(stdClass)#185 (2) {
        ["channel"]=>
        string(5) "email"
        ["source"]=>
        object(stdClass)#181 (3) {
          ["from"]=>
          object(stdClass)#188 (2) {
            ["address"]=>
            string(28) "testing@name.co.uk"
            ["name"]=>
            string(13) "name"
          }
          ["to"]=>
          object(stdClass)#173 (2) {
            ["name"]=>
            string(13) "Saving "
            ["address"]=>
            string(26) "support"
          }
          ["rel"]=>
          NULL
        }
      }
      ["created_at"]=>
      string(20) "2016-02-09T17:57:24Z"
      ["updated_at"]=>
      string(20) "2016-06-27T21:01:14Z"
      ["type"]=>
      NULL
      ["subject"]=>
      string(29) " contact message"
      ["raw_subject"]=>
      string(29) " contact message"
      ["description"]=>
      string(1077) "
something
      ["priority"]=>
      NULL
      ["status"]=>
      string(6) "closed"
      ["recipient"]=>
      string(26) "support@email.co.uk"
      ["requester_id"]=>
      int(1141596301)
      ["submitter_id"]=>
      int(1141596301)
      ["assignee_id"]=>
      int(712346221)
      ["organization_id"]=>
      NULL
      ["group_id"]=>
      int(24119601)
      ["collaborator_ids"]=>
      array(0) {
      }
      ["forum_topic_id"]=>
      NULL
      ["problem_id"]=>
      NULL
      ["has_incidents"]=>
      bool(false)
      ["is_public"]=>
      bool(true)
      ["due_at"]=>
      NULL
      ["tags"]=>
      array(0) {
      }
      ["custom_fields"]=>
      array(1) {
        [0]=>
        object(stdClass)#186 (2) {
          ["id"]=>
          int(27657905)
          ["value"]=>
          string(0) ""
        }
      }
      ["satisfaction_rating"]=>
      NULL
      ["sharing_agreement_ids"]=>

8th October, 2016

Lordgreymaul left a reply on Declaration Of ComicsTable::run() Must Be Compatible With Illuminate\Database\Seeder::run() • 11 months ago

yes you do ! It allows you to do that , problem is it errors is if the id doesn't exist

Lordgreymaul left a reply on Declaration Of ComicsTable::run() Must Be Compatible With Illuminate\Database\Seeder::run() • 11 months ago

it works when pulling in one comic!

Can i only do one at a time?

Lordgreymaul left a reply on Declaration Of ComicsTable::run() Must Be Compatible With Illuminate\Database\Seeder::run() • 11 months ago

because Im completely new to this sort of thing and have not much idea what i'm doing lol!

What are random numbers?

Lordgreymaul left a reply on Declaration Of ComicsTable::run() Must Be Compatible With Illuminate\Database\Seeder::run() • 11 months ago

ok so gone for

 public function run()
    {
        $ts = time();
        $hash = md5($ts . config('marvel.private_key') . config('marvel.public_key'));

        $this->client = new Client([
            'base_uri' => 'http://gateway.marvel.com/v1/public/',
            'query' => [
                'apikey' => config('marvel.public_key'),
                'ts' => $ts,
                'hash' => $hash
            ]
        ]);

        $response = $this->client->get();
        $response = json_decode($response->getBody(), true);
       
         $comics = $response['data']['results'];
        foreach ($comics as $comic) {
           App\comics::insert([
              'title' => $comic['title'],
              'publisher' => 'Marvel',
              'year' => $comic['startYear'],
              'age' => 'Modern age',
              'slug' => $comic['title'],
              'type' => 'comic'
             
          ]); 
            
        }

and get Magic request methods require a URI and optional options array

Lordgreymaul left a reply on Declaration Of ComicsTable::run() Must Be Compatible With Illuminate\Database\Seeder::run() • 11 months ago

ahhh ok but so no it gives me this error [ErrorException] Undefined variable: id

Lordgreymaul started a new conversation Declaration Of ComicsTable::run() Must Be Compatible With Illuminate\Database\Seeder::run() • 11 months ago

hey guys getting this error for seeding, any ideas? Declaration of ComicsTable::run() must be compatible with Illuminate\Database\Seeder::run() the seeder is below

<?php

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\comics;
use GuzzleHttp\Client;

class ComicsTable extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run($id)
    {
        $ts = time();
        $hash = md5($ts . config('marvel.private_key') . config('marvel.public_key'));

        $this->client = new Client([
            'base_uri' => 'http://gateway.marvel.com/v1/public/',
            'query' => [
                'apikey' => config('marvel.public_key'),
                'ts' => $ts,
                'hash' => $hash
            ]
        ]);

        $response = $this->client->get('comics/' . $id);
        $response = json_decode($response->getBody(), true);
       
         $comics = $response['data']['results'];
        foreach ($comics as $comic) {
           App\comics::insert([
              'title' => $comic['title'],
              'publisher' => 'Marvel',
              'year' => $comic['startYear'],
              'age' => 'Modern age',
              'slug' => $comic['title'],
              'type' => 'comic'
             
          ]); 
            
        }
    }
       
}
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.