Man

Man

Member Since 4 Years Ago

Experience Points 5,415
Experience Level 2

4,585 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 8
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

27 Feb
1 year ago

Man started a new conversation Header Image On Homepage

How can I create a header hero image like the one on laracast.com?

05 Jun
2 years ago

Man left a reply on 403 Error Forbidden Path Laravel Homestead 2.0

seems like the problem is in

'SYSTEM_IMAGE_URL' => config('app_path').'/assets/images/setting/',

Man left a reply on 403 Error Forbidden Path Laravel Homestead 2.0

@Jaytee I thought app_path() goes to the public directory. If not, what should I use instead of app_path? the folder that I need it to go to is located at: my/root/folder/public/assets/images/settings.

Man started a new conversation 403 Error Forbidden Path Laravel Homestead 2.0

I am using this code in my index:

<ul class="nav nav-pills pull-left">
                        <li><a href="{{ URL::to('/') }}"><img height="40" width="183" src="{{ config('constant.SYSTEM_IMAGE_URL').App\Setting::param('site','logo')['value'] }}" alt="{{ App\Setting::param('site','app_name')['value'] }}"></a></li>
                    </ul>

The problem is from the SYSTEM_IMAGE_URL, and the constant.php file has this:

'SYSTEM_IMAGE_URL' => config('app_path').'/assets/images/setting/',

Now I get the forbidden error 403. My homestead vagrant permission shows this:


-rwxr-xr-x 1 vagrant vagrant   1273 Apr 22  2016 select_arrow.jpg
drwxr-xr-x 1 vagrant vagrant    102 Aug 19  2016 setting
-rwxr-xr-x 1 vagrant vagrant   9851 Apr 22  2016 sprite.png

What would the problem be. It looks like there is permission in my vagrant box.

04 Jun
2 years ago

Man left a reply on Undefined Constant In Laravel 5.4

@tykus How do I define this particular CURRENCY_BEFORE?

Man left a reply on Undefined Constant In Laravel 5.4

They should've been in the global.php, but there where not. they are either somewhere in setting.php or a controller.

This specific one is in a MedController.php

define('CURRENCY_BEFORE', 'BEFORE');

that is it. But it isn't really referenced anywhere else. That is why I don't really get how this worked in laravel 4.2

Man left a reply on Undefined Constant In Laravel 5.4

I guess setting.php might not have anything to do with this particular callout.

Man left a reply on Undefined Constant In Laravel 5.4

@tykus I am unsure of how to create a config for this specific constant like we did yesterday. https://laracasts.com/discuss/channels/laravel/undefined-variable-13

Man started a new conversation Undefined Constant In Laravel 5.4

I am migrating an old code from 4.2 to 5.4. I get the error: undefined constant CURRENCY_BEFORE assumed 'CURRENCY_BEFORE

This is the code in my index file that it is triggering the error:

<select name="curreny_position">
                        <option value="BEFORE"
                            <?php if ($curr_pos['value'] == CURRENCY_BEFORE) echo "selected"; ?>> Before
                        </option>
                        <option value="AFTER" <?php if ($curr_pos['value'] == CURRENCY_AFTER) echo "selected"; ?>>
                            After
                        </option>
                    </select>

and this is the setting.php file:

public static function currencyFormat($amount)
    {
        $currency_position = self::param('site', 'curr_position')['value'];
        $currency = self::param('site', 'currency')['value'];
        switch ($currency_position) {
            case CURRENCY_BEFORE:
                return implode(' ', [$currency, number_format($amount, 2)]);
                break;
            case CURRENCY_AFTER:
                return implode(' ', [number_format($amount, 2), $currency]);
                break;
        }

I am sure after the solution, the CURRENCY_AFTER will be next to spark the error.

What is the proper way to fix this in laravel 5.4?

03 Jun
2 years ago

Man left a reply on Undefined Variable

Quick Update.

Using url() in a config file makes php artisan throw errors. figured it out here: https://laracasts.com/discuss/channels/general-discussion/cannot-run-php-artisan?page=1

Man left a reply on Undefined Variable

just figured that I forgot to wrap ' around system_image_url.

Thanks for your help.

Man left a reply on Undefined Variable

the undefined constant is located in constant.php now. which is throwing a larger system error.

Man left a reply on Undefined Variable

@tykus This is my complete constant.php file in config folder:

<?php


return [
    
  SYSTEM_IMAGE_URL => url('/resources/assets/images/setting/'),

];

When I call it up, I used

src="{{ config('constant.SYSTEM_IMAGE_URL').App\Setting::param('site','logo')['value'] }}"

I get an error indicating that there might be an issue with constant.php

Man left a reply on Undefined Variable

@tykus please give me an example, I am a newb at this.

This code worked for laravel 4.2, I don't know why it isn't working on 5.4.

Man left a reply on Undefined Variable

@tykus How would I define the constant in order to solve that error?

Man left a reply on Undefined Variable

if I remove the $,

I get the error:

use of undefined constant

If I use the $, I get the current error of

undefined variable

Man started a new conversation Undefined Variable

I have this code that I am migrating to 5.4.

 <ul class="nav nav-pills pull-left">
                        <li><a href="{{ URL::to('/') }}"><img height="40" width="183" src="{{ $SYSTEM_IMAGE_URL.App\Setting::param('site','logo')['value'] }}" alt="{{ App\Setting::param('site','app_name')['value'] }}"></a></li>
                    </ul>
                    <ul class="nav nav-pills pull-left about-menu">

This is the only callout in settingsController.php

   define('SYSTEM_IMAGE_URL', URL::to('/') . '/resources/assets/images/setting/');

I get the error:

SYSTEM_IMAGE_URL is an undefined variable.

please help.

02 Jun
2 years ago

Man left a reply on Best Way To Call Out Assets In 5.4

would this lead to the same file path?

<link href="{{asset('sass/styles.css?')}}{{ date('Y-m-d h:i:s') }}" rel="stylesheet">

Man started a new conversation Best Way To Call Out Assets In 5.4

I currently have this header.blade.php file call out made in laravel 4.2:

 <link href="{{url()}}/resources/assets/sass/styles.css?{{ date('Y-m-d h:i:s') }}" rel="stylesheet">


but that throws an error of htmlspecialchar() expects to parameter 1 to be a string.

What is the best way to callout assets?

Man started a new conversation Class Settings Not Found In Route.php

I am migrating from laravel 4.2 to 5.4 via a fresh install.

This is the code in my web.php that is causing problems.

<?php

    /*
    |--------------------------------------------------------------------------
    | Application Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register all of the routes for an application.
    | It's a breeze. Simply tell Laravel the URIs it should respond to
    | and give it the Closure to execute when that URI is requested.
    |
    */
    // Home Page
 
    Route::get('/', function () {
        Setting::settings();

        return View::make('users.index');
    });

I have the app/Settings.php file available.

The thing is that I don't see anyone registering their use app/settings.php within the web.php or route.php file.

Do I have to call it out in the web.php file or is there another way I am supposed to get this to work?

12 May
2 years ago

Man left a reply on App::missing Upgrading From 4.2 To 5.4

Why update from 4.2 to 5.4?

There are usually more support and information dedicated to the latest version of the app. A lot of things have depreciated and are disappearing from search results.

Man started a new conversation App::missing Upgrading From 4.2 To 5.4

I am upgrading an inherited app from 4.2 to 5.4.

I have installed a new version of 5.4 and am trying to update it by going through all the problems.

How can I rewrite code below to work for 5.4?

App::missing(function ($exception) {
        return Response::view('admin.missing', array(), 404);
    });
29 Mar
2 years ago

Man started a new conversation Class 'App\Http\Controllers\Setting' Not Found

I get the error Class 'App\Http\Controllers\Setting' not found.

I am switching from laravel 5.1.11 to laravel 5.4. I basically did a fresh install of 5.4 and I am integrating my app to it.

my homepage has this code:

<?php 

namespace App\Http\Controllers;
use App\Http\Controllers\controller;

class ThemeHomeController extends Controller
{
    private $videos_per_page = 12;

    public function __construct()
    {
        $this->middleware('secure');
        $settings = Setting::first();
        $this->videos_per_page = $settings->videos_per_page;
    }

It finds a problem with the

$settings = settings::first();

callout. Is there any changes I have to make in order to make this work?

26 Mar
2 years ago

Man left a reply on Upgrading From 5.1 To 5.2 Error BadMethodCallException

I don't know if this will help. This is my routesServiceProvider.php file

<?php namespace App\Providers;

use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
use \Auth as Auth;
use \View as View;
use \Redirect as Redirect;
use \Plugin as Plugin;
use \PluginData as PluginData;
use \Input as Input;
use Illuminate\Cookie\CookieJar as CookieJar;

class RouteServiceProvider extends ServiceProvider
{

    /**
     * This namespace is applied to the controller routes in your routes file.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = null;

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @param  \Illuminate\Routing\Router  $router
     * @return void
     */
    public function boot(Router $router)
    {
        parent::boot($router);

        //
        $settings = \Setting::first();
        $root_dir = __DIR__ . '/../../public/';
        
        if (\Cookie::get('theme')) {
            $theme = \Crypt::decrypt(\Cookie::get('theme'));
            define('THEME', $theme);
        } else {
            if ($settings->theme):
                    $theme = $settings->theme;
            if (!defined('THEME')) {
                define('THEME', $theme);
            }
            endif;
        }
        

        \Config::set('mail.from', ['address' => $settings->system_email, 'name' => $settings->website_name]);

        @include($root_dir . 'content/themes/' . $theme . '/functions.php');
        View::addNamespace('Theme', $root_dir . 'content/themes/' . $theme);

        View::addNamespace('plugins', 'content/plugins/');

        try {
            $plugins = Plugin::where('active', '=', 1)->get();
        
            //print_r($plugins); die();
            foreach ($plugins as $plugin) {
                $plugin_name = $plugin->slug;
                $include_file = 'content/plugins/' . $plugin_name . '/functions.php';
                
                // Create Settings Route for Plugin
        
                Route::group(array('before' => 'admin'), function () {
                    Route::get('admin/plugin/{plugin_name}', function ($plugin_name) {
                        $plugin_data = PluginData::where('plugin_slug', '=', $plugin_name)->get();

                        $data = array();

                        foreach ($plugin_data as $plugin):
                            $data[$plugin->key] = $plugin->value;
                        endforeach;


                        return View::make('plugins::' . $plugin_name . '.settings', $data);
                    });
            
                    Route::post('admin/plugin/{plugin_name}', function ($plugin_name) {
                        $input = Input::all();
                        foreach ($input as $key => $value) {
                            $pluginData = PluginData::where('plugin_slug', '=', $plugin_name)->where('key', '=', $key)->first();
                            
                            if (!empty($pluginData->id)) {
                                $pluginData->value = $value;
                                $pluginData->save();
                            } else {
                                $pluginData = new PluginData;
                                $pluginData->plugin_slug = $plugin_name;
                                $pluginData->key = $key;
                                $pluginData->value = $value;
                                $pluginData->save();
                            }
                        }
                        
                        return Redirect::to('/admin/plugin/' . $plugin_name)->with(array('note' => 'Successfully updated plugin information', 'note_type' => 'success'));
                    });
                });
        
                if (file_exists($include_file)) {
                    include($include_file);
                }
            }
        } catch (Exception $e) {
            die('error in RouteServiceProvider.php with plugins');
        }
        

        Route::filter('auth', function () {
            if (Auth::guest()) {
                return Redirect::guest('login');
            }
        });


        Route::filter('auth.basic', function () {
            return Auth::basic();
        });

        Route::filter('if_logged_in_must_be_subscribed', function () {
            if (!Auth::guest()) {
                $settings = \Setting::first();
                $free_registration = $settings->free_registration;

                if ((!Auth::user()->subscribed() && Auth::user()->role == 'subscriber') || (!$free_registration && Auth::user()->role == 'registered')) {
                    $username = Auth::user()->username;
                    return Redirect::to('user/' . $username . '/renew_subscription')->with(array('note' => 'Uh oh, looks like you don\'t have an active subscription, please renew to gain access to all content', 'note_type' => 'error'));
                }
            }
        });

        Route::filter('admin', function () {
            if (!Auth::guest() && (Auth::user()->role == 'admin' || Auth::user()->role == 'demo')) {
            } else {
                return Redirect::to('/login');
            }
        });

        Route::filter('demo', function () {
            if (!Auth::guest() && Auth::user()->role == 'demo') {
                return Redirect::back()->with(array('note' => 'Sorry, unfortunately this functionality is not available in demo accounts', 'note_type' => 'error'));
            }
        });

        Route::filter('guest', function () {
            if (Auth::check()) {
                return Redirect::to('/');
            }
        });
    }

    /**
     * Define the routes for the application.
     *
     * @param  \Illuminate\Routing\Router  $router
     * @return void
     */
    public function map(Router $router)
    {
        $router->group(['namespace' => $this->namespace], function ($router) {
            require app_path('Http/routes.php');
        });
    }
}

Man started a new conversation Upgrading From 5.1 To 5.2 Error BadMethodCallException

I just upgraded to 5.2, slowly making my way up to 5.4.

I am using a mac Os, running on homestead.

In laravel 5.2, I get the error:

BadMethodCallException in Macroable.php line 74: Method filter does not exist.

The full callout is:

in Macroable.php line 74
at Router->__call('filter', array('auth', object(Closure))) in Facade.php line 219
at Router->filter('auth', object(Closure)) in Facade.php line 219
at Facade::__callStatic('filter', array('auth', object(Closure))) in RouteServiceProvider.php line 120
at Route::filter('auth', object(Closure)) in RouteServiceProvider.php line 120
at RouteServiceProvider->boot(object(Router))
at call_user_func_array(array(object(RouteServiceProvider), 'boot'), array(object(Router))) in Container.php line 507
at Container->call(array(object(RouteServiceProvider), 'boot')) in Application.php line 757
at Application->bootProvider(object(RouteServiceProvider)) in Application.php line 740
at Application->Illuminate\Foundation\{closure}(object(RouteServiceProvider), '14')
at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FoundationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ViewServiceProvider), object(AppServiceProvider), object(ConfigServiceProvider), object(EventServiceProvider), object(RouteServiceProvider), object(AuthServiceProvider), object(ImageServiceProvider), object(CashierServiceProvider)), object(Closure)) in Application.php line 741
at Application->boot() in BootProviders.php line 17
at BootProviders->bootstrap(object(Application)) in Application.php line 203
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 232
at Kernel->bootstrap() in Kernel.php line 127
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 47

