vkronlein

Owner / Lead Developer at Periapt, LLC.

Experience

38,710

1 Best Reply Awards

  • Member Since 3 Years Ago
  • 434 Lessons Completed
  • 3 Favorites

15th October, 2018

vkronlein left a reply on API Calls From Datatables Not Authorized • 12 hours ago

@jlrdw @Cronix

It's not a datatables issue, I can't hit anything inside the auth:api middleware, even the default

axios.get('/api/user')
    .then(response => {
        console.log(response.data);
    });

fails using both axios and jquery. Always returns 401 Unathorized with the Unauthenticated message.

And before you ask, I do have passport set as my auth driver for the api routes.

@D9705996

Yes, when I remove the routes from behind the middleware it works perfectly.

Here's the code that's inside the view, not sure how this would help but as requested:

@push('scripts')
    <script>
        $(document).ready(function() {
            $('#datatable-users').DataTable({
                'processing': true,
                'serverSide': true,
                'ajax': '/api/datatables/users',
                'pageLength': 25
            });
        });
    </script>
@endpush

vkronlein started a new conversation API Calls From Datatables Not Authorized • 23 hours ago

Hello all.

I have some datatables being called via api in some views. There exist from the previous developer.

I just realized that they were outside of any authentication and available to the public, so I moved it inside of the auth:api middleware and not I get a 401.

Route::group(['middleware' => 'auth:api'], function() {
    //dd(request()->cookie('laravel_token')); // always produces a valid token
    Route::get(
        '/datatables/users', 
        'Builder\[email protected]'
    );
});

I included the CreateFreshApiToken middleware from Passport and with the commented out dd call I can see that a valid token is being sent on each request.

Why would I be getting a 401?

12th October, 2018

vkronlein left a reply on Relationships Always Null • 3 days ago

@Cronix

I figured, but those aren't the id's from the table.

@staudenmeir

Changed the incrementing but no love, also needed to add keyType = 'string' and then this did the trick.

Thanks everyone for all your help, much appreciated.

vkronlein left a reply on Relationships Always Null • 3 days ago

@staudenmeir

They are the standard Passport migrations, let me grab them from github.

public function up()
{
    Schema::create('oauth_access_tokens', function (Blueprint $table) {
        $table->string('id', 100)->primary();
        $table->integer('user_id')->index()->nullable();
        $table->integer('client_id');
        $table->string('name')->nullable();
        $table->text('scopes')->nullable();
        $table->boolean('revoked');
        $table->timestamps();
        $table->dateTime('expires_at')->nullable();
    });
}

public function up()
{
    Schema::create('oauth_refresh_tokens', function (Blueprint $table) {
        $table->string('id', 100)->primary();
        $table->string('access_token_id', 100)->index();
        $table->boolean('revoked');
        $table->dateTime('expires_at')->nullable();
    });
}

vkronlein left a reply on Relationships Always Null • 3 days ago

@staudenmeir

array:2 [▼
  0 => array:3 [▼
    "query" => "select * from `oauth_access_tokens`"
    "bindings" => []
    "time" => 0.38
  ]
  1 => array:3 [▼
    "query" => "select * from `oauth_refresh_tokens` where `oauth_refresh_tokens`.`access_token_id` in (?, ?, ?, ?, ?, ?, ?, ?)"
    "bindings" => array:8 [▼
      0 => 0
      1 => 3
      2 => 13
      3 => 44
      4 => 85
      5 => 2855414
      6 => 5850233
      7 => 8646257075
    ]
    "time" => 0.63
  ]
]

Can you explain what the bindings are here?

vkronlein started a new conversation Relationships Always Null • 3 days ago

I'm sure I must be missing something simple.

I've created local models for the OAuth tables created by Passport.

I'm trying to create a one to one relationship between oauth_access_tokens and oauth_refresh_tokens

As per the docs:

Eloquent determines the foreign key of the relationship based on the model name.

The refresh table column is access_token_id to reference the parent table id.

namespace App;

