jasonb

Experience

6,360

0 Best Reply Awards

  • Member Since 3 Years Ago
  • 59 Lessons Completed
  • 10 Favorites

14th September, 2016

jasonb left a reply on Saving A File In A Form. • 1 year ago

bashy, are you for hire?

13th September, 2016

jasonb left a reply on Saving A File In A Form. • 1 year ago

I was. I upgraded my php and created a new instance of the laravel install from scratch. I am at 5.3 and using Jeffs example.

jasonb left a reply on Saving A File In A Form. • 1 year ago

OK Just walking through the example Jeff does here: https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/12 What's New in Laravel 5.3: Super Simple File Uploading

I follow along and when I try to store the file I get this: FatalErrorException in routes.php line 19: Call to a member function store() on null

Route:

<?php

Route::get('/', function () {
    return view('welcome');
});

Route::post('avatars', function () {
   request()->file('avatar')->store('avatars');
    return back();
});

here is the welcome blade:

<!DOCTYPE html>
<html>
    <head>
        <title>Laravel</title>

        <link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">

        <style>
            html, body {
                height: 100%;
            }

            body {
                margin: 0;
                padding: 0;
                width: 100%;
                display: table;
                font-weight: 100;
                font-family: 'Lato';
            }

            .container {
                text-align: center;
                display: table-cell;
                vertical-align: middle;
            }

            .content {
                text-align: center;
                display: inline-block;
            }

            .title {
                font-size: 96px;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <div class="content">
                <div class="title">Avitars</div>
                <form method="POST" action="avatars" enctype="multipart/form-data">
                    {{ csrf_field()}}
                    <input type = "file" name="avitar"></input>
                    <button type="submit">Save Avatar</button>

                </form>
            </div>
        </div>
    </body>
</html>

Pretty straight forward.

The full dump:

in routes.php line 19 at FatalErrorException->__construct() in HandleExceptions.php line 133 at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 118 at HandleExceptions->handleShutdown() in HandleExceptions.php line 0 at RouteServiceProvider->{closure:/Users/jbrashear/tastycoders-DEV/dantest/avatars/app/Http/routes.php:18-20}() in Route.php line 158 at call_user_func_array:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Routing/Route.php:158}() in Route.php line 158 at Route->runCallable() in Route.php line 137 at Route->run() in Router.php line 724 at Router->Illuminate\Routing{closure}() in Pipeline.php line 52 at call_user_func:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52}() in Pipeline.php line 52 at Pipeline->Illuminate\Routing{closure}() in VerifyCsrfToken.php line 64 at VerifyCsrfToken->handle() in Pipeline.php line 136 at call_user_func_array:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline{closure}() in Pipeline.php line 32 at call_user_func:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}() in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle() in Pipeline.php line 136 at call_user_func_array:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline{closure}() in Pipeline.php line 32 at call_user_func:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}() in StartSession.php line 64 at StartSession->handle() in Pipeline.php line 136 at call_user_func_array:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline{closure}() in Pipeline.php line 32 at call_user_func:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}() in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle() in Pipeline.php line 136 at call_user_func_array:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline{closure}() in Pipeline.php line 32 at call_user_func:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}() in EncryptCookies.php line 59 at EncryptCookies->handle() in Pipeline.php line 136 at call_user_func_array:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline{closure}() in Pipeline.php line 32 at call_user_func:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}() in Pipeline.php line 103 at call_user_func:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103}() in Pipeline.php line 103 at Pipeline->then() in Router.php line 726 at Router->runRouteWithinStack() in Router.php line 699 at Router->dispatchToRoute() in Router.php line 675 at Router->dispatch() in Kernel.php line 246 at Kernel->Illuminate\Foundation\Http{closure}() in Pipeline.php line 52 at call_user_func:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52}() in Pipeline.php line 52 at Pipeline->Illuminate\Routing{closure}() in CheckForMaintenanceMode.php line 44 at CheckForMaintenanceMode->handle() in Pipeline.php line 136 at call_user_func_array:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline{closure}() in Pipeline.php line 32 at call_user_func:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing{closure}() in Pipeline.php line 103 at call_user_func:{/Users/jbrashear/tastycoders-DEV/dantest/avatars/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103}() in Pipeline.php line 103 at Pipeline->then() in Kernel.php line 132 at Kernel->sendRequestThroughRouter() in Kernel.php line 99 at Kernel->handle() in index.php line 54 at {main}() in index.php line 0

