jakeryansmith

jakeryansmith

Member Since 5 Years Ago

Fort Wayne, IN

Web Developer at GrazeCart

Experience Points 30,440
Experience Level 7

4,560 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 337
Lessons
Completed
Best Reply Awards 17
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.

08 May
1 week ago

jakeryansmith started a new conversation Updating JSON Columns In PostgreSQL (Missing In Docs?)

Hi, the Laravel 5.8 docs it says: "When updating a JSON column, you should use -> syntax to access the appropriate key in the JSON object. This operation is only supported on MySQL 5.7+"

But according to this: https://github.com/laravel/framework/commit/ddf6caee01186cb07dd87da1168a249e06e556c7

Shouldn't it also be working in PostgreSQL? Or am I missing something? Thanks!

25 Oct
6 months ago

jakeryansmith left a reply on User Customizable Table Columns

Yeah, I figured that was maybe the case. But the question is, how would you go about doing this with blade? One possible option would be to generate a blade partial for the row each time the user updates their preferences, and save it to storage, then load that partial inside each row and pass in that particular row item?

24 Oct
6 months ago

jakeryansmith left a reply on User Customizable Table Columns

Thanks @bobbybouwmann Sorry I should have been more clear, I wasn't concerned about how to implement the actual end-user experience. I have that part figured out. I was more wondering about the actual process of defining the table structure when rendering, specifically if having a loop for each table row was the best way to go about this, or if there was a more efficient way. Or maybe it's not a big deal? I don't expect any of these table to be more than 100 rows long. Thanks!

23 Oct
6 months ago

jakeryansmith started a new conversation User Customizable Table Columns

I'd like to be able to let my users control which columns to display in a table. I have a few standard columns that will always display, but I want them to have the option to select from like 3-5 additional columns to display. I'd also like them to be able to control the order they appear. I've seen this done in other apps, like Drip for example.

I have one idea for how to make this happen, which looks like this:

`@foreach($items as $item)

@foreach($columns as $column) {{ $item->present($column) }} @endforeach @endforeach `

I simply pass the columns array, which is pulled from the database and can be updated by the user. This is passed to a presenter method on the item which then calls the appropriate presenter method for that column, or defaults to a property with that column name.

I know I can make this work, I just wanted some feedback on whether this was a good approach, if there were performance concerns with having a loop embedded in a loop. How do other people handle this?

Thanks!

11 Apr
1 year ago

jakeryansmith started a new conversation E-signatures

Does anyone have any suggestions on an affordable service that would let me integrate e-signatures into a Laravel app?

26 Feb
1 year ago

jakeryansmith left a reply on Weird Things With Permissions And Stale Code After Updating Server.

So I noticed when monitoring my server on Digital Ocean it lists both PHP php-fpm7.1 and php-fpm7.2. I wonder if Envoyer is restarting php-fpm7.1 instead of php-fpm7.2? Any suggestions on what to do here?

jakeryansmith started a new conversation Weird Things With Permissions And Stale Code After Updating Server.

Here is the problem: Anytime I deploy new code can't see the changes when running my app. I can confirm the code is being updated on the server and that the new code is in the latest releases directory. But when I try to run my app it behaves as it did before the changes.

This started happening after I did these updates on my server:

  1. Updated to PHP 7.2 via Forge
  2. Resized my droplet via Digital Ocean.

I'm not sure which one of these caused the problem as I did them around the same time. Nothing else has changed so I'm pretty sure one of those things is the culprit.

First I noticed that my app couldn't write to my storage directory. So I'm guessing the permissions somehow got changed. I just set the storage directory and everything in it to 777 and that fixed the issue of my app not being able to write to the directory worked. But I still get no code updates when I deploy.

I have the same app running on a different server with PHP 7.2 and provisioned by forge and it does not have this same issue, so I don't think it's my code.

Any help would be much appreciated!

12 Feb
1 year ago

jakeryansmith left a reply on Weird Issue With Queued Jobs Not Processing

I'm using beanstalkd and have the Beanstalkd Admin UI installed (https://github.com/Dionera/laravel-beanstalkd-admin-ui) that's how I was able to see how many jobs I have and that there was a backlog.

I might have to give Horizon a look though.