use Illuminate\Database\Eloquent\Model;

class AccessToken extends Model
{
    protected $table = 'oauth_access_tokens';

    public function refresh()
    {
        return $this->hasOne(RefreshToken::class);
    }
}

As per the docs:

Eloquent determines the default foreign key name by examining the name of the relationship method and suffixing the method name with _id. However, if the foreign key on the Phone model is not user_id, you may pass a custom key name as the second argument to the belongsTo method.

Thusly if my column name is access_token_id and my method name is access_token My belongs to model should like like so:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class RefreshToken extends Model
{
    protected $table = 'oauth_refresh_tokens';

    public function access_token()
    {
        return $this->belongsTo(AccessToken::class);
    }
}

It seems that the relationships are created because I can eager load them without any errors, but they are consistently null. For both relationships.

If I call either of these:

$tokens = AccessToken::with('refresh')->get();

foreach ($tokens as $token) {
    $token->refresh // always has a value of null
}

$tokens = RefreshToken::with('access_token')->get();

foreach ($tokens as $token) {
    $token->access_token // always has a value of null
}

What am I missing, this usually just works without a problem.

Thanks

1st September, 2018

vkronlein left a reply on File Not Found For Download • 1 month ago

@Dry7

Uh ... no. These downloads aren't public, aside from which, I already have the storage link set up.

31st August, 2018

vkronlein started a new conversation File Not Found For Download • 1 month ago

I'm getting a FileNotFoundException using the Storage Facade when the file is indeed there. I'm looking at it in the damn folder. The path and filename are correct, I've triple checked everything ...

The weird part is I'm downloading it from another section via controller using response()->download($same->path) and it works perfectly.

If I use Storage::get($same->path) it returns the file as a string ... but the download method can't seem to find it.

I've read the docs ... and I missing something obvious?

Thanks.

14th July, 2018

vkronlein started a new conversation Single Form For New And Editing Data • 3 months ago

Can anyone tell me what's the best way for handling data for a form so that I can use my form for both editing an existing data object, or creating a new one?

If an item is being editing it's being pulled in via mapGetters from Vuex, but it seems like if I'm doing it this way the new item form doesn't work correctly.

Should I create individual props for each form field and set them to null or data based on my pulled in Vuex computed props or is there an easier way to format this so it works consistently?

Any help would be greatly appreciated.

If you need any code please let me know what you want to see and I'll happily post it up.

29th June, 2018

vkronlein started a new conversation Computed Property Won't Render • 3 months ago

I can't figure this one out.

I have a vuex-binding in my component that shows in the vue dev tools as correctly populated, then an additional computed property to select a given key from the object.

but when I try and render that property as v-html or v-model it throws an error "TypeError: Cannot read property '1' of null"

computed: {
    ...mapGetters({
        instructions: 'wizard/instructions'
    }),
    standard() {
        return this.instructions[this.isActive]
    }
},

In the above,

isActive is numerical and represents a given key of the property to load

In my vuex dev tool I have

data
    isActive: 1
    isOpen: false

computed
    standard: "the html of the correct instruction"

vuex bindings
    instructions: Object

In my template I have a simple bootstrap panel body div

<div class="panel-body" v-html="standard"></div>

If I remove the binding to standard in the div the error stops, but with it in I get the error.

Any ideas would be helpful.

Thanks.

18th June, 2018

vkronlein left a reply on Extending ConsoleMakeCommand • 3 months ago

@bobbybouwmann

Yeah honestly I think that should be changed for abstract methods. The purpose of declaring something abstract is so that it has no set up, which I think should include the signature.

We already have strict signature enforcement on Interfaces ...

Anyway, I was able to resolve it using reflection and middleware, but it should be easier to resolve this type of problem.

Thanks.

16th June, 2018

vkronlein left a reply on Extending ConsoleMakeCommand • 4 months ago

@bobbybouwmann

How would I go about enforcing that a class has a given method, but making the signature flexible?

For instance I want to make my action classes all adhere to an interface that includes the __invoke() method but can also have variables passed in, or be able to type hint classes in the signature.

