jackbarham

jackbarham

Member Since 5 Years Ago

Experience Points 12,130
Experience Level 3

2,870 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 209
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.

10 Dec
6 months ago

jackbarham left a reply on Wildcard Dynamic Subdomain(s) In Homestead Laravel 5.1 On OS X Yosemite

I've since gone through this process a few times (new MacBook and occasionally reformatting) and this article has always been really helpful.

https://passingcuriosity.com/2013/dnsmasq-dev-osx

The only change, if you are using Homestead and the .test tld, is this file

/usr/local/etc/dnsmasq.conf

set it to

address=/test/192.168.10.10

22 Nov
7 months ago

jackbarham left a reply on Using Image Intervention With Laravel Nova

Thanks, @martinbean. It wasn't obvious at first, but have it working now.

Avatar::make('Image', 'image_large')
    ->store(function (Request $request, $model) {

        // Create a UUID filename
        $fileSmall = $this->uuid() . '.jpg';
        $fileLarge = $this->uuid() . '.jpg';

        // Crop with Image Intervention
        $imageSmall = Cropper::make($request->image)->fit(200, 100, function ($c) {
            $c->upsize();
        })->encode('jpg', 90);
        $imageLarge = Cropper::make($request->image)->fit(500, 300, function ($c) {
            $c->upsize();
        })->encode('jpg', 90);

        // Store on S3
        Storage::disk('s3_image')->put($fileSmall, (string) $imageSmall);
        Storage::disk('s3_image')->put($fileLarge, (string) $imageLarge);

        return [
            'image_small' => $fileSmall,
            'image_large' => $fileLarge,
        ];
    })
    ->rules('required')
    ->disk('s3_image')
    ->hideFromIndex()
    ->prunable(),

jackbarham left a reply on Using Image Intervention With Laravel Nova

I have Image Intervention working and pushing to S3, but I can't save the filename to the table.

this is what I have so far:

// Use AS because Image is already a Nova facade
use Intervention\Image\Facades\Image as Cropper;

- - -

Avatar::make('Image Large')
    ->store(function (Request $request, $model) {
        
        // Create a UUID filename
        $fileName = $this->uuid() . '.jpg';
        
        // Crop with Image Intervention
        $cropped = Cropper::make($request->image_large)->fit(100, 50, function ($c) {
            $c->upsize();
        })->encode('jpg', 80);

        // Store on S3
        Storage::disk('s3_image')->put($fileName, (string) $cropped);

        // Save filename in DB
        $model->update([
            'image_large' => $fileName,
        ]);
    })
    ->rules('required')
    ->prunable(),

All working except the last part, saving the filename.

jackbarham left a reply on Using Image Intervention With Laravel Nova

I was having issues. Let me try again, as I might be getting the logic wrong :)

jackbarham started a new conversation Using Image Intervention With Laravel Nova

I'm trying crop images once they upload, then save to newly cropped image to S3. I have all working expect the image cropping.

I don't see anything on the documentation about being able to crop images at the server end, is it this even possible?

I know there's a front-end Nova package for cropping images before upload, but I'd like to process image cropping (ideally with Image Intervention) at the server level.

Has anyone got it working yet?

02 Dec
1 year ago

jackbarham started a new conversation All Wildcard Subdomain Traffic To SSL And Custom Domains To (non SSL) HTTP

I'm running a server on the regular Laravel Forge setup. I'm creating a site builder where the user has username.sitebuilder.com with the ability to have www.username.com mapped over it, which is all working fine.

However, I needed to add an SSL wildcard cert for *.sitebuilder.com which, again is all working fine. But I need the server to still listen to www.username.com (non SSL) and that's no longer working.

How do I setup Nginx to route:

*.sitebuilder.com -> SSL www.whatever.com -> HTTP

When I go to www.whatever.com I get the Welcome to nginx! page