jasonb left a reply on Saving A File In A Form. • 1 year ago

JoolsMcFly, FatalErrorException in FormsController.php line 46: Call to a member function move() on a non-object

jasonb left a reply on Saving A File In A Form. • 1 year ago

Dang I thought I was on 5.3 /** * The Laravel framework version. * * @var string */ const VERSION = '5.2.45';

jasonb left a reply on Saving A File In A Form. • 1 year ago

this is what came out:

/Applications/MAMP/tmp/php/phpbnsVa2

jasonb left a reply on Saving A File In A Form. • 1 year ago

So when I run:

 public function store(Request $request){
     
        $path = $request->pic1->store('pics');
        return $path;




    }

I get: BadMethodCallException in Macroable.php line 74: Method store does not exist.

This is so strange.

jasonb left a reply on Saving A File In A Form. • 1 year ago

That gives us: BadMethodCallException in Macroable.php line 74: Method store does not exist.

12th September, 2016

jasonb left a reply on Saving A File In A Form. • 1 year ago

So I want to save the file name into the database and I want to save the actual file in a folder called pics in the storage folder

jasonb left a reply on Saving A File In A Form. • 1 year ago

The form:

  <form method="post" action="/forms/store" enctype="multipart/form-data">
                            <input type="hidden" name="_token" value="{{ csrf_token() }}">
                            <div class="form-group">
                                <label for="title" class="control-label">Title</label>
                                <input class="form-control" name="title"></input>

                            </div>
                            <div class="form-group">
                                <label for="body" class="control-label">Content Body</label>
                                <textarea class="form-control" name="body"></textarea>

                            </div>
                            <div class="form-group">
                                <label for="pic" class="control-label">Upload Picture</label>
                                <label class="btn btn-default btn-file">
                                    Browse <input type="file"  name="pic1" style="display: none;">
                                </label>

                            </div>




                            <div class="form-group">
                                <button class="btn btn-primary" type="submit"><i class="fa fa-sticky-note-o" aria-hidden="true"></i> Add Form</button>
                            </div>
                        </form>

The controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Form;
use DB;
/**
 * Create a new controller instance.
 *
 * @return void
 */


class FormsController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth'); // This will require basic authentication with Larvel Auth.
    }
    //
    public function index(){

        //$forms = DB::table('forms')->get();
        $forms = form::all();

        return view('forms.index', compact('forms'));

    }

    public function show(Form $form){
//        $form = Form::find($id); // old way not needed with type hinting
      return view('forms.show', compact('form'));

    }

    public function newform(){
//return "Hello";
        return view('forms.new');

    }

    public function store(Request $request){
      //  return $request->all();
        $form = new Form;
        $form->title = $request->title;
        $form->body = $request->body;
        $form->pic1 = $request->pic1;
        $form->save();
        $request->file('pic1')->storeas('pics');



    }
    
}

jasonb left a reply on Saving A File In A Form. • 1 year ago

public function store(Request $request){ // return $request->all(); $form = new Form; $form->title = $request->title; $form->body = $request->body; $form->pic1 = $request->pic1; $form->save(); $request()->file('pic1')->store('pics');

}

jasonb started a new conversation Saving A File In A Form. • 1 year ago

OK I am a little confused. I have a route where I can process a file upload that stores correctly. But when I want to process a complete form with a file I am lost. {code} Route::post('/forms/store', '[email protected]'){ request()->file('pic1')->store('pics'); }; [/code]

I know this is written incorrectly. But I am not sure how to make the two work together.

29th October, 2015

jasonb started a new conversation Ajax And Blade • 1 year ago