I tried this:

namespace App\Domain\Contracts;

interface ActionContract
{
    public function __invoke($class = null);
}

Then in my action :

public function __invoke(UserRepository $users)
{
    return $this->responder->send();
}

But I'm getting the dreaded must be compatible with error.

I want to ensure that the actions aren't creating traditional crud methods in order to keep the SOC principle intact by default.

I'll also need this type of functionality for my Service classes as I want to force the handle method to receive some optional params while enforcing others.

Thanks.

15th June, 2018

vkronlein left a reply on Extending ConsoleMakeCommand • 4 months ago

@bobbybouwmann

Yeah normally I would agree with you, but I really like the idea of ADR a lot. And I think the pattern in general is better for modern web apps. I'm constantly trying to clean up controllers and keep SOC and DRY principles.

@JeffreyWay has really helped me clean up my coding and reusability principles, and at least for me, ADR is the next step in this journey.

Thanks again for the assist.

vkronlein left a reply on Using Different Namespace For Controllers And How App\Http\Controllers Works. • 4 months ago

Yeah I would recommend reading up on autoloading in PHP so you'll better understand how classes and files are loaded.

(PSR)[https://www.php-fig.org/psr]

vkronlein left a reply on Trying To Get Property Of Non Object • 4 months ago

Wow ... this is like a skit on SNL.

vkronlein left a reply on Extending ConsoleMakeCommand • 4 months ago

@bobbybouwmann

I'm such and idiot ....

Look at the namespace .... should be Commands not Command

Thanks for your help man.

I'd love to get your opinion on how I've structured everything if you're interested.

https://source.codemafia.io/codemafia/laravail

14th June, 2018

vkronlein left a reply on Extending ConsoleMakeCommand • 4 months ago

@bobbybouwmann

Any ideas?

All my other commands are working great.

vkronlein left a reply on Extending ConsoleMakeCommand • 4 months ago

<?php

namespace App\Domain\Console\Command;

use Illuminate\Foundation\Console\ConsoleMakeCommand as BaseConsoleMakeCommand;

class ConsoleMakeCommand extends BaseConsoleMakeCommand
{
    /**
     * Get the stub file for the generator.
     *
     * @return string
     */
    protected function getStub()
    {
        return __DIR__.'/stubs/console.stub';
    }

    /**
     * Get the default namespace for the class.
     *
     * @param  string  $rootNamespace
     * @return string
     */
    protected function getDefaultNamespace($rootNamespace)
    {
        return $rootNamespace.'\Domain\Console\Commands';
    }
}

vkronlein started a new conversation Extending ConsoleMakeCommand • 4 months ago

I'm creating an ADR version of the latest version of Laravel, mostly for my own use, but I will make it public for anyone who wants it.

As part of this I've moved all domain related stuff inside the domain directory, so this requires creating new make commands for generating classes to the correct location.

For all of these it's been very straightforward, create a new MakeCommand which extends the original one, change the namespace section, copy over the stub and make whatever changes are needed and register it in the Kernel.

Until ... the ConsoleMakeCommand.

 Whoops\Exception\ErrorException  : Cannot declare class App\Domain\Console\Command\ConsoleMakeCommand, because the name is already in use

  at /Users/vincek/Code/adr/web/app/Domain/Console/Commands/ConsoleMakeCommand.php:29
    25|     protected function getDefaultNamespace($rootNamespace)
    26|     {
    27|         return $rootNamespace.'\Domain\Console\Commands';
    28|     }
  > 29| }
    30| 

This error doesn't make sense to me, I can't declare it in the file it's in, because it's already declared in the file it's in .... what the heck?

Can anyone explain to me how I can get this done?

Thanks.

6th June, 2018

vkronlein left a reply on LetsEncrypt 'ERROR: Challenge Is Invalid!' On Forge • 4 months ago

What extra file?

22nd April, 2018

vkronlein left a reply on Service Provider Not Publishing Config File • 5 months ago

@Cinek