Here is my config file:

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/sitebuilder.com/before/*;

server {
    listen 80;
    listen [::]:80;

    server_name ~.;

    #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 (DOT NOT REMOVE!)
    include forge-conf/sitebuilder.com/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/sitebuilder.com-error.log error;

    error_page 404 /index.php;

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

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

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name .sitebuilder.com;
    root /home/forge/sitebuilder.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/sitebuilder.com/00000/server.crt;
    ssl_certificate_key /etc/nginx/ssl/sitebuilder.com/00000/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers '**PRIVATE KEY**';
    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 (DOT NOT REMOVE!)
    include forge-conf/sitebuilder.com/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/sitebuilder.com-error.log error;

    error_page 404 /index.php;

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

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

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/sitebuilder.com/after/*;
27 Jan
2 years ago

jackbarham started a new conversation Delete Laravel 5.3 Polymorphic Items When Deleting Parent Via Cascade

I'm trying to delete polymorphic items/relationships when a parent is deleted.

My structure is;

    - User (hasMany: Page)
    - - Page (hasMany: Module, belongsTo: User)
    - - - - Module (belongsTo: Page, morphTo: content())
    - - - - - ModuleVideo (morphMany: 'content')
    - - - - - ModuleAudio (morphMany: 'content')
    - - - - - ModuleSomething (morphMany: 'content')

I can delete the Module and ModuleItem by pinging Module directly;

$module->forceDelete();
$module->content->forceDelete();

The User > Page > Module are all setup so onDelete they cascade down.

How do I force ModuleVideo/Audio/Something to delete if any of the parents (Page or User) are deleted?

24 Aug
2 years ago

jackbarham left a reply on Can I Use Laravel 5.3 Passport As General Auth For A SPA To Laravel API?

@nate.a.johnson I did watch that video, I got the impression it would achievable, hence the question, but what wasn't clear how much of the first 3/4 of the video I need to follow to get it working. I'm pretty sure in the not too distant future there will be plenty of tutorials as it seems I'm not the only one interested in the concept :)

23 Aug
2 years ago

jackbarham left a reply on Can I Use Laravel 5.3 Passport As General Auth For A SPA To Laravel API?

Thanks @usman that seems to be the part I'm looking for.

jackbarham left a reply on Can I Use Laravel 5.3 Passport As General Auth For A SPA To Laravel API?

Thanks, @sicsol - I'll have to look into that bit, it's hard to keep it simple as all examples are showing the 'full blown' version of what the app can do :)

jackbarham started a new conversation Can I Use Laravel 5.3 Passport As General Auth For A SPA To Laravel API?

Today Laravel 5.3 was launched with a service called Passport. I've read through the documentation and watched the Laracast "Whats new 5.3 - Passport" video.

What I'm struggling to understand through all the bells and whistles; is this suitable to use just to login/register a user in from a SPA into a Laravel API server? I'm not interested in allowing my users to have their own API server.

There doesn't seem to be much around (probably as it's brand new) telling me about using for purely as a general auth service for an app?

04 Apr
3 years ago

jackbarham left a reply on Page Not Loading On Refresh When Removing The # Hash From The URL In Vue.js + Vue-Router

I actually found another way too. Add this to the route of the Vue SPA

Route::get('/{vue?}', function() {
    return view('app');
})->where('vue', '[\/\w\.-]*');
03 Apr
3 years ago

jackbarham left a reply on Class Log Does Not Exist

This also happens if you have a space without quotes around the a word in the .env file; for example:

Error: WEBSITE_TITLE=Website title Good: WEBSITE_TITLE="Website title"

02 Apr
3 years ago

jackbarham started a new conversation How Do I Use Debugbar On An API Server (with No Views)

I'm building out an API server in Laravel 5.2 only outputting json (for a Vue.js SPA) and I want to use Laravel Debugbar, or a similar tool to monitor database queries. Should I still be able to view the toolbar? I presume not as I have no views and theres no mention on being able to use it, or not, for API only servers.

I've noticed files in storage/debugbar/... with squashed up .json which I have to run through a prettifier to read.

I presume there's any easier way?

Thanks.

28 Mar
3 years ago

jackbarham started a new conversation Trying To Remove Data In Fractal By Implementing ArraySerializer In Laravel 5.2

I've got the API working using the standard process, but I want to remove the data namespace from the JSON output. I see I need to implement ArraySerializer, I have been through the Fractal docs, but I can't work out where I need to added it in Laravel 5.2

I found this answer but I'm just getting the same output at the line of code I commented out:

<?php

namespace App\Http\Controllers;

use App\Link;
use App\Track;

use League\Fractal\Manager;
use League\Fractal\Resource\Collection;
use League\Fractal\Serializer\ArraySerializer;

use App\Transformers\TrackTransformer;

//use Illuminate\Http\Request;
//use App\Http\Requests;

class TrackController extends ApiController
{
    public function index()
    {
        $tracks = Track::all();
        //return $this->respondWithCollection($tracks, new TrackTransformer);
        
        // This does the same at the code commented out above
        $manager = new Manager();
        $manager->setSerializer(new ArraySerializer());
        $response = new Collection($tracks, new TrackTransformer);
        return response()->json($manager->createData($response)->toArray());
    }

    public function show($id)
    {
        $track = Track::find($id);
        return $this->respondWithItem($track, new TrackTransformer);
    }
}

Also, I'm implementing this on a specific controller, even if I got this working, where do I add the code/class so I can get ArraySerializer output for all my controllers?

I've posted this on Github if that helps.

14 Mar
3 years ago

jackbarham left a reply on Vue.js DatePicker With Time

I've been looking for this for ages. Not only that, I can't even find a vanilla Javascript date and time picker either, just date pickers. Which means I'm going to to have to add jQuery for this and another module because my JS isn't good enough, yet, to build it up myself.

If you do find a native Javascript or Vue date and time picker, do let me know.

Thanks, Jacks.

28 Jan
3 years ago

jackbarham started a new conversation Page Not Loading On Refresh When Removing The # Hash From The URL In Vue.js + Vue-Router

I have a Laravel 5.2 setup running in Homestead and using Vue.js router to build an SPA. I'm trying to completely remove the #hash from the URL which I know can be done, but I keep getting errors:

I've added rewrite ^(.+)$ /index.html last; to my vhosts file in Homestead:

    server {
    
        listen 80;
        listen 443 ssl;
        server_name app.vibecast.dev;
        root "/home/vagrant/Code/vibecast/app.vibecast.com/public";
    
        rewrite ^(.+)$ /index.html last;
    
        index index.html index.htm index.php;
    
        charset utf-8;
    
        ...
    
    }

When I restart and open a page I get a 500 Internal Server Error.

Is there anything I need added to routes in Laravel?

    var router = new VueRouter({
        hashbang: false,
        history: true,
        linkActiveClass: "active"
    })

I can get it working without the #hash (or the modified hosts file) when navigating around, but fails when I reload a page.

26 Jan
3 years ago

jackbarham left a reply on Compiling Bourbon/Neat In Elixir

I got it working by adding:

@import "node_modules/bourbon/app/assets/stylesheets/bourbon"; to app.scss

I think you need to add the last /bourbon at the end

04 Jan
3 years ago

jackbarham started a new conversation London Vue.js Meetup

Hello. I've created a London Vue.js Meetup group and looking for people to either register their interest in attending or would be up for doing a talk.

http://www.meetup.com/London-Vue-js-Meetup/about

PS: Apologies if this forum is strictly for code only. Happy to delete.

03 Dec
3 years ago

jackbarham left a reply on How Do I Pass A Dynamic Page :id To $http.get Url

Thanks @JoaoSantos - I managed to find a cleaner answer on Stackoverflow:

var itemId = this.$route.params.id;
this.$http.get('//api.trax.dev/tracks/' + itemId, function (data) {
    this.$set('track', data.track)
})

Ref: http://stackoverflow.com/questions/34070580/how-do-i-pass-a-dynamic-page-id-to-http-get-url-in-vue-js

jackbarham started a new conversation Pass A Dynamic Page/:id To Resource

This is literally my first time using Vue. I have have view router set up:

router.map({ '/tracks/:id': { component: SingleTrack } })

And this is my component:

`var SingleTrack = Vue.component('track', {

template: '#track-template',

data: function() {
    return {
        track: ''
    }
},

ready: function() {
    this.$http.get('//api.trax.dev/tracks/1', function (data) {
        this.$set('track', data.track)
    })
}

});`

How do I pass the url/:id to the end of the get string, something like:

ready: function(id) { this.$http.get('//api.trax.dev/tracks/' + id, function (data) { this.$set('track', data.track) }) }

So I can pull in the correct data dynamically?

02 Dec
3 years ago

jackbarham started a new conversation How Do I Stop The Sites-available File From Being Rewritten After Homestead Being Provisioned?

I'm running various sites in Homestead. One of my main ones is *.project.dev - To get the wildcard to work in Homestead I have to add:

server_name *.project.dev; in /etc/nginx/sites-available/project.dev

I've upgraded Homestead so it keeps the database but I have to manually edit the server name after each provision.

Is there anyway to project these files?

01 Oct
3 years ago

jackbarham left a reply on EC2 Management Via Forge

I'm also interested in this too.

02 Sep
3 years ago

jackbarham left a reply on Wildcard Dynamic Subdomain(s) In Homestead Laravel 5.1 On OS X Yosemite

@robgeorgeuk @superseb thanks very much, having tried all this over over the weekend (via dnsmasq) I've clearly something, so I'm going to try again this evening, following your instructions, when I get back home. I'll keep you both updated.

29 Aug
3 years ago

jackbarham left a reply on Wildcard Dynamic Subdomain(s) In Homestead Laravel 5.1 On OS X Yosemite

Those are fixed, they are supposed to go to different folders. I have the App app.project.mac, Marketing website www.project.mac and User profile pages username.project.mac all running different L5 installations. However, the username of username.project.mac needs to be dynamically generated

jackbarham started a new conversation Wildcard Dynamic Subdomain(s) In Homestead Laravel 5.1 On OS X Yosemite

I'm trying to get wildcard subdomains to resolve locally on my mac (OS X Yosemite).

A user creates their own site and based on their username they will have username.project.mac (or *.project.mac).

I have Homestead working correctly for www.project.mac, app.project.mac and project.mac as these are pre-set routes, but I need username.project.mac to be dynamic.

.hosts

    # Homestead
    192.168.10.10 project.mac
    192.168.10.10 app.project.mac
    192.168.10.10 www.project.mac

Homestead.yaml

    ---
    ip: "192.168.10.10"
    memory: 2048
    cpus: 2
    
    authorize: ~/.ssh/id_rsa.pub
    
    keys:
        - ~/.ssh/id_rsa
    
    folders:
        - map: /Users/me/Code
          to: /home/vagrant/Code
    
    sites:
        - map: project.mac
          to: /home/vagrant/Code/vybecast/user.project.com/public
        - map: app.project.mac
          to: /home/vagrant/Code/vybecast/app.project.com/public
        - map: www.project.mac
          to: /home/vagrant/Code/vybecast/www.project.com/public
    
    databases:
        - homestead
    
    variables:
        - key: APP_ENV
          value: local

routes.php

    Route::group(['domain' => '{username}.project.mac'], function () {
        return $username;
    });

I have even been through this tutorial: http://passingcuriosity.com/2013/dnsmasq-dev-osx/ which 'seems' to have worked until the very last point where I can't resolve test.testing.mac when I try to ping it. project.mac does resolve when I ping it.

I have also edited /etc/nginx/sites-available/project.mac to server_name project.mac *.project.mac; as per this reply: https://laracasts.com/discuss/channels/general-discussion/homestead-and-subdomains/replies/46620

I have no idea what else to try.

24 Jul
3 years ago

jackbarham started a new conversation Error Trying To Delete S3 Directory (and Contents) In Laravel 5.1

I'm trying to delete and entire directory with any preceding folders or contents. I can delete upload, create and delete single files but get errors when deleting the master folder:

Folders start with the Auth::user id, so I was hoping to delete the master folder when deleting the user.

First option: Storage::disk('s3')->deleteDirectory(Auth::id()); Error: "Maximum function nesting level of '100' reached, aborting!"

Second option: Storage::deleteDirectory(Auth::id()); Error: "Call to a member function delete() on integer"

I've been using Storage::disk('s3')->delete($path . $filename); for adding and removing individual files without any issues.

21 Jul
3 years ago

jackbarham left a reply on Advice On How To Restructure And Move Database Data While Lots Of Changes Are Being Made During Alpha Testing Stage

Cool, thanks Mike.

I think I'm going to have to do some reading up on this too.

jackbarham started a new conversation Advice On How To Restructure And Move Database Data While Lots Of Changes Are Being Made During Alpha Testing Stage

I'm building a web app and about to get it out for private alpha testing. This is the first app I've developed, so I've never got this far before.

I'd like to know any opinions, thoughts and recommendations with regards to managing database content, rows and fields while lots of initial feedback is coming in and inevitably lots of databases updates, changes and migrations will be required.

The app I am building creates websites or profile pages for musicians, and while I'm not too worried about breaking changes within the admin area (while in alpha), I'm more concerned that I keep the website (my testers public facing profile) part as smooth running as possible.

I'm building the app in Laravel, so I'll be using migrations to do this. Obviously it's going to be hard to predict what changes could be made but an example might be:

Splitting the User table into user and user_profile and migrating/importing some of the data from the user table and adding it to the user_profile table without impacting the user or flow of the app.

I'd really appreciate any feedback, help, suggestions or other links that might help me while I prepare my app for user testing.

03 Jul
3 years ago

jackbarham left a reply on Where Do I Add Event::fire() In Laravel 5.1 When User Registers?

Works a treat @goatshark I just literally copied the whole postRegister() method to AuthController and it worked! - Had to move use Illuminate\Http\Request; over too.

jackbarham started a new conversation Where Do I Add Event::fire() In Laravel 5.1 When User Registers?

I have an Event::fire(); on getRegister(); in Illuminate/Foundation/Auth/RegistersUsers.php

But I know this is not the correct location for it:

public function postRegister(Request $request)
{
    $validator = $this->validator($request->all());

    if ($validator->fails()) {
        $this->throwValidationException(
            $request, $validator
        );
    }

    Auth::login($this->create($request->all()));

    Event::fire(new UserWasRegistered(Auth::id()));

    return redirect($this->redirectPath());
}

How I add the event so it's not in Illuminate and in AuthController?

25 Jun
3 years ago

jackbarham left a reply on Image Gallery Using Batch Uploads, Processing Sizes, Send To CDN And Display Them

I thought I had put into that forum - My mistake, updated it now.

I've been looking at intervention, about to use it for a test project this afternoon - Blueimp looks good too.

This probably is a mini-series, although I'm still keen to see what the best practices are and correct ways to implement a modern image gallery are.

jackbarham started a new conversation Image Gallery Using Batch Uploads, Processing Sizes, Send To CDN And Display Them

I've been working a few Laraval projects which require some form of image gallery.

I know you have file upload videos, which have been really helpful, but a dedicated gallery video would be really really helpful.

I was thinking along the lines:

  • Drag 'n' drop a brunch of images (I know this will require a touch of js)
  • Process batch uploads (ideally with progress bar)
  • Resize images (thumb an full size) and store them
  • Send images to S3 (or cloud/CDN of some form)
  • Display images (thumbnail and full size)
  • Delete images (or batch delete)

Maybe use Vue.js for the js part of the image uploading - I'd be happy to see that too.

I'm sure there are many others who would fid this useful.

Great work - Thanks for all your help so far.

12 Jun
4 years ago

jackbarham started a new conversation Passing Sanitized Preg_match To Rules() Via Request In Laravel 5 Not Working As It Should

I have a feature where I sanitize a YouTube link before it gets saved to the database. I have the preg_match working fine, but I can't pass the sanitized version (just the YouTube ID) back to the Controller, it reverts back the unsanitised original link.

VideoRequest:

public function rules()
{
    $this->sanitize();

    return [
        'page_id' => 'required|integer',
        'visibility' => 'required',
        'item_type' => 'required',
        'title' => 'required|string',
        'embed' => 'required',
        'content' => '',
        'image' => 'string',
        'order' => 'required|integer'
    ];
}

public function sanitize()
{
    $input = $this->all();

    if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $input['embed'], $match)) {
        $input['embed'] = $match[1];
    } else {
        return "Please try another YouTube URL or link";
    }

    $this->replace($input);
}

VideoController:

public function store(VideoRequest $request)
{
    $video = array_intersect_key(Input::all(), $request->rules());
    VideoItem::create($video);
    flash()->success('New video created');
    return redirect()->back();
}

When I dd($input) at the bottom of sanitize() function it will return all inputs with the embed code correctly, just as an ID. When it passes to rules(); embed is now the original link?

06 Apr
4 years ago

jackbarham left a reply on Laravel 5 Trying To Get Property Of Non-object Error When Passing Multiple Join Table Values To View

I've actually just figured out what it was.

I needed to change ->get(); to ->first();

jackbarham started a new conversation Laravel 5 “Trying To Get Property Of Non-object” Error When Passing Multiple Join Table Values To View

I am querying three tables using joins and getting the following error:

ErrorException: Trying to get property of non-object (View: .../views/app/text.blade.php).

Let me explain the logic:

User: I need to grab details from the User model User: hasMany -> Page

Page: holds every page meta (title, slug, menu_order, active, etc). The page content is in separate model specific to that type of content. On this occasion Page: HasMany -> Text.

Text: Is a type of page that has page content, it's related to the Page model Text: belongsTo -> Page.

Here is the controller:

public function show($id)
{
    $text = DB::table('pages')->where('pages.id', '=', $id)
        ->join('texts', 'pages.id', '=', 'texts.page_id')
        ->join('users', 'pages.user_id', '=', 'users.id')->where('users.id', '=', Auth::user()->id)
        ->get();

    return view('app.text', compact('text'));
}

The joins seem to work because when I change return view('app.text', compact('text')); to return $text I get the following json response:

[
    {
        "id": 1,
        "user_id": 1,
        "title": "",
        "slug": "new-order",
        "type": "text",
        "status": "private",
        "order": 0,
        "published_at": "2015-04-06 19:31:21",
        "created_at": "2015-04-02 23:14:37",
        "updated_at": "2015-04-03 15:57:08",
        "page_id": 16,
        "content": "testing",
        "image_path": null,
        "image_position": null,
        "email": "jack@_ _ _.com",
        "username": "jackbarham",
        "full_name": "Jack Barham",
        "country": "gb",
        "city": "London",
        "password": "_ _ _",
        "remember_token": null
    }
]

I'm not sure if this is related or not, the title has the value New order in the database, but it doesn't appear in this output.

My view:

{!! Form::model($text, ['route'  => ['text-update', $text->page_id], 'role'=> 'form', 'class' => 'page']) !!}

    <div class="page__content">

        <div class="ui form">

            <div class="page__header">

                <div class="field @if($errors->has('title')){{ 'error' }}@endif">
                    {!! Form::label('title', 'Page title') !!}
                    @if($errors->has('title'))<span class="validation__error">{{ $errors->first('title') }}</span>@endif
                    {!! Form::text('title', null, ['class' => 'js-slug__title']) !!}
                    <span class="page__slug">vybecast.com/{!! $text->username !!}/{!! Form::text('slug', null, ['class' => 'js-slug']) !!}</span>
                </div>

            </div><!-- page__header -->

            <div class="field">
                {!! Form::label('content', 'Page content') !!}
                {!! Form::textarea('content', null) !!}
            </div>

            <div class="field">
            <label>Page image</label>
            {!! Form::file('hero', array('class' => 'form__file')) !!}
        </div>

        </div>

    </div>

    @include('app.layout.page-control')

{!! Form::close() !!}

I originally pulled the Page and User content via two separate calls (then two compacts) and it worked. However, now I have joined three tables I can't get the view to work without the errors.

I haven't put my model code on here as I'm sure they are working (re: json output) correctly - Although I'm happy to post more code if required.

15 Feb
4 years ago

jackbarham left a reply on How To Register A Custom 404 In Laravel 5

Do you mean my reply? That's interesting, so just add in a 404.blade.php in views/errors and it will handle it automatically you mean?

14 Feb
4 years ago

jackbarham started a new conversation Homestead 2.0, Vagrant And VirtualBox Running A Lot Slower Than MAMP

I've just setup Homestead 2.0 vagrant server for Laravel 5 running on VirtualBox on OSX 10.10 (Yosemite) and it's running a lot slower than MAMP.

I really want to use Homestead, but the 1-3 second delay in loading pages is becoming really annoying, yet every load request is instant on MAMP.

Am I missing something on my setup?

Homestead.yaml:

---
ip: "192.168.10.10"
memory: 2048
cpus: 2

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: /Users/jackbarham/Code
      to: /home/vagrant/Code

sites:
    - map: tasks.mac
      to: /home/vagrant/Code/tasks/public

databases:
    - homestead

variables:
    - key: APP_ENV
      value: local

hosts:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 

192.168.10.10 tasks.mac

127.0.0.1   tasks-mamp.mac  # MAMP PRO - Do NOT remove this entry!
01 Feb
4 years ago

jackbarham left a reply on My Company Has Dropped Laravel For Symphony :(

I'm your typical designer/front-end dev with little more than basic WP dev knowledge and I don't find L5 and more daunting than L4 was. Also, I've not had much time to do anything than other than basic pages and controllers as I've been waiting for L5.

The point point I am trying to make, mainly in regards to @larapetit reply, as a design focused front-end coder I'm really don't find the barrier to L5 any worse than L4. I don't think new dev's will be put off by L5 as much as they might be by Symphony.

16 Dec
4 years ago

jackbarham left a reply on Series On Building A Complete Application From Scratch (like Larabook) Using Laravel 5

I agree, every app has its particularities. However as a front-ender/designer I've learnt a LOT from building tutorial apps because it's give much more context (especially if you're fairly new to Laravel, OOP, etc) of what each section does with another.

I'm still learning and becoming confident enough to build my own app (albeit fairly basically) and I'm always hunting down new App build tutorials as they are invaluable in learning how everything connects together, even if it is very general.

Once I get better I can focus more on specific parts of development but understanding how an App is structured, layout and implemented then seeing it done on a new version of Laravel is beyond valuable to me.

jackbarham left a reply on Series On Building A Complete Application From Scratch (like Larabook) Using Laravel 5

I'd be up for this - Maybe a Web App as appose to another Social Media App. However, I think everyone (inc. Laracasts) are waiting for a stable Laravel 5 release as its changing quite a lot while it's being developed which I believe will be around late January.

11 Dec
4 years ago

jackbarham left a reply on Video Player Is Too Small In The New Site Design

Also - Having the a player (away from the page) makes keyboard shortcuts much easier...

CMD/CTRL + Tab to switch between IDE and browser/player Space to stop and start the video Rinse and repeat...

I'm more than happy with this setup.

jackbarham left a reply on Video Player Is Too Small In The New Site Design

All good - Don't waste your time on it, the download (which actually plays full-screen anyway) is exactly what I was looking for.

Maybe a button to force playing in the browser for those that automatically download, but really, this is not a big deal.

I was going to delete the thread when I realised, but thought it might help someone else :)

jackbarham left a reply on Video Player Is Too Small In The New Site Design

I've just noticed that if you click 'download' it will play directly in your browser - I guess this is down to browser settings (I'm on Chrome / OSX).

Thats enough for me - I can now adjust it to the exact width I require it.

Problem solved - Hopefully will help someone else :)

jackbarham started a new conversation Video Player Is Too Small In The New Site Design

Loving the new site design, its much cleaner. However, the video is much smaller, on the old design the player would stretch across the screen and I can open my IDE and browser (with Laracasts playing) next to each other. How you have controls on the right and the screen is way smaller and harder to read the code, unless I go full-screen which is quite clumsy when you're stopping and startying.

I've attached a screenshot of what I mean - On the old design the video would take up the full width of the browser and made viewing the video mush easier.

https://dl.dropboxusercontent.com/u/8458983/laracastsvideo.png

Is there any chance this can be returned as it makes following tutorials a LOT easier.

In the meantime, I'll download each video manually.

28 Nov
4 years ago

jackbarham left a reply on Automatically Play Next Lesson

I've just posted the same request, admittedly, before I fully checked the website: https://laracasts.com/discuss/channels/site-improvements/continuos-play-for-series-videos

I'll leave it up there for now - Hopefully it will get the point across.

jackbarham started a new conversation Continuos Play For Series Videos

Before I get stuck into any tutorials I tend to watch the whole series first. I often do this by watching it on my main TV, sitting on my couch via an iDivice and AppleTV. It keeps me away from my computer so I can focus on the course/lesson in-hand and take ntoes.

What would be awesome is some form of YouTube style play list where it will automatically play the next video when the previous one has finished.

Adding to that, what would be even more awesomerer (if that's even a word) is to select a playlist by queuing up a load of videos (or even a whole series mixed with videos) manually. Maybe a separate page/pop-out with whole list of queued-up videos which continuously play. If I stop watching I can come back and carry on where I left off. Maybe not in the middle of a video but at from the last one I watched.

I have great admiration for your work and this website - I understand this is a 'nice to have', but it would really nice to have it ;)

Regards, Jack.