thekordy / ticketit

A simple helpdesk tickets system for Laravel 5.1+ which integrates smoothly with Laravel default users and auth system, demo is available at: http://ticketit.kordy.info/tickets
MIT License
873 stars 383 forks source link

Proposal & help needed: Database Settings #63

Closed fusiondesign closed 8 years ago

fusiondesign commented 8 years ago

This is for tracking, please do not merge.

I need help with figuring out routes.php. Everything else seems to work perfect.

fusiondesign commented 8 years ago

So routes.php has two hard-coded variables: $main_route and $admin_route.

For some reason Cache:: does not work in routes. It's PHP so I'm 100% sure there is a way to bootstrap the Cache or fix this. The rest of the app uses a 60minute cached database setting.

fusiondesign commented 8 years ago

To test and help with this: Please pull "git reset --hard fusiondesign/0.2"

The commit diff log is far too long to digest.

fishmad commented 8 years ago

Ill look into this after work tonight.

thekordy commented 8 years ago

Great work Brian :+1:

About the main_route and admin_route settings, I thought about that earlier when we first talked about moving settings to database, How user will access the settings admin panel the first time in order to adjust the routes and master template information?

Even if we made it defaults to url/tickets and url/tickets-admin .. what about the master template name? Most cases will end up with errors and won't be able to access the admin panel, so it was very practical that you checked first the config file there for settings, that is essential. Well done

thekordy commented 8 years ago

I get this error:

tickets-database settings error

thekordy commented 8 years ago

figured out now that ticketit_settings table is empty

fishmad commented 8 years ago

is there a seed?

thekordy commented 8 years ago

It is there, but I did not run the seeder :)

fishmad commented 8 years ago

php artisan db:seed --class=Kordy\Ticketit\Seeds\SettingsTableSeeder

fishmad commented 8 years ago

I always run this after pull requests to clear stored views,
php artisan view:clear

fishmad commented 8 years ago

So when do we get and admin interface for config?/ lol

fishmad commented 8 years ago

Yeah I have the route issue, cannot access any admin areas.

fishmad commented 8 years ago

capture

fusiondesign commented 8 years ago

Hmm... do you guys both have empty settings tables?

fusiondesign commented 8 years ago

It should see config/ticketit.php, merge the config from that file into the defaults, then sync the database with the config (just run the migration then the seeder)

thekordy commented 8 years ago

@fishmad it is "dashboard" instead of "tickets-admin"

@FusionDesign I still get an error when i try to access any admin page

ticket app dashboard status

fusiondesign commented 8 years ago

I'm doing a fresh install now. I'll let you know where the issue is and patch it :)

fusiondesign commented 8 years ago

Also in Setting.php, did you uncomment the Cache:forget('settings') to clear your cache? Don't worry, I'll fix all these problems.

thekordy commented 8 years ago

I don't use Cache .. so for time being I just modified Models/Setting.php

From

$settings = Cache::remember('settings', 60, function () {
            return Table::all();
        });

to

$settings = Table::all();
fusiondesign commented 8 years ago

Cache is file-based by default and turned on. Are you sure you don't use it?

fusiondesign commented 8 years ago

Or do you mean that you changed the code and it still doesn't work?

thekordy commented 8 years ago

@FusionDesign If I do not do that, i get the error

ticket app dashboard status route error

fusiondesign commented 8 years ago

Hmm it looks like it's not finding an "admin_ids" in the database under the Slug column. Can you confirm that row exists?

thekordy commented 8 years ago

@FusionDesign When i dump $settings value Models/Settings.php

// Cache::forget('settings');

        $settings = Cache::remember('settings', 60, function () {
            return Table::all();
        });

        dd($settings);

I get this

Collection {#268 ▼
  #items: []
}
fishmad commented 8 years ago

I ran the seeder and it populated fine, Ill check /dashboard

fusiondesign commented 8 years ago

Did you run

    php artisan db:seed --class=Kordy\\Ticketit\\Seeds\\SettingsTableSeeder
fusiondesign commented 8 years ago

@thekordy ^^

fusiondesign commented 8 years ago

The command replaces the old "publish config" command.

fusiondesign commented 8 years ago

Essentially it's the new "check for old config, merge into new config, and merge into database command" so it supports upgrades and old versions.

thekordy commented 8 years ago

Yes, and It is populated fine and I checked it has all needed data

fusiondesign commented 8 years ago

Yet it returns an empty array? Give me 20min to troubleshoot. I'm doing a fresh install now

fishmad commented 8 years ago

my views are hardcoded to use /tickets-admin so I need to update. I ran: php artisan db:seed --class=Kordy\Ticketit\Seeds\SettingsTableSeeder

fishmad commented 8 years ago

capture

fusiondesign commented 8 years ago

Oh @thekordy did you check routes.php and change the hard-coded values?

fusiondesign commented 8 years ago

Oops sorry I'm falling asleep. You already answered that lol

fishmad commented 8 years ago

values are derived from the constants in config.php 'admin_route' => 'tickets-admin', does this need to be changed in config so database is populated correctly?

fusiondesign commented 8 years ago

Nah, that's why I opened this PR in the first place was to find a better solution to the routes.php hardcoded values. Every other reference to admin_route and main_route uses the DB cache.

fusiondesign commented 8 years ago

I duplicated the error. I'm trying to fix it now.

fishmad commented 8 years ago

I changed both config and DB to /dashboard and cleared views cache but its still looking for /tickets-admin its not really harcoded because its using this $setting->grab('main_route')

fusiondesign commented 8 years ago

Ok I fixed this error by un-commenting // Cache::forget('settings')

to clear the cache.

fusiondesign commented 8 years ago

Let me know if that works @fishmad

fishmad commented 8 years ago

where? is it

thekordy commented 8 years ago

@FusionDesign After I changed the hardcoded admin route .. the backend works fine creating new values. However the front won't load until I comment out the Cache line as i mentioned before

fusiondesign commented 8 years ago

Setting.php

fusiondesign commented 8 years ago

@thekordy I think during first install it boots an empty $settings and keeps it like that for 60 minutes because it was originally a cached instance maybe?

fishmad commented 8 years ago

Ok that's working now.

thekordy commented 8 years ago

@fishmad in the routes.php

$router = $this->app['router'];

$main_route = 'tickets';
$admin_route = 'tickets-admin';
fusiondesign commented 8 years ago

Ok so we have a problem with Cache lifetime on first install and hard-coded routes.php

fusiondesign commented 8 years ago

I'll add in a catch to clear the cache.... if $settings is empty. That will fix that.

fusiondesign commented 8 years ago

Main focus is on somehow removing $admin_route and $main_route from routes.php