All the paths are good, as I said, it will publish if I select it from the list with just

php artisan vendor:publish

Perhaps I need quotes around my class name?

vkronlein started a new conversation Service Provider Not Publishing Config File • 5 months ago

In my package, I have a config file to publish but in 5.6 it won't publish the file:

public function boot()
{
    $this->publishes([
        __DIR__ . '/../config/generator.php' => config_path('generator.php'),
    ]);
}

When I run:

php artisan vendor:publish --provider=Empress\Generator\GeneratorServiceProvider

All I get is Publishing complete. but nothing is published.

It will however publish if I use just

php artisan vendor:publish

I can then select the provider from the list and it does publish.

Is there something I'm missing here or something that's changed?

Thanks.

29th March, 2018

vkronlein left a reply on Laravel Is A Giant Waste Of Time • 6 months ago

HAHAHAHAHAHA This was the best thing I've seen all month!

And to think it's been here for 2 years. Awesome.

Poor old @dazed067 is probably rocking a mullet and a Motorola flip phone, cause you know ... it takes a minute to set up that stupid iPhone ... I just wanna turn it on and start dialing.

Fabulous!

vkronlein started a new conversation API Resource Custom Conditional Pivot • 6 months ago

The documentation stays to do a conditional pivot I have submit a closure like so:

public function toArray($request)
{
    return [
        'id' => $this->id,
        'name' => $this->name,
        'expires_at' => $this->whenPivotLoaded('role_users', function () {
            return $this->pivot->expires_at;
        }),
    ];
}

I have a resource that requires 10 different columns from the same pivot table, is there not a way to wrap these all within the same closure? Seems nuts to have to whenPivotLoaded 10 different times on the same pivot table.

Anyone?

27th March, 2018

vkronlein left a reply on Checking For Deep Nested Relations For APIResources • 6 months ago

@ahmedmsvb

Thanks. I searched but didn't find that one. That might work.

vkronlein started a new conversation Checking For Deep Nested Relations For APIResources • 6 months ago

Hey All.

I have a project I've taken over that's already in production, so no blame for the database design please =)

I've been tasked to build an API which is coming along nicely, but I've run into a snag that I'd like to resolve, it's not life ending, but if there's a way to accomplish this I'd like to.

I'd like to be able to omit certain columns from my resource depending on whether relations and nested relations are loaded.

Here's the case I'm working on.

  1. My record model has a product relationship
  2. My product model has a company relationship
  3. The records table has both a company_id and product_id

I'd like to show the model resource if the model has been loaded, or else the column value if not.

For direct relations this is a snap

In RecordResource:

$product = $this->relationLoaded('product') 
            ? new ProductResource($this->product) 
            : $this->product_id;

return [
    'id' => $this->id,
    'company_id' => $this->company_id,
    'format_id' => $this->format_id,
    'stage_id' => $this->stage_id,
    'archived' => $this->archived,
    'created' => $this->created_at->format('Y-m-d H:i:s'),
    'updated' => $this->updated_at->format('Y-m-d H:i:s'),
    'published_filename' => $this->published_filename,
    'published_at' => $this->published_at,
    'screened' => $this->screened->format('Y-m-d H:i:s'),
    'inventory_type' => $this->inventory_type,
    'leed_calc' => $this->leed_calc,
    'leed_display' => $this->leed_display,
    'no_accessory' => $this->no_accessory,
    'product'  => $product,
];

In ProductResource:

$company = $this->relationLoaded('company') 
            ? new CompanyResource($this->company) 
            : $this->company->name;

return [
    'id' => $this->id,
    'name' => $this->name,
    'archived' => $this->archived,
    'created' => $this->created_at->format('Y-m-d H:i:s'),
    'updated' => $this->updated_at->format('Y-m-d H:i:s'),
    'company' => $company,
];

These work perfectly since they are direct relations.

But if you look in the RecordResource array, I'd like to be able to remove the company_id key if company has been loaded in the ProductResource.