I want to have a portet in my admin panel I am building out. I want to show a list if alerts in a portlet/block and have this load data from the controller and refresh say every 5-10 seconds. What is the best way/method to accomplish this?

-J

28th August, 2015

jasonb started a new conversation What Is The Site That Is Like Composer But Deals With CSS And Things Like Jquery? • 2 years ago

It has a logo of a bird. For the life of me I cannot remember what it is. Thanks

-J

8th July, 2015

jasonb started a new conversation Laravel And Existing Application • 2 years ago

I have a question. Is it possible to run larval with an existing web application? so that you set a route for say: /dashboard and that route gets passed to an application in the same web root but not controlled by larval. I am using laravel 5.1

The reason for this is we have an old CRM that we want to re write but do not have the time to do a complete rewrite from the ground up in Laravel and want to do this in stages.

Thank you in advance for your input! -J

24th June, 2015

jasonb left a reply on PHP 7 And Laravel • 2 years ago

I am downloading it right now. Also Blackfire io https://blackfire.io/ you can sign up for free as it is in beta. Blackfire empowers all developers and IT/Ops to easily identify and understand performance bottlenecks, and find how to resolve them quickly based on accurate data.

-J

jasonb started a new conversation PHP 7 And Laravel • 2 years ago

Hi all! Has anyone started putting thought into using php 7 with Laravel 5.1? Since PHP 7 is based on the PHPNG, The performance gains realized from PHP 7 are huge! They vary between 25% and 70% on real-world apps, and all of that just from upgrading PHP, without having to change a single line of code!

To put things in perspective – when PHPNG was published, the WordPress homepage required approx. 9.4 billion CPU instructions to execute. As of now – it requires only 2.6 billion – that’s 72% less!

I am excited to see the performance of Laravel 5.1 running on php 7.

I know that Right now php 7 is only in the first stage ie 7.0.0 Alpha 1 Released but the road map shows that it will be prime time November of this year 2015.

What are your thoughts?

-J

8th June, 2015

jasonb started a new conversation Auuto Build CRUD? • 2 years ago

Is there a way to build out CRUD from artisan based on a Database Table? In Cake PHP there was an option in the Bake tool that would build the scaffolding and give you boilerplate CRUD.

-J

4th May, 2015

jasonb started a new conversation Sorta Off Topic. WordPress In Sub Folder Located In Public. Pages Wont Load. • 2 years ago

Question for you guys, When I use the WP pages the home page functions but any pages that require the rewrite rules get passed over to Laravel. I am using NginX as a web server. Any ideas How I would setup NginX correctly to work with a sub folder and not pass to the roots index.php?

22nd April, 2015

jasonb left a reply on Array To String Conversion ?? • 2 years ago

Yes.. =) that was it..

~~

$links = implode('\n', array_flatten($links));

// should be

$links = implode("\n", array_flatten($links)); ~~

jasonb left a reply on Array To String Conversion ?? • 2 years ago

I really need some major help here. =)

jasonb left a reply on Array To String Conversion ?? • 2 years ago

@usman That is perfect.. It gives me the result I need.

So get this, I am working with an API that says to: Links String[] Yes Uploaded to the POSTs Request Body. Every link must be on a new line. Minimum of 10 links without BatchID. Example:

$links = “http://google.com\nhttp://yahoo.com”;

If I submit that to the API with the above $links I get Response : {"LinksAdded":2}

If I create $ links with the code you supplied:

$links = Link::whereStatus(false)->get(['url'])->reduce(function($previous, $value) { 
    if( ! $previous) return $value->url; 
    return $previous . '\n' . $value->url;
});

I get this: Response : {"LinksAdded":1}

For some reason if I try to build the variable the API takes the string and is unable to parse it and all URLs appear as one string. If I build it out manually it works. What the heck if the difference?

jasonb left a reply on Array To String Conversion ?? • 2 years ago

@usman That is perfect.. It gives me the result I need.

So get this, I am working with an API that says to: Links String[] Yes Uploaded to the POSTs Request Body. Every link must be on a new line. Minimum of 10 links without BatchID. Example:

$links = “http://google.com\nhttp://yahoo.com”;