I am not sure what filters I am using or what to change them to.

This is my routes.php file

<?php


Route::group(array('before' => 'if_logged_in_must_be_subscribed'), function(){

    /*
    |--------------------------------------------------------------------------
    | Home Page Routes
    |--------------------------------------------------------------------------
    */

        Route::get('/', '[email protected]');

    /*
    |--------------------------------------------------------------------------
    | Video Page Routes
    |--------------------------------------------------------------------------
    */

        Route::get('videos', array('uses' => '[email protected]', 'as' => 'videos') );
        Route::get('videos/category/{category}', '[email protected]' );
        Route::get('videos/tag/{tag}', '[email protected]' );
        Route::get('video/{id}', '[email protected]');
        

    /*
    |--------------------------------------------------------------------------
    | Favorite Routes
    |--------------------------------------------------------------------------
    */

        Route::post('favorite', '[email protected]');
        Route::get('favorites', '[email protected]_favorites');


    /*
    |--------------------------------------------------------------------------
    | Post Page Routes
    |--------------------------------------------------------------------------
    */
        
        Route::get( 'posts', array('uses' => '[email protected]', 'as' => 'posts') );
        Route::get( 'posts/category/{category}', '[email protected]' );
        Route::get( 'post/{slug}', '[email protected]' );
        

    /*
    |--------------------------------------------------------------------------
    | Page Routes
    |--------------------------------------------------------------------------
    */

        Route::get('pages', 'ThemePa[email protected]');
        Route::get('page/{slug}', '[email protected]');


    /*
    |--------------------------------------------------------------------------
    | Search Routes
    |--------------------------------------------------------------------------
    */

        Route::get('search', '[email protected]');

    /*
    |--------------------------------------------------------------------------
    | Auth and Password Reset Routes
    |--------------------------------------------------------------------------
    */

        Route::get('login', '[email protected]_form');
        Route::get('signup', '[email protected]_form');
        Route::post('login', '[email protected]');
        Route::post('signup', '[email protected]');

        Route::get('password/reset', array('before' => 'demo', 'uses' => '[email protected]_reset', 'as' => 'password.remind'));
        Route::post('password/reset', array('before' => 'demo', 'uses' => '[email protected]_request', 'as' => 'password.request'));
        Route::get('password/reset/{token}', array('before' => 'demo', 'uses' => '[email protected]_reset_token', 'as' => 'password.reset'));
        Route::post('password/reset/{token}', array('before' => 'demo', 'uses' => '[email protected]_reset_post', 'as' => 'password.update'));

        Route::get('verify/{activation_code}', '[email protected]');

    /*
    |--------------------------------------------------------------------------
    | User and User Edit Routes
    |--------------------------------------------------------------------------
    */

        Route::get('user/{username}', '[email protected]');
        Route::get('user/{username}/edit', '[email protected]');
        Route::post('user/{username}/update', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('user/{username}/billing', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('user/{username}/cancel', array('before' => 'demo', 'uses' => '[email protected]_account'));
        Route::get('user/{username}/resume', array('before' => 'demo', 'uses' => '[email protected]_account'));
        Route::get('user/{username}/update_cc', '[email protected]_cc');

}); // End if_logged_in_must_be_subscribed route

Route::get('user/{username}/renew_subscription', '[email protected]');
Route::post('user/{username}/update_cc', array('before' => 'demo', 'uses' => '[email protected]_cc_store'));

Route::get('user/{username}/upgrade_subscription', '[email protected]');
Route::post('user/{username}/upgrade_cc', array('before' => 'demo', 'uses' => '[email protected]_cc_store'));

Route::get('logout', '[email protected]');

Route::get('upgrade', '[email protected]');

Route::get('upload_dir', function(){
    echo Config::get('site.uploads_dir');
});
/*
|--------------------------------------------------------------------------
| Admin Routes
|--------------------------------------------------------------------------
*/

    Route::group(array('before' => 'admin'), function(){
        
        // Admin Dashboard
        Route::get('admin', '[email protected]');

        // Admin Video Functionality
        Route::get('admin/videos', '[email protected]');
        Route::get('admin/videos/edit/{id}', '[email protected]');
        Route::post('admin/videos/update', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/videos/delete/{id}', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/videos/create', '[email protected]');
        Route::post('admin/videos/store', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/videos/categories', 'AdminVideoCategori[email protected]');
        Route::post('admin/videos/categories/store', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::post('admin/videos/categories/order', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/videos/categories/edit/{id}', '[email protected]');
        Route::post('admin/videos/categories/update', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/videos/categories/delete/{id}', array('before' => 'demo', 'uses' => '[email protected]'));

        Route::get('admin/posts', '[email protected]');
        Route::get('admin/posts/create', '[email protected]');
        Route::post('admin/posts/store', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/posts/edit/{id}', '[email protected]');
        Route::post('admin/posts/update', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/posts/delete/{id}', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/posts/categories', '[email protected]');
        Route::post('admin/posts/categories/store', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::post('admin/posts/categories/order', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/posts/categories/edit/{id}', '[email protected]');
        Route::get('admin/posts/categories/delete/{id}', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::post('admin/posts/categories/update', array('before' => 'demo', 'uses' => '[email protected]'));

        Route::get('admin/media', '[email protected]');
        Route::post('admin/media/files', '[email protected]');
        Route::post('admin/media/new_folder', '[email protected]_folder');
        Route::post('admin/media/delete_file_folder', '[email protected]_file_folder');
        Route::get('admin/media/directories', '[email protected]_all_dirs');
        Route::post('admin/media/move_file', '[email protected]_file');
        Route::post('admin/media/upload', '[email protected]');
        Route::get('file_upload', function(){
            echo phpinfo();
        });

        Route::get('admin/pages', '[email protected]');
        Route::get('admin/pages/create', '[email protected]');
        Route::post('admin/pages/store', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/pages/edit/{id}', '[email protected]');
        Route::post('admin/pages/update', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/pages/delete/{id}', array('before' => 'demo', 'uses' => '[email protected]'));
        

        Route::get('admin/users', '[email protected]');
        Route::get('admin/user/create', '[email protected]');
        Route::post('admin/user/store', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/user/edit/{id}', '[email protected]');
        Route::post('admin/user/update', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/user/delete/{id}', array('before' => 'demo', 'uses' => '[email protected]'));

        Route::get('admin/menu', '[email protected]');
        Route::post('admin/menu/store', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/menu/edit/{id}', '[email protected]');
        Route::post('admin/menu/update', array('before' => 'demo', 'uses' => '[email protected]e'));
        Route::post('admin/menu/order', array('before' => 'demo', 'uses' => '[email protected]'));
        Route::get('admin/menu/delete/{id}', array('before' => 'demo', 'uses' => '[email protected]'));

        Route::get('admin/plugins', '[email protected]');
        Route::get('admin/plugin/deactivate/{plugin_name}', '[email protected]');
        Route::get('admin/plugin/activate/{plugin_name}', '[email protected]');

        Route::get('admin/themes', '[email protected]');
        Route::get('admin/theme/activate/{slug}', array('before' => 'demo', 'uses' => '[email protected]'));

        Route::get('admin/settings', '[email protected]');
        Route::post('admin/settings', array('before' => 'demo', 'uses' => '[email protected]_settings'));

        Route::get('admin/payment_settings', '[email protected]');
        Route::post('admin/payment_settings', array('before' => 'demo', 'uses' => '[email protected]_payment_settings'));

        Route::get('admin/theme_settings_form', '[email protected]_settings_form');
        Route::get('admin/theme_settings', '[email protected]_settings');
        Route::post('admin/theme_settings', array('before' => 'demo', 'uses' => '[email protected]_theme_settings'));
    });

/*
|--------------------------------------------------------------------------
| Payment Webhooks
|--------------------------------------------------------------------------
*/

    Route::post('stripe/webhook', 'Laravel\Cashier\[email protected]');

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
*/


Route::group(array('prefix' => 'api/v1'), function()
{
    Route::get('/', 'Api\v1\[email protected]');

    Route::get('videos', 'Api\v1\[email protected]');
    Route::get('video/{id}', 'Api\v1\[email protected]');
    Route::get('video_categories', 'Api\v1\[email protected]_categories');
    Route::get('video_category/{id}', 'Api\v1\[email protected]_category');

    Route::get('posts', 'Api\v1\[email protected]');
    Route::get('post/{id}', 'Api\v1\[email protected]');
    Route::get('post_categories', 'Api\v1\[email protected]_categories');
    Route::get('post_category/{id}', 'Api\v1\[email protected]_category');
});


19 Mar
2 years ago

Man left a reply on Homestead 2.0 Not Displaying In Browser

I tried a bunch of stuff. Including uninstalling vagrant and reinstalling it because I kept getting a vboxsf issue. The fix to my problem was to provision the homestead. which ironically also fixed my vboxsf issue.

18 Mar
2 years ago

Man left a reply on Homestead 2.0 Not Displaying In Browser

I am using latest OSX.

17 Mar
2 years ago

Man started a new conversation Homestead 2.0 Not Displaying In Browser

I followed the instructions to install homestead 2.0 in my system. When I type in myawesome.app in the browser, it does not work. It actually forwards to www.myawesome.app

How do I fix this and make it work?

09 Oct
3 years ago

Man left a reply on Convert Post Title To Post Slug

@thomaskim Thank you for your explanation. I understand what the code does. The only part I do not understand is the "YourModel" part. I don't know how to replace "YourModel" to make it relevant to my controller.

Man left a reply on Convert Post Title To Post Slug

@thomaskim I still don't know how to replace conversation. In my current code, I have no clue how to create a model specifically to use the code.

Man left a reply on L5 Routing

I am getting a 'Conversation' class not found error

Man left a reply on Convert Post Title To Post Slug

@RachidLaasri I can't find Conversation class anywhere in the docs. I am stuck at the error: Class 'Conversation' not found

Man left a reply on Convert Post Title To Post Slug

Never mind: I had to

use Illuminate\Support\Str;

I get title not found, but I will try to straighten the errors out

Man left a reply on Convert Post Title To Post Slug

@m.rankovic, @RachidLaasri I am getting Class 'Str' not found when I use that method

Man left a reply on Convert Post Title To Post Slug

@m.rankovic, Do I put that in the store function? And don't I have to put something about if empty?

Man left a reply on Convert Post Title To Post Slug

A better question is, how do I add a function to the controller to automatically create a slug out of the title. This is my create and store post functions.

 public function create()
    {
        $data = array(
            'post_route' => URL::to('admin/posts/store'),
            'button_text' => 'Add New Post',
            'admin_user' => Auth::user(),
            'post_categories' => PostCategory::all(),
            );
        return View::make('admin.posts.create_edit', $data);
    }

    /**
     * Store a newly created video in storage.
     *
     * @return Response
     */
    public function store()
    {
        $validator = Validator::make($data = Input::all(), Video::$rules);

        if ($validator->fails())
        {
            return Redirect::back()->withErrors($validator)->withInput();
        }

        $image = (isset($data['image'])) ? $data['image'] : '';
        if(!empty($image)){
            $data['image'] = ImageHandler::uploadImage($data['image'], 'images');
        } else {
            $data['image'] = 'placeholder.jpg';
        }

        if(empty($data['active'])){
            $data['active'] = 0;
        }

        $post = Post::create($data);

        return Redirect::to('admin/posts')->with(array('note' => 'New Post Successfully Added!', 'note_type' => 'success') );
    }

I would like a slug to be created out of the title and separated with "-"....if empty.

Man started a new conversation Convert Post Title To Post Slug

I currently have this code in my admin section:

<div class="@if(!empty($post->created_at)) col-sm-3 @else col-sm-4 @endif">
                        <div class="panel-body" style="display: block;"> 
                            <p>(example. /post/slug-name)</p> 
                            <input type="text" class="form-control" name="slug" id="slug" placeholder="slug-name" value="@if(!empty($post->slug)){{ $post->slug }}@endif" />
                        </div> 
                    </div>
                </div>

With the way it is, i have to always type out a slug, basically a lowercase version of the title with "-" instead of space...

How can I make the input do something like: If empty --> str_slug("$post->title", "-")? My goal is to not have to manually type that in every time.

06 Oct
3 years ago

Man left a reply on Bugsnag Local

Anyone knows how this works?

03 Oct
3 years ago

Man started a new conversation Bugsnag Local

Currently bugsnag reports for both local and production. I don't need it to report for my local development because I can see the error my self.

I am using https://github.com/bugsnag/bugsnag-laravel

In the doc it says do something like this in the config file:

return array(
    'api_key' => env('BUGSNAG_API_KEY'),
    'notify_release_stages' => ['production', 'staging']
);

But it is not clear on how to set it up to not report local. The doc is a little unclear because bugsnag reports on both local and production.

01 Oct
3 years ago

Man left a reply on Getting Errors In Production Only

@sid405 It is not in the view. The way it is structured is that admin section is in the view, but public facing site is in the public directory with standard php, wrapping blade syntax in php. I did not create the structure, just reverse engineering it to use it to fit my needs.

Man left a reply on Getting Errors In Production Only

@sid405 ok. i put this in the postcontroller:

public function similar()
    {
        return $this->hasMany('Posts', 'post_category_id', 'post_category_id')->orderBy('created_at', 'DESC')->take(6);
    }

And in my sidebar.php I have this:

<?php


$sidebar = Post::with('similar')->find($some_post_id);

?>

<div id="sidebar">

    <h3>Articles You Will Love</h3>

    <div class="row">
        <?php foreach($sidebar as $post): ?>
            
            <?php $post_description = preg_replace('/^\s+|\n|\r|\s+$/m', '', strip_tags($post->body)); ?>

            <div class="col-md-12">
                <article class="block">
                <div class="row">
                    <div class="col-md-6">
                    <a class="block-thumbnail" href="<?= ($settings->enable_https) ? secure_url('p') : URL::to('p') ?><?= '/' . $post->slug ?>">
                        <div class="thumbnail-overlay"></div>
                        <img src="<?= ImageHandler::getImage(str_replace(' ', '-', $post->image), 'medium')  ?>">
                    </a>
                    </div>
                    <div class="col-md-6 col-sm-6 col-xs-12" >
                        <div class="details">
                        <h2><a href="<?= ($settings->enable_https) ? secure_url('p') : URL::to('p') ?><?= '/' . $post->slug ?>"><?= $post->title; ?></a></h2>
                        <small><?= date("F jS, Y", strtotime($post->created_at)); ?></small>
                        <div class="clear"></div>
                        <?php if(!empty($post->category)): ?>
                            <p class="category"><span>in </span> <a href="/posts/category/<?= $post->category->slug; ?>"><?= $post->category->name; ?></a></p>
                        <?php endif; ?>
                        </div>
                    </div>
                </div>
                </article>
            </div>

        <?php endforeach; ?>
    </div>
</div>

I don't know how to implement the new information... the (some_post_id) and general implementation of the code.

Man left a reply on Getting Errors In Production Only

@sid405 had some issues implementing the 2nd one. My laravel skills are not that sharp.

Man left a reply on Getting Errors In Production Only

@sid405 I will try your 2nd answer after the deployment is complete. I just want to make sure that i have a working solution on hand. Report back shortly.

Man left a reply on Getting Errors In Production Only

@sid405 I just tried your first answer, worked perfectly. Thank you.

@phildawson thank you for the help with this issue. I appreciate it.

Man left a reply on Getting Errors In Production Only

@phildawson Both mysql database are the same.

Man left a reply on Getting Errors In Production Only

@phildawson how do I make it find the current post category that I am in. Example: if someone is reading a post about shoes, I want the sidebar to get posts about shoes.

I don't know why this works well in local env, but not in production.

Another difference between local and production is that local uses nginx, production uses apache. I couldn't make them both use nginx because amazon beanstalk doesn't support nginx without a docker container for php.

Man started a new conversation Getting Errors In Production Only

I set up a sidebar to get posts in the same category:

$post_category = Post::find($post->post_category_id);
$sidebar = Post::where('published', '=', '1')->where('post_category_id', '=', $post_category->id)->orderBy('created_at', 'DESC')->take(6)->get();

Everything works well locally. But when I push it to production, I get an error:

ErrorException Trying to get property of non-object
    public/content/includes/sidebar.php:4 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
    public/content/includes/sidebar.php:4 include
    public/content/post.php:89 include
    vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php:42 Illuminate\View\Engines\PhpEngine::evaluatePath
    vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php:20 Illuminate\View\Engines\PhpEngine::get
    vendor/laravel/framework/src/Illuminate/View/View.php:138 Illuminate\View\View::getContents
    vendor/laravel/framework/src/Illuminate/View/View.php:107 Illuminate\View\View::renderContents
    vendor/laravel/framework/src/Illuminate/View/View.php:81 Illuminate\View\View::render
    vendor/laravel/framework/src/Illuminate/Http/Response.php:51 Illuminate\Http\Response::setContent
    vendor/symfony/http-foundation/Response.php:202 Symfony\Component\HttpFoundation\Response::__construct
    vendor/laravel/framework/src/Illuminate/Routing/Router.php:1225 Illuminate\Routing\Router::prepareResponse
    vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:113 Illuminate\Routing\ControllerDispatcher::Illuminate\Routing\{closure}
    [internal]:0 call_user_func
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:139 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    app/Http/Middleware/Secure.php:35 App\Http\Middleware\Secure::handle

How is this possible. The only difference between local and production is that production uses SSL. I have cloudfront set up to forward all http request to https.

Man left a reply on How To Adjust OrderByRaw()

Thank you guys for pointing me in the right direction. I played around with it and used something like this:

$post_category = Post::find($post->post_category_id);
$sidebar = Post::where('published', '=', '1')->where('post_category_id', '=', $post_category->id)->orderBy('created_at', 'DESC')->take(6)->get();