I know that having that company_id in the table is redundant, but once again I didn't design the database and there's no changing it now.

Is there a way to test whether the company has been loaded from within the RecordResource given that it's nested?

Thanks.

4th November, 2017

vkronlein left a reply on 2 Domains | 1 IP - NGINX • 11 months ago

What do you mean by non-descript error what does the error say exactly?

Did you ping and dig the domain to make sure the DNS is correct?

It could be that Bluehost didn't destroy your DNS file, but if you've changed the nameservers at your host, or the IP at the DO DNS that shouldn't matter I don't think.

OpenDNS has a nice tool I always use when I switch servers to help update the worldwide DNS cache. It seems to work pretty well with Linode servers, I haven't used DO in quite a while.

https://cachecheck.opendns.com

Give us an update once you resolve it, this is always a good bit of knowledge to have.

vkronlein left a reply on Best Practice: Laravel Echo Server • 11 months ago

@carlituxman

I installed it the normal way. SSH into your server and install it globally.

npm install -g laravel-echo-server

19th October, 2017

vkronlein started a new conversation Broadcast An Event On Multiple Private Channels? • 11 months ago

Each of my users already has their private channel in the footer of our layout.

Echo.private('{{ auth()->user()->username }}')

When a someone they follow makes a new post, I'd like that event to be broadcast to their private channel, so that they'll see it no matter where they are on the site.

How can I set my broadcastOn method to send to each of the follower's private channel?

Thanks.

18th October, 2017

vkronlein left a reply on Detecting And Empty Model When Passed Via Route Model Binding • 11 months ago

@sutherland

I tried that but still got an error.

I decided to just pass the username to the route for all calls, it was more consistent that way anyway.

Thanks though.

14th October, 2017

vkronlein started a new conversation Detecting And Empty Model When Passed Via Route Model Binding • 1 year ago

Hey All.

In my API routes I have a route that optionally passes in a filled Profile model.

Route::get('/post/profile/{profile?}', '[email protected]');

This is used to pull in posts for a Vue profile page, so it has to be dynamic, if a username is passed, it will receive the model and query the posts for that user, if no username is passed, it will query the posts for the request user.

The problem I'm having is that no matter whether the username is passed or not, I get an instance of the model, it's just empty if no username was passed.

I tried calling isEmpty, but since it's not a collection that fails, I tried is_null but that fails, obviously boolean will fail.

How can I test if the model has data in my controller?

5th October, 2017

vkronlein left a reply on Laravel Echo Server With Laravel Forge • 1 year ago

Running this as a daemon on Forge adds it to supervisor, so it should restart on a server reboot or if it dies.

The daemon also allows you to set the user, I run mine as root without any issues. You could simply add the forge user to the group that owns the certificates and you should be able to read them from the echo server and you could run the daemon as the forge user.

4th October, 2017

vkronlein started a new conversation Laravel Echo Broadcasters • 1 year ago

Is it possible to use something besides pusher or socket.io with Echo? ZMQ or pub-sub.js?

I installed ZMQ and created a driver for it, but I can't seem to get the sub piece running. How can I read messages off of my pub driver in javascript?

3rd October, 2017

vkronlein left a reply on Converting 5.0 To 5.4 • 1 year ago

@36864

Thanks I didn't even know those were there.

Anyone else can chime in as well here ... so my understanding, looking at the upgrade guide is that Commands have become Jobs that contain their own handle method eliminating the Handlers for commands.

All the logic in the former Handlers\Commands\ExampleHandler::handle method would be added to the new Job class.

class ExampleJob extends Job implements ShouldQueue
{
        use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function __construct()
    {
        // build up public objects here
    }

    public function handle()
    {
        // all logic from former handler here
    }

}

Then I would just call the Job in my controller or wherever?

ExampleJob::dispatch();

// or

dispatch(new ExampleJob());

vkronlein left a reply on Converting 5.0 To 5.4 • 1 year ago

@Dibya

That has absolutely nothing to do with what I asked. Socialite is a package to allow logins from other social networks. Completely irrelevant.