If I submit that to the API with the above $links I get Response : {"LinksAdded":2}

If I create $ links with the code you supplied:

$links = Link::whereStatus(false)->get(['url'])->reduce(function($previous, $value) { 
    if( ! $previous) return $value->url; 
    return $previous . '\n' . $value->url;
});

I get this: Response : {"LinksAdded":1}

For some reason if I try to build the variable the API takes the string and is unable to parse it and all URLs appear as one string. If I build it out manually it works. What the heck if the difference?

jasonb left a reply on Array To String Conversion ?? • 2 years ago

@bashy Yes.

jasonb left a reply on Array To String Conversion ?? • 2 years ago

I want to take the array and create a variable that has the values from the array VALUE\nVALUE\nVALUE\nVALUE

When I tried to take my array and create that variable I got that error.

$links = implode(' ', $links);

ErrorException in LinkController.php line 43: Array to string conversion

jasonb started a new conversation Array To String Conversion ?? • 2 years ago

I need to take the valules of an array and convert it to a string that looks like this:

$links = “http://google.com\nhttp://yahoo.com”;

Here is my code:

 $links = Link::whereStatus(false)->get(['url'])->toarray();

            $links = implode(' ', $links);
            dd($links);

First off I get this error: Array to string conversion

I am not sure what is going on.

6th April, 2015

jasonb left a reply on .gitignore What Should Be Ignored? • 2 years ago

ok great. What do you think about storage/ ?

jasonb started a new conversation .gitignore What Should Be Ignored? • 2 years ago

Hello,

What all should we be ignoring from the laravel 5 installation? .env composer.lock vendor

What about storage?

Anything else that may be a good idea/ -J

2nd April, 2015

jasonb left a reply on How Do I Pass An Environment Variable To A View • 2 years ago

That is it.. I was soo close!! Thank you. =)

jasonb started a new conversation How Do I Pass An Environment Variable To A View • 2 years ago

I have an article page That is creating the collection $articles

  $articles = Article::with('category', 'tags')->published()->latest('published_at')->get();

        return view('articles.index', compact('articles'));

I want to pass an environment variable to this view

$_ENV['DOMAIN_NAME'];

How do I do that?

31st March, 2015

jasonb left a reply on How To Add A Css ID To A Form • 2 years ago

Can you have both installed at the same time?

jasonb left a reply on How To Add A Css ID To A Form • 2 years ago

@mstnorris I have not installed one. https://plugins.jetbrains.com/plugin/7532 is what I see. is that Laravel 4?

jasonb left a reply on How To Add A Css ID To A Form • 2 years ago

I use PHP storm *. its odd it didn't tell me.

jasonb started a new conversation How To Add A Css ID To A Form • 2 years ago

Hi, I am trying to add a id to this form element:

{!! Form::select('category_id', App\Category::lists('name','id'), null, [class' => 'form-control']) !!}

Like this:

{!! Form::select('category_id', App\Category::lists('name','id'), null, ['id' => 'category_id', class' => 'form-control']) !!}

But when I do I get this error: FatalErrorException in 6c7f1f5529aaf6da458220a54c0ea28e line 13: syntax error, unexpected 'class' (T_CLASS), expecting ']'

What am I doing wrong? -J

26th March, 2015

jasonb started a new conversation How Do I Pull Data From A Pivot Table? • 2 years ago

I want to query my articles based on a category ID that is attached to articles in the pivot table.

$articles = Article::latest('published_at')->where('article_id', '=', $categoryId)->get();

But article_id means nothing the this query. I am confused as to how I get that from the pivot table.

[article_tags table] article_id tag_id

[tag table] id name So my article 3 is tagged to tag 1

so I am passing 1 as $categoryId.

I hope this is making sense.

Thanks!

-J

jasonb left a reply on Accessing The User Table • 2 years ago

Ahh I had to put /App/User

jasonb left a reply on Accessing The User Table • 2 years ago

PhpStorm says it is an undefined namespace. At the top of the controller I have use App/User;

jasonb started a new conversation Accessing The User Table • 2 years ago

How can I look up a user ID with out loading auth?

I need to lookup a variable in a controller but auth is not loaded so this can be done publicly.

jasonb left a reply on View As An Rss Feed Issue • 2 years ago

ok I figured it out. In my controller I loaded the view like this:

 return Response::view('articles.feed', compact('articles'), 200)->header('Content-Type', 'application/atom+xml; charset=UTF-8');
   

jasonb left a reply on View As An Rss Feed Issue • 2 years ago

Here is my complete view. It seems to be stripping out the first line:

{!! '<'.'?'.'xml version="1.0" encoding="UTF-8" ?>'."\n" !!}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>my page</title>
        <link>http://www.domain.com</link>
        <description>Private RSS Feeds</description>
        <language>en-us</language>
        <copyright>Copyright (C) 2015 domain.com</copyright>
        <atom:link href="http://mydomain.dev/articles/rss.xml" rel="self" type="application/rss+xml" />

@foreach ($rss as $article)

            <item>
                <title>{{ $article->title}}</title>
                <linl>#</linl>
                <pubDate>{{ $article->published_at}}</pubDate>
                <guid>{{ $article->id}}</guid>
                <description>{{ $article->description}}</description>
            </item>

@endforeach

    </channel>
</rss>

jasonb left a reply on View As An Rss Feed Issue • 2 years ago

I am returning the view like this"

return view('articles.feed', compact('rss'));

I read I need to return like this:

return Response::make($content, '200')->header('Content-Type', 'text/xml');

But how do I do that with a view file?

jasonb started a new conversation View As An Rss Feed Issue • 2 years ago

I am trying to create a view that will be an rss feed. When I put the first line in:

<?xml version="1.0" encoding="ISO-8859-1"?>

I get : FatalErrorException in aa4ff9d1db2560875fcf9c481c3e288c line 1: syntax error, unexpected 'version' (T_STRING)

How can I pass this through? the view file is rss.blade.php

is it the <? loading? How should I do this?

21st March, 2015

jasonb left a reply on Class 'App\Articles' Not Found • 2 years ago

@Ruffles That is it! =) Article.php not plural. /facepalm

jasonb started a new conversation Class 'App\Articles' Not Found • 2 years ago

Going through the lesson Many to Many Relations (With Tags).

When I run:

$tag->articles->toArray();

From tinker I get this error: [Symfony\Component\Debug\Exception\FatalErrorException] Class 'App\Articles' not found

my Tag model has:

 public function articles()
    {
        return $this->belongsToMany('App\Articles');
    }
}

Why would I be getting this error?

jasonb left a reply on Cannot Add Foreign Key Constraint • 2 years ago

That was most likely it.

jasonb left a reply on Cannot Add Foreign Key Constraint • 2 years ago

So my question is how did Jeff do this and not get any errors? https://laracasts.com/series/laravel-5-fundamentals/episodes/21 Start 6.00 into the video.

The migration I did was identical. Very frustrated. =)

20th March, 2015

jasonb left a reply on Cannot Add Foreign Key Constraint • 2 years ago

CREATE TABLE `article_tag` (
  `article_id` int(11) NOT NULL DEFAULT '5',
  `tag_id` int(11) NOT NULL DEFAULT '5',
  PRIMARY KEY (`article_id`),
  KEY `tag_id` (`tag_id`),
  CONSTRAINT `article_tag_ibfk_1` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`tag_id`) ON DELETE CASCADE,
  CONSTRAINT `article_tag_ibfk_2` FOREIGN KEY (`article_id`) REFERENCES `articles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

jasonb left a reply on Cannot Add Foreign Key Constraint • 2 years ago

I think I figured it out. In Sql Pro For the ID's I unchecked Unsigned. I was then able to run this from the Sequel Pro Gui.. I am not sure how the migration can fix this. I Guess this is an issue with MySQL?

jasonb left a reply on Cannot Add Foreign Key Constraint • 2 years ago

This is driving me nuts! =) I just don't see why the foreign key wont work. I even tried this inside of Sequel Pro and it doesn't work.

Edit Your Profile
Update

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