jakeryansmith started a new conversation Weird Issue With Queued Jobs Not Processing

So I have a strange issue with my queue workers, and I would be very grateful for any help figuring this out.

Basically, my queue workers will just stop working after certain jobs are pushed to the queue. I'll end up with 100s of jobs backlogged in the queue waiting to be processed. These workers are started via Forge, and when I check the worker status I get this error: FATAL Exited too quickly (process log may have details)

I've checked the logs but they are always empty. Also, there aren't any failed jobs saved to the database.

What's really odd is that if I manually restart the worker in Forge, it will process maybe 10-20 jobs but then quite again given the same error. I can keep manually restarting the queue until all the jobs are processed.

It only stops when trying to run certain jobs. These jobs run without any errors, so I'm not sure why they are causing problems, they just seem to cause the worker to stop.

The only thing I can think of is they are causing a memory leak which stops the worker, but shouldn't supervisor restart the queue worker automatically since these are set up with Forge?

Does anyone have any ideas what causes this?

Thanks!

04 Feb
1 year ago

jakeryansmith started a new conversation Setting Queue Priority In Forge

The documentation is clear on how to set queue priority using comma-delimited list of queue names like this: queue:work --queue=high,low.

What I'd like to know is how this is set up with Forge? Do I just enter "high,low" in the Queue field like this: https://d.pr/free/i/RtP0sc

Thanks!

18 Mar
3 years ago

jakeryansmith started a new conversation Bootstrap Modal In Component Not Binding To Component Data.

I'm trying to create a component with a bootstrap modal, and I would like to have inputs inside the modal that are bound to the data in my component, but instead it tries to bind the input to data on the parent Vue instance. I think it has something to do with the modal having display:none applied to it when the page loads, because if I remove that it will bind to the components data. Anyone have any ideas how best to handle this?

01 Mar
3 years ago

jakeryansmith started a new conversation Unique Problem With Forge And LetsEncrypt

Ok so I have 1 installation of a Laravel app on a server managed by forge. This is a multi-tenant app, and I want to allow custom domains to be directed to this, and also have SSL certs using LetsEncrypt. This is what I did to get this to work:

  1. Create a new site for the custom domain; example mycustomdomain.com.
  2. I create an SSL cert for this site.
  3. I edit the Nginx config file to point this site to the directory with my multi-tenant app.

This all works fine, but now I've realized that I can't update my certs because Forge is looking in the directory of the mycustomdomain.com site for the info on the cert. Which was the whole reason I had to create the site first as per step 1 - 2. I just didn't think about having to update them and that the process would be the same.

So my question is how can I go about updating my certs with this kind of setup, or is it even possible? I know I can edit the Nginx config again and temporarily change the path back to update the cert, but this of course will mean the site goes down, and I would have to still somehow manually trigger this each time. Is there a better way to do this? Are there other ways to update a certificate? Thanks for any help!

28 Jan
3 years ago

jakeryansmith left a reply on Bulk Update

MySQL does not provide a way to do bulk updates in one query. But I think if you put multiple queries inside a transaction it will execute with one connection, but I'm not 100% sure.

02 Jan
3 years ago

jakeryansmith started a new conversation Set The Server On The Fly For Envoy Task

I know I can define which server a task will run on, but is it possible to change this on the fly? I want to run the script first on a staging server, then run on a production server if staging was successful.

jakeryansmith left a reply on Using Envoy As Alternative To Envoyer But Having Trouble

@deringer Ok cool runig php5-fpm reload worked. Now it makes sense, it seems the problem wasn't nginx or even the symlink not working, it was as @bashy pointed out, PHP was caching the real path which was causing laravel to load old files when bootstrapping the application.

jakeryansmith left a reply on Using Envoy As Alternative To Envoyer But Having Trouble

@bashy Ok so you are saying that nginx is pointing to the correct release, it's just that when the index.php page is hit and bootstraps the application, it's still loading from the old release because the path has been cached?

jakeryansmith left a reply on Using Envoy As Alternative To Envoyer But Having Trouble

@deringer So I just tested it again, and had the same issue, but I noticed something. I went into my releases folded and delete the old releases then it started working.

jakeryansmith left a reply on Using Envoy As Alternative To Envoyer But Having Trouble

@deringer I already tried restarting nginx, it doesn't seem to matter. It doesn't seem like nginx would need restarted if all I am doing is changing an existing symlink, isn't that the point of the symlink, so it can be easily changed without disrupting anything?

Thanks!

jakeryansmith started a new conversation Using Envoy As Alternative To Envoyer But Having Trouble

With Envoyer being down, I thought I could write an Envoy script to handle my deployments in the interim. This is what I have so far for activating the latest release. The problem is the symlink seems to update fine (I can verify this point to the correct release using ls -l) but ngix wants to keep loading from the previous release, like it's ignoring the updated symlink and going of that it used to be. I can verify this by changing the name of the previous release, as this return the "no input found" error.

Here is part of my Envoy script:

ln -nfs /home/forge/myapp.com/releases/{{ $release }}/ /home/forge/myapp.com/current;

Any help will be much appreciated!

19 Dec
3 years ago

jakeryansmith left a reply on Adding New Domains With LetsEncrypt And Forge

@jdrzejb Ok that's what I figured. Thank you for your reply!

jakeryansmith started a new conversation Adding New Domains With LetsEncrypt And Forge

I know with LetsEncrypt you can add multiple domains at one time, but what do you do if you need to add another domain later? Like lets say initially I create a certificate for "www.mydomain.com, mydomain.com". But then a couple months later I need to add blow.mydomain.com. Is it possible to update the certificate, or do I need to create a new one? It's my understanding that you can only have 1 active at a time, sou would I have to create a new one for all 3 domains? Thanks!

17 Dec
3 years ago

jakeryansmith left a reply on Extremely Frustrated. Please Help!

@luceos As far as setting the database connection, the middleware works fine. The problem I was having involved setting other application configs. I assumed it was safe to dynamically set any configs in middleware, but I don't think this works for all configs. For example, the cache and session configs. I think I found a solution though, when I placed them in the app service provider it set the configs as expected, I'm sure this is probably the correct place to do this type of thing anyways. Thank you for your help!

@nfauchelle I would prefer a separate database. I've considered both options and a separate database makes the most sense. As I mentioned above, setting the database connection works fine, it was setting other app configs, like cache prefix, that was a problem. Some of my configs, like timezone need to be set dynamically from a database. I agree that my middleware is doing a lot, I plan to refactor it later. Thanks!

jakeryansmith left a reply on Extremely Frustrated. Please Help!

@luceos Thanks for your reply! So I'm trying to do this with a 'setContext' middelware:

DB::disconnect('tenant');

        $domain = parse_url($request->root());

        config(['cache.prefix' => $domain['host']]);

        $tenant = Cache::tags(['context'])->remember($domain['host'], 60, function() use ($domain)
        {
            return DB::connection('main')
                ->table('tenants')
                ->where('domain', $domain['host'])
                ->join('connections', 'connections.id', '=', 'tenants.connection_id')
                ->first();
        });

        if(is_null($tenant))
        {
            return response('The page you are looking for could not be found.', 404);
        }

        // Save the context to a session
        session(['context' => [
            'name' => $tenant->name,
            'tenant_id' => $tenant->tenant_id,
            'database' => $tenant->database
        ]]);

        $connection = [
            'driver'    => 'mysql',
            'host'      => $tenant->db_host,
            'database'  => $tenant->database,
            'username'  => $tenant->db_username,
            'password'  => $tenant->db_password,
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ];

        config(['database.connections.tenant' => $connection]);

        config(['database.default' => 'tenant']);

        // Set the applications timezone.
        $tz = setting('timezone', 'America/Fort_Wayne');
        date_default_timezone_set($tz);

        // Set the applications theme path.
        $themePath = base_path('public/client-files/'.$tenant->tenant_id.'/views');
        view()->addNamespace('theme', $themePath);

        // Set blade compiled view path
        $compiledViewPath = base_path('public/client-files/'.$tenant->tenant_id.'/storage/views');
        config(['view.compiled' => $compiledViewPath]);
        if(Schema::hasTable('settings'))
        {
            $settings = Cache::tags(['setting'])->remember('settings', 120, function()
            {
                return Setting::lists('value', 'key');
            });

            view()->share(['theme' => $settings]);
        }

        return $next($request);

I'm wondering if this is the right place for this? Or should I put this in a service provider?

I'll check out your link. Thanks!

jakeryansmith started a new conversation Extremely Frustrated. Please Help!

Creating multi-tenant apps is extremely frustrating. I wish there were more resources on the subject, especially pertaining to L5. All the resources out there seem to only talk about what database structure to use, then how to set the context. There has to be more to it than that, like how best to deal with cache, compiled blade templates, sessions, background tasks. I wish Jeffery would do a series on this.

I've been trying to figure it out, but I'm about to lose my mind.

Here is an example:

I've been noticing some weird inconsistencies in setting configs on the fly. For example:

config(['cache.prefix => 'tenant_1'])

At one point this was working fine, but now it seems to have no effect. It also seems that some configs can not be set on the fly, like sessions for example. Is this correct?

I just want multiple tenants to share 1 codebase, each with it's own database. Why does this have to be so difficult!

Thanks to anyone willing to help!

jakeryansmith started a new conversation Why Is Homestead-PHP-7 Returning XMLHttpRequest?

I recently set up the php7 branch of Homestead. After using it for a little while I noticed it started returning responses as XMLHttpRequest. Anyone have any idea why it would do this? Thanks!

jakeryansmith started a new conversation How To Session Config Dynamically? Really Confused.

Is it possible to dynamically set the session configuration using Config::set() ? It appears that "Illuminate\Session\Middleware\StartSession" gets called before all other middleware, regardless of what position it's in. Am I correct in thinking that the middleware should be called in the order it is set in Kernal.php ? I would like to set my session data dynamically with my own custom middleware, but it seems to have no effect. I confirmed that StartSession is being called first when I did a dd() in both he 'StartSession' and my custom middleware, it didn't matter if the custom middleware was listed first, the StartSession dd() was outputed. So is StartSession being called somewhere else? Is it possible to set the sessions config dynamically? Thanks!

16 Dec
3 years ago

jakeryansmith left a reply on Some Weird Stuff Going On With Requests And Middleware

It seems it might have to do with homestead/vagrant. I tried another project and it was treating all requests as ajax, returning everything in json. I ran vagrant halt / vagrant up and it seemed to fix it, for now. I am working with the PHP7 version of homestead, and I also ran vagrant provision while it was still running and never restarted it after... I'm guessing it's probably best to run vagrant provision when it's halted?

jakeryansmith started a new conversation Some Weird Stuff Going On With Requests And Middleware

So I am trying to make a multi-tenant site where each tenant has their own database. I created a middleware that gets the root domain then looks up the corresponding tenant in a database, if a match is found I then set the DB connection for that tenant. Here is that middleware:

public function handle($request, Closure $next)
    {
        DB::disconnect('tenant');

        $domain = parse_url($request->root());

        config(['cache.prefix' => $domain['host']]);
        config(['session.cookie' => $domain['host']]);
        config(['session.domain' => $domain['host']]);

        $tenant = Cache::tags(['context'])->remember($domain['host'], 60, function() use ($domain)
        {
            return DB::connection('main')
                ->table('tenants')
                ->where('tenant_id', $domain['host'])
                ->join('connections', 'connections.id', '=', 'tenants.connection_id')
                ->first();
        });

        if(is_null($tenant))
        {
            return response('The page you are looking for could not be found.', 404);
        }

        // Save the context to a session
        session(['context' => [
            'name' => $tenant->name,
            'tenant_id' => $tenant->tenant_id,
            'database' => $tenant->database
        ]]);

        $connection = [
            'driver'    => 'mysql',
            'host'      => $tenant->db_host,
            'database'  => $tenant->database,
            'username'  => $tenant->db_username,
            'password'  => $tenant->db_password,
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ];

        config(['database.connections.tenant' => $connection]);

        config(['database.default' => 'tenant']);

        return $next($request);

This seemed to work fine, but all of a sudden I started noticing some weird behavior. If I switch from one domain to another it starts treating all requests as an ajax request. I can't seem to track down the source, or why it would all of a sudden become and ajax request. It's definitely not an ajax request.

I was wondering what steps I needed to take in order to share 1 code base across multiple domains, ensuring there was no cross-over. For example, I figured out I needed to set the cache prefix so it was unique to each domain, but is there more I have to do? Do sessions need a unique prefix as well? If they are file based sessions do they need to be stored in unique folders for each domain?

Any help on this would be greatly appreciated!

15 Nov
3 years ago

jakeryansmith left a reply on PHPUnit Insists On Showing Null Value For Eloquent Modal.

My test could look as simple as this:

public function test_something_happens()
{
    $user = User::findOrFail(1);
    dd($user)
}

And that will show empty strings as NULL,

However, doing this anywhere outside of a test I do see empty strings. I'm wondering if this is normal behavior for PHPUnit? It seems odd that it would behave differently. Thanks.

11 Nov
3 years ago

jakeryansmith started a new conversation PHPUnit Insists On Showing Null Value For Eloquent Modal.

I have noticed that when running a test, PHPUnit turns any fields with an empty string into a null value.

Here is the output of doing a dd($user) in a test:

"shipping_street" => null
    "shipping_street_2" => null
    "shipping_city" => null
    "shipping_state" => null
    "shipping_zip" => null
    "billing_street" => null
    "billing_street_2" => null
    "billing_city" => null
    "billing_state" => null
    "billing_zip" => null

And here is the output if I dd($user) in say a controller:

 "shipping_street" => ""
    "shipping_street_2" => ""
    "shipping_city" => ""
    "shipping_state" => ""
    "shipping_zip" => ""
    "billing_street" => ""
    "billing_street_2" => ""
    "billing_city" => ""
    "billing_state" => ""
    "billing_zip" => ""

Why the difference? This is causing my test to fail becasue I keep getting the "Integrity constraint violation: 1048 Column 'shipping_street' cannot be null'" error.

Thanks!

08 Nov
3 years ago

jakeryansmith left a reply on Hitting POST Routes With Link.

@jlrdw I know how requests types work. That's not really what I'm asking. Thanks.

@Snapey Perhaps, that wasn't the best example. There are other use cases, such submitting a POST request with a link/button inside another form. I'm actually using it to fire an email from a dropdown menu, as it would take a lot of custom CSS work to get a form submit button to match the rest of the links and look like it belongs. You would never what to use a GET request for something destructive. Even if it's unlikely, you always run the risk someone could bookmark it or revisit it in their history. I thought this might be an easy way to submit POST requests from a link. Thanks.

06 Nov
3 years ago

jakeryansmith started a new conversation Hitting POST Routes With Link.

So I'm looking for some advice on whether this is a good idea or not. I have come across a few situation when building apps where I want to trigger a route via a link, but I want want to use a something other than a GET request. A good example of this would be logging a user out. I could do this with a GET, but I would prefer to use POST or DELETE as to avoid any chance the user could bookmark the link. So I came up with a solution. I created a small javascript function.

function sendAsPost(action)
{
    var form = $('#sendAsPostForm');
    form.attr('action', action);
    form.submit();
}

Then I add a form to my main layout so it's on every page.

<form action="" method="POST" id="sendAsPostForm">
    {!! csrf_field() !!}
</form>

Now I can call a POST route with a link from anywhere in my app as simple as this:

<a href="#" onclick="sendAsPost('{{ route('logout') }}')">Log-out</a>

This seems to work great, I was just wondering how other people have dealt with this? Or if this is a terrible idea for some reason I'm not seeing. Thanks!

01 Oct
3 years ago

jakeryansmith left a reply on How To Run Migration On Initial Deployment

Never mind, I believe I figured it out. I was injecting a dependency vie the constructor into my command, it was this dependency that needed access to the database. I moved this dependency out of the constructor and everything works fine now.

jakeryansmith started a new conversation How To Run Migration On Initial Deployment

I have an interesting problem. I'm trying to deploy my app with Envoyer. The problem is that I have artisan commands that need access to the database, so when the "Install Composer Dependencies" task runs it tries to run artisan at the end for cleanup, but this throws an error because it's trying to load the artisan command which then looks for a database but can't find it. So, I thought I could fix this by running my migrations before the task using hooks, but that doesn't work because it can't seem to run artisan commands until the composer dependencies are installed. I'm guessing there is a simple solution to this, but I'm not seeing it. I would love anyones advice on how they typically handle initial deployments, or how I could resolve this issue. Thanks!

28 Sep
3 years ago

jakeryansmith left a reply on Calling Auth::check() In Bade Partial Throws Nesting Level Error.

@toniperic It's not in a loop. Just a basic include:

@include('partial')
27 Sep
3 years ago

jakeryansmith left a reply on Calling Auth::check() In Bade Partial Throws Nesting Level Error.

@bestmomo I increased the level to 250 and that surpassed the error. It does seem high though. I never had this issue before 5.1 so maybe either. Using auth()->check() doesn't seem to make a difference.

25 Sep
3 years ago

jakeryansmith started a new conversation Calling Auth::check() In Bade Partial Throws Nesting Level Error.

For some reason when I try to call Auth::check() in a blade partial I get the infamous "Maximum function nesting level of '100' reached, aborting!" error. I can call Auth:check() other places and it works just fine, but if it's in a partial that is imported into another view I get the error. Thanks for any insight on this!

24 Sep
3 years ago

jakeryansmith left a reply on Multi-Tenancy With Spark

I would like this as well. I would also like a lesson on the best way to allow for custom domains. We always hear about how to implement subdomains, but what if you want to allow your clients to to white label with their own domain.

15 Sep
3 years ago

jakeryansmith left a reply on Error On My Artisan Upon Deployment

Sounds like somewhere in your code you have a typo, probably forget the ';' at the end of a line. It's hard to know exactly where that is, but I would start with your routes and controllers. Sorry if that's not much help.

14 Sep
3 years ago

jakeryansmith left a reply on Saving Database Problem

@zerogpm That's really strange. What @bestmomo suggested should have worked. I'm not sure what else would be wrong. Is there anymore code you could show us?

jakeryansmith left a reply on Saving Database Problem

According to your migration you do not have the created_at and updated_at timestamps. You will need to add this line

$table->timestamps();

jakeryansmith left a reply on How To Pass Vue Variables To Php Functions

I'm not sure of any option to control this, in fact I'm not sure what else you can do besides hide it with CSS and then in the ready function on your Vue instance you could modify the css so it displays. You could even apply a nice CSS transition this way.

jakeryansmith left a reply on How To Pass Vue Variables To Php Functions

Are you sure your Vue instance has data? Try outputting your data in your view like this @{{ $data | son }} this will show all the data in your Vue instance. It's there might not be any data in 'backers'.

jakeryansmith left a reply on How To Pass Vue Variables To Php Functions

You can't do that. PHP is rendered on the server. Vue is client side. If you want to send any Vue data to the server you will have to use an AJAX request.

13 Sep
3 years ago

jakeryansmith left a reply on Reading Site Settings From Database

To do what, cache the query?

jakeryansmith left a reply on Reading Site Settings From Database

It will be an array so you will have to access like this:

{{ $settings['site_name'] }}

You shouldn't have to loop though anything. Every setting will be available in that settings array. If you want you could even cache the Setting::lists() query so that way you only call the database once.

jakeryansmith left a reply on How To Run Model Methodes

@0re1 A service class can be very basic. I like to think of it as a class for handling and organizing a specific set of functionality. So you might create a class called InvoiceCalculator and this class could hold any logic for performing calculations on your invoices. You don't need a service provider, unless you class has a lot of dependancies then it would be useful to make a service provider.

class InvoiceCalculator {
    
    public method sum(Invoice $invoice)
    {
        // Perform your complex calculation here
    }   
}

You can then inject your InvoiceCalculator class easily into your controller using controller infection.

Then in your controller you can call methods on your InvoiceCalculator

public function index(InvoiceCalculator $invoiceClaculator)
{
    return view(invoice.index)->withSum($invoiceClaculator->sum())
}

jakeryansmith left a reply on Reading Site Settings From Database

@maddtech Here is what you do:

public function getIndex()
{
    return view('index', ['settings' => Setting::lists('value','key)]);
}

Don't worry about keyBy. It will give you the same result as list(). Lists is designed specifically for this purpose, to return database results as an associative array.

jakeryansmith left a reply on Reading Site Settings From Database

@sid405 Yeah I came across keyBy a few days ago. It's really helpful!