Thanks though.

vkronlein started a new conversation Converting 5.0 To 5.4 • 1 year ago

Hey All!

I'm working on a project at the moment for a client who wants social components, basically Twitter as part of the larger app.

I found Will Harrison's Twitter clone which has all the components I'm looking for, but it's built in 5.0 and I'm seeing a lot of differences in terms of how things are structured.

Mainly in terms of Commands. Events and Handlers, so I wanted to get some clarification from you guys to make sure I'm going in the right direction.

It looks like in 5.0 Commands required handlers to basically listen for commands? Am I right in understanding that Commands now have their own internal handlers?

And Events now have Listeners ... those have replaced the old Handlers/Events?

Appreciate the help.

-V

27th September, 2017

vkronlein left a reply on Dynamic Select Menu From Ajax Vue 2 • 1 year ago

@Lars-Janssen

Thanks man, I found it ... I forgot the = sign ...

v-for"item in items" 

DOH!

vkronlein started a new conversation Dynamic Select Menu From Ajax Vue 2 • 1 year ago

This is driving me insane!

My component:

<template>
    <select v-material-select="selected" id="fiat">
        <option 
            v-for"item in items" 
            :value="item.code" 
            :data-quote="item.quote">{{ item.name }}
        </option>
    </select>
</template>

<script>
export default {

    name: 'FiatList',

    data () {
        return {
            items: [],
            selected: null
        };
    },

    created () {
        axios.get('/ajax/fetch-fiat')
             .then((response) => {
                this.items = response.data

                $('#fiat').material_select();
        });
    },
};
</script>

Why do I keep getting this error:

[Vue warn]: Property or method "item" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.

item is just the iterator for items ...

Items are being set with the following json from my controller:

[
    {
        "code": "USD",
        "quote": 1,
        "name": "US Dollar"
    },
    {
        "code": "GBP",
        "quote": 0.74581,
        "name": "British Pound"
    },
    {
        "code": "EUR",
        "quote": 0.85172,
        "name": "Euro"
    },
    {
        "code": "CHF",
        "quote": 0.9753,
        "name": "Swiss Franc"
    },
    {
        "code": "CAD",
        "quote": 1.2396,
        "name": "Canadian Dollar"
    },
    {
        "code": "AUD",
        "quote": 1.2737,
        "name": "Australian Dollar"
    },
    {
        "code": "INR",
        "quote": 65.712,
        "name": "Indian Rupee"
    },
    {
        "code": "JPY",
        "quote": 112.94,
        "name": "Japanese Yen"
    },
    {
        "code": "CNY",
        "quote": 6.642,
        "name": "Chinese Yuan"
    },
    {
        "code": "SEK",
        "quote": 8.1667,
        "name": "Swedish Krona"
    }
]

Need some help please!

26th September, 2017

vkronlein left a reply on Connect To Remote MySQL Using SSL • 1 year ago

Did you try it without the protocol?

Other than that, perhaps the port is different over SSL? Or maybe the firewall isn't open for 3306 for secured traffic?

Check those.

vkronlein left a reply on Why Linux Is Prefer For Web Development? • 1 year ago

Yeah Windows servers are a pain in the ass, so most hosting companies don't mess with them. Plus the licensing through Microsoft is very expensive.

Linux/Unix hosting will always be the standard, or at least for the foreseeable future anyway.

vkronlein left a reply on Connect To Remote MySQL Using SSL • 1 year ago

@ashishsanjayrao

Have you tried just using the IP address?

I know when connecting to a remote AWS MySQL instance we didn't use any protocol just the hostname.

DB_HOST=yourconnectionprovider.com

Also check in cPanel that MySQL is allowing remote connections, perhaps that's changed since you connected last.

vkronlein left a reply on Undefined Variable • 1 year ago

I don't understand what your Voyager models are.

Are they Eloquent models? I could be wrong, but I don't think you can create relationships on non-Eloquent models, at least I've never seen it done.

You have models in TCG\Voyager\Models then you have other models in App, I can't make any sense of this code.

I would suggest you make your models in a single location App

If you need to pull in some other class do it there.

namespace App;

use TCG\Voyager\Models\Post;
use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    // new up your Post model if you need to
}

This is just a guess really ... the code doesn't make a whole lot of sense as is.

25th September, 2017

vkronlein left a reply on Undefined Variable • 1 year ago

If you dd your $tutorials collection in the show method on TutorialController are you getting any results?

I'm a bit confused with your terminology for your variables, you're calling first on the model so you're only going to get a single row. I would suggest you use route model binding like so:

public function show (Tutorial $tutorial)
{
    return view('tutorial.show')->compact('tutorial');
}

As for your index view ... you haven't set the $tutorial variable in your controller, only $tutorials ....

Also I would suggest you eager load your relationships in the index so you don't make so many calls to the db:

public function index()
{
  $tutorials = Tutorial::with('category')->paginate(12);

  return view('tutorial.index', compact('tutorials'));
}

vkronlein left a reply on Slug Routing • 1 year ago

@sutherland

Well that was stupid easy .... geez

thanks man.

vkronlein left a reply on Undefined Variable • 1 year ago

Are you passing a Tutorial model to your view?

Showing your Controller might help.

vkronlein started a new conversation Slug Routing • 1 year ago

Hey All.

My client wants all his database stored pages routed as top level links ie: example.com/terms-of-service

So for the pages table we have title, slug and content. In the Page model I've set the route keyname to slug but I can't figure out how to set the route so that if the slug is not found, continue to search for the called route.

I have this ... which does work if the route is found:

Route::get('/{page?}', function($page) {
    $item = Page::where('slug', $page)->first();
    
    if (! is_null($item)) {
        $page = new \App\Controllers\PageController();
        return $page->index($item);
    }

    return;
});

But if the page model isn't found, I just get a blank page. How do I get it to continue on and look for dashboard or whatever non-page route is called?

Thanks.

21st September, 2017

vkronlein left a reply on Module Not Found: Error: Can't Resolve 'fs' • 1 year ago

@xsigns @ibrahem

You can resolve this in your Laravel Mix file like so:

mix.webpackConfig({
    node: {
      fs: "empty"
    },
    resolve: {
        alias: {
            "handlebars" : "handlebars/dist/handlebars.js"
        }
    },
});

19th September, 2017

vkronlein left a reply on Force The User To Validate The Mail To Navigate In The App • 1 year ago

@Sylvert

Yeah you can use some middleware for that, and I have a custom Activatable trait that I use to force users to verify their email address.

When the user registers it fires a confirmation email, which then activates their account.

If you're interested in that just let me know I can post all the steps here for you. =)

vkronlein left a reply on Can I Specify My Custom Variable Or Constant In App.php Laravel • 1 year ago

@sam0081

Yes.

'my_custom_variable' => 'foobar'

Then you can access it via:

config('app.my_custom_variable');

You could set a constant as well, but in my mind those should be avoided when you can, use a config variable.

vkronlein left a reply on Deploy Laravel Project To The Webserver • 1 year ago

Hello.

Congrats on your project.

My suggestion, (for what it's worth), is that you should host your site on Laravel Forge, or at least on a platform that allows you to utilize all the features of Laravel.

You've taken the time to build your project on the best PHP framework, why host it someplace that doesn't let you manage any of the things you need to?

You'll be extremely limited in what you can do in a shared hosting environment, and while it'll cost you a few dollars more per month to use Forge and either DigitalOcean or Linode, you'll have a much better experience and be able to take advantage of the true power of what you've built.

As someone who always tried to host on the cheap in the past, I can tell you first hand, once I became aware of Forge, my life became a whole lot better.

I host everything there, development projects, live projects, and not just Laravel, I have several Ghost blogs and static sites, API documentation, and so on.

When Taylor builds something, it works, and usually works like a friggin champ. Give it a look before you mess with that horrible shared hosting.

My 2 cents. =)

Edit Your Profile
Update

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