peanut

Member Since 5 Years Ago

Web Services Coordinator at Stark County District Library

Experience Points 8,500
Experience Level 2

1,500 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 27
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.

28 Nov
2 years ago

peanut left a reply on BelongsToMany Only Returning First Record

The select doesn't do anything. I get the same thing. The user has one role still (Basic) when they should have Basic and Admin..

22 Nov
2 years ago

peanut left a reply on BelongsToMany Only Returning First Record

Yeah I know. I did that originally. It displays the same thing as a loop and a foreach just to see what each item holds.. it only has the one role.

peanut left a reply on BelongsToMany Only Returning First Record

Anybody have any idea on this??

18 Nov
2 years ago

peanut started a new conversation BelongsToMany Only Returning First Record

I'm not completely understanding the belongsToMany and why it is only returning the first record found.. This is what I'm doing in my code:

foreach ($userB->roles as $role)
{
    var_dump($role->name);
}

This only returns the first role attached to $userB when $userB has 3 roles.. This is the relationship:

/**
 * Relation of roles
 *
 * @return BelongsToMany
 */
public function roles()
{
    return $this->belongsToMany(Role::class, 'user_roles')
        ->select(Role::getDefaultFields());
}

HOWEVER, this pulls in all 3:

foreach ($userB->roles()->get() as $role)
{
    var_dump($role->name);
}

Why do I have to do roles()->get() instead of just roles to get all the records? Is there anyway to make the relationship return all of them, but still allow this functionality to work:

$this->roles()->attach($role->id, ['expires_at' => $expires]);

Thank you for any help or explanation. Haley

23 Aug
3 years ago

peanut left a reply on V-on:click Clicks Inner Tag Instead Of A Tag..

Looks like you have to do e.currentTarget and when you do a console.log(e), currentTarget will be null.. but when you actually do e.currentTarget, it gets the right node!

peanut started a new conversation V-on:click Clicks Inner Tag Instead Of A Tag..

This is happening EVERYWHERE throughout my application. Take this for example:

<a v-bind:href="post.edit_link" class="blend action" v-on:click.prevent="editPostPopup" v-if="post.can_edit">
          <i class="fa fa-pencil" aria-hidden="true"></i> Edit
        </a>

When I click on "Edit", it works just fine.. but when I click on the <i> tag, it registers the i tag as being clicked and not the a tag.. How do I get this to stop happening?

Thanks, Haley

01 Aug
3 years ago

peanut started a new conversation Laracasts/Integrated Rollback Migrations?

So I'm using the Integrated package created by Jeffrey. I'm using the Selenium extension. This is my base testcase that all my tests extend:

<?php

use Dotenv\Dotenv;
use Laracasts\Integrated\Extensions\Selenium;
use Laracasts\Integrated\Services\Laravel\Application as Laravel;

class TestCaseSelenium extends Selenium
{
    use Laravel;
    protected $baseUrl = 'http://bunnymeadows.local';

    /**
     * Creates the application.
     *
     * @return \Illuminate\Foundation\Application
     */
    public function createApplication()
    {
      $app = require __DIR__ . '/../bootstrap/app.php';

      //$env = new Dotenv(__DIR__ . '/../', '.env.testing');
      putenv('APP_ENV=testing');
      $app->loadEnvironmentFrom('.env.testing');

      $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();

      $this->faker = Faker\Factory::create();

      $this->baseUrl = env('APP_URL', $this->baseUrl);

      return $app;
    }

    public function runDatabaseMigrations()
    {
        $this->artisan('migrate:refresh', ['--database' => 'mysql_testing', '--env' => 'testing']);
        $this->artisan('db:seed', ['--database' => 'mysql_testing', '--env' => 'testing']);

        $this->beforeApplicationDestroyed(function () {
            $this->artisan('migrate:rollback', ['--database' => 'mysql_testing', '--env' => 'testing']);
        });
    }
}

I have a connection called mysql_testing that has my database config. When I run php artisan migrate:refresh --database=mysql_testing --env=testing it does everything I want it to do. It erases my testing database, re-migrates everything.. and then I seed it using the following comnmand: php artisan db:seed --database=mysql_testing --env=testing and it works as expected. HOWEVER, when I run phpunit, it runs these test, they work fine.. but it doesn't rollback my database transactions. And if I run it again, it doesn't refresh the database so I feel like it's not even hitting this method..

Is there something I'm doing wrong?

Thank you for any help.

29 Jul
3 years ago

peanut left a reply on Reset Database In Tests For Specific Connection

Does anybody know how to do this??

28 Jul
3 years ago

peanut started a new conversation Reset Database In Tests For Specific Connection

So my users are stored on a different connection (not the default one).. and obviously in Laravel's documentation: https://laravel.com/docs/5.1/testing#resetting-the-database-after-each-test it says it only resets the default connection. Is there a way to make it reset a different connection.. or how would I go about doing this so I don't have it create multiple records and then I have to remove just to make my ID column super large?

Thank you for any help or advice!

27 Jul
3 years ago

peanut started a new conversation Change DatabaseTokenRepository.php Connection

So I'm working on resetting the password for my application.. my user model has the connection of 'int' which is my live database.. not my local database. It will always use a different connection than the rest of the app.

However, when I am trying to reset the password, Laravel is automatically trying to connect to the local default database connection I have which obviously the password_resets table does not reside on. It resides where the users are all held.

I followed the trace of code and the problem lies within the Token Repository. I see the connection variable in that class, but I'm unsure how to change that to use the 'int' connection instead of the default.

Thank you for any help!

07 Jul
3 years ago

peanut left a reply on Auth::guest() Returns True, But Auth::id() Holds Value?

I was giving Auth::login() a User model instance instead of the GlobalUser model instance.

The design honestly isn't that perplexed.. it's literally the same but with a subdividion for game specific accounts.

peanut left a reply on Auth::guest() Returns True, But Auth::id() Holds Value?

It was a simple fix. When I was registering a user, I was logging them in and I was accidentally logging them in with the User model, not the GlobalUser model. So when Auth was trying to grab the user from the globaluser, they weren't logged in since the session expired, but I'm guessing Auth::id() held onto the user_id I was giving it from the user model. Anywho, programmed a test for it too and it works great now. It was the registration. The login was working fine, but I was doing something off when I registered them and immediately logged them in.

peanut left a reply on Auth::guest() Returns True, But Auth::id() Holds Value?

I literally renamed the default User model to GlobalUser.. that doesn't change anything with what Laravel provided by default. Because then I just changed the config to the new model name. It still uses the same users table (id, email, password, etc. etc.). I don't know what "default" I'm reverting back to since this is literally the same thing Laravel had. It's just different names, that's it. There is no difference besides renaming models and tables.

And for Laravel to know the difference, I just updated the auth config which is all you need to do.

peanut left a reply on Auth::guest() Returns True, But Auth::id() Holds Value?

@SaeedPrez , I'm not sure if you're following, but that's EXACLTLY what I'm doing. GlobalUser is the model for authentication. It holds the id, email, and password and anything authentication related. My user model is the GameAccounts model.. it holds the user_id, username, points, etc.

I'm registering and logging in with the GlobalUser model.. GlobalUser can be renamed to User and User can be renamed to GameAccounts. My setup is exactly what you already described. Like to a T.

peanut left a reply on Auth::guest() Returns True, But Auth::id() Holds Value?

I have my auth config set to use the GlobalUser model which has (id, email, password, etc.) then I have a UserModel that has (user_id, username, points, cash, etc.). So when they change their password or email, it's only done for one account.

<?php

namespace App\Models\Eloquent\User;

use App\Models\Eloquent\User\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;

class GlobalUser extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword;

    /**
     * The connection name for the model.
     *
     * @var string
     */
    protected $connection = 'int';

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['name', 'email', 'password'];

    /**
     * Identifier for user
     *
     * @var string
     */
    protected $identifier = 'email';

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = ['password', 'remember_token'];

    /**
     * Relationship to user info.
     *
     * @return Relation
     */
    public function user()
    {
        return $this->hasOne(User::class, 'user_id', 'id');
    }

    /**
     * Get identifier column.
     *
     * @return string
     */
    public function identifier()
    {
        return $this->identifier;
    }
}

Then my User model:

<?php

namespace App\Models\Eloquent\User;

use Intellect\Sanction\Traits\UserSanction;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    UserSanction;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'users';

    /**
     * The primary key for the model.
     *
     * @var string
     */
    protected $primaryKey = 'user_id';

    /**
     * Identifier for user
     *
     * @var string
     */
    protected $identifier = 'username';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['username'];

    /**
     * Get identifier column.
     *
     * @return string
     */
    public function identifier()
    {
        return $this->identifier;
    }

    /**
     * Global user information
     *
     * @return Relation
     */
    public function account()
    {
        return $this->belongsTo(GlobalUser::class);
    }

    /**
     * Get primary key column
     *
     * @return string
     */
    public function getPrimaryKey()
    {
        return $this->primaryKey;
    }

    /**
     * Get user ID
     *
     * @param int $user
     * @return int
     */
    public function id($user = null)
    {
        return (is_null($user) ? auth()->id() : $user);
    }

    /**
     * Get user by ID
     *
     * @param int $user
     * @return User
     */
    public function user($user = null)
    {
        if (is_null($user))
        {
            return $this->find($this->id());
        }

        // Get user by ID
        return $this->find($user);
    }
}

But Auth is set to use GlobalUser. So when they login, they type in their email and password and I believe Auth does everything for you.. because I didn't have to make any getLogin or postLogin methods. I just used what Laravel came with. Auth::id() is holding 25 which is my ID in the GlobalUser model and my user_id in the User model.

Thank you for trying to help.

peanut left a reply on Auth::guest() Returns True, But Auth::id() Holds Value?

I would use Auth::check(), but I'm seeing why Auth::id() even has a value to begin with. I have a global user account and then individual user accounts per game app I have. So they register with us ONCE and that becomes their ID, then in each game, it links their individual accounts to their global account so that is the reason I am pulling the individual user account based on Auth::id(). It shouldn't hold a value to begin with. That's the concern. I can worry about how I'm doing my other stuff later, I'm just trying to debug.

peanut started a new conversation Auth::guest() Returns True, But Auth::id() Holds Value?

So, I'm getting this really weird thing that keeps happening. In my base controller (I was logged in, but my session expired), I am doing \Auth::guest() and it returns true, Auth::user() returns null, but Auth::id() returns my ID that I was logged in with.. is there a reason this keeps happening? I tried doing a php artisan cache:clear and that still does not fix the issue..

Part of my application thinks I'm logged in since I'm getting my user data by using Auth::id() is the where filter, but parts where I'm using the auth middleware filter, it redirects.

Thank you for any help.. I'm not sure where to even start looking to fix this issue.

02 May
3 years ago

peanut left a reply on Laravel 5.2 Resources/views Write Permissions?

Does anybody have any idea on this?

28 Apr
3 years ago

peanut started a new conversation Laravel 5.2 Resources/views Write Permissions?

So it seems for now what I have been doing is scp from my local computer to my server via ssh. HOWEVER, I can edit every view file (the ones I have edited at least) perfectly fine, except this one.. I'm getting a write permission denied error. Any idea on what can cause this on one specific view file?

I did a ls -l view.blade.php on a file I can edit and on a file I cannot edit and they both have the same permissions so it makes no sense to me. I just did a chmod -R 775 resources/ command and still to no avail.

Thank you for any help!

30 Mar
3 years ago

peanut started a new conversation Validate() Method On Controller Doesn't Flash Old Input

I can't find anywhere in the documentation on how to flash the old input back to the previous request. Originally you would put $request->flash();, but I am using their $this->validate() method right on the controller like so:

$this->validate($request, $this->messages->getValidationRules());

However, when it fails and redirects back, it will not flash my old input. Is there a way to do this? I tried putting the flash code before the validate method, but that didn't work either.

Thank you for any help.

02 Dec
3 years ago

peanut left a reply on Recommended Laravel Presenter Package?

I had to remove JUST the illuminate support directory that kept generating, run composer dump-autoload and then add laracasts/presenter 0.2.* in my composer and now everything works! Thanks!

peanut left a reply on Recommended Laravel Presenter Package?

Now even when I completely remove the vendor directory and have my old composer.json file WITHOUT laracasts presenter or illuminate support, it keeps throwing that same error.. I didn't have this until the laracasts presenter. This is why I avoided it. Because it always breaks my entire project and I can't ever get it back to working... ugh..

peanut left a reply on Recommended Laravel Presenter Package?

I tried adding illuminate/support.. Now composer update returns this (because laracasts presenters depends on illuminate support.. which is what's throwing the error):

PHP Fatal error:  Call to a member function make() on a non-object in /var/www/html/bunny-meadows-v2/vendor/illuminate/support/Illuminate/Support/helpers.php on line 30
Script php artisan clear-compiled handling the post-install-cmd event returned with an error


                                                                               
  [RuntimeException]                                                           
  Error Output: PHP Fatal error:  Call to a member function make() on a non-o  
  bject in /var/www/html/bunny-meadows-v2/vendor/illuminate/support/Illuminat  
  e/Support/helpers.php on line 30                                             
                                                                               


install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...

I tried removing the entire vendor directory and running composer install, but I still get this...

composer.json file:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "laracasts/presenter": "0.2.*"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        },
        "files": [
            "app/Http/helpers.php"
        ]
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

peanut left a reply on Recommended Laravel Presenter Package?

Oh no, I'm still getting it..

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install laravel/framework v5.1.25
    - Conclusion: don't install laravel/framework v5.1.24
    - Conclusion: don't install laravel/framework v5.1.23
    - Conclusion: don't install laravel/framework v5.1.22
    - Conclusion: don't install laravel/framework v5.1.21
    - Conclusion: don't install laravel/framework v5.1.20
    - Conclusion: don't install laravel/framework v5.1.19
    - Conclusion: don't install laravel/framework v5.1.18
    - Conclusion: don't install laravel/framework v5.1.17
    - Conclusion: don't install laravel/framework v5.1.16
    - Conclusion: don't install laravel/framework v5.1.15
    - Conclusion: don't install laravel/framework v5.1.14
    - Conclusion: don't install laravel/framework v5.1.13
    - Conclusion: don't install laravel/framework v5.1.12
    - Conclusion: don't install laravel/framework v5.1.11
    - Conclusion: remove laravel/framework v5.1.10
    - Conclusion: don't install laravel/framework v5.1.10
    - Conclusion: don't install laravel/framework v5.1.9
    - Conclusion: don't install laravel/framework v5.1.8
    - Conclusion: don't install laravel/framework v5.1.7
    - Conclusion: don't install laravel/framework v5.1.6
    - Conclusion: don't install laravel/framework v5.1.5
    - Conclusion: don't install laravel/framework v5.1.4
    - Conclusion: don't install laravel/framework v5.1.3
    - Conclusion: don't install laravel/framework v5.1.2
    - Conclusion: don't install laravel/framework v5.1.1
    - laracasts/presenter 0.1.0 requires illuminate/support 4.1.* -> satisfiable by illuminate/support[v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9].
    - laracasts/presenter 0.1.1 requires illuminate/support 4.1.* -> satisfiable by illuminate/support[v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9].
    - laracasts/presenter 0.1.2 requires illuminate/support 4.1.* -> satisfiable by illuminate/support[v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9].
    - laracasts/presenter 0.1.3 requires illuminate/support 4.1.* -> satisfiable by illuminate/support[v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9].
    - laracasts/presenter 0.1.4 requires illuminate/support ~4.1 -> satisfiable by illuminate/support[v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - don't install illuminate/support v4.1.0|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.1|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.10|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.11|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.12|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.13|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.14|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.15|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.16|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.17|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.18|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.19|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.2|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.20|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.21|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.22|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.23|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.24|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.25|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.26|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.27|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.28|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.29|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.3|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.30|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.4|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.5|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.6|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.7|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.8|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.1.9|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.1|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.12|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.16|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.17|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.2|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.3|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.4|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.5|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.6|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.7|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.8|don't install laravel/framework v5.1.0
    - don't install illuminate/support v4.2.9|don't install laravel/framework v5.1.0
    - Installation request for laravel/framework 5.1.* -> satisfiable by laravel/framework[v5.1.0, v5.1.1, v5.1.10, v5.1.11, v5.1.12, v5.1.13, v5.1.14, v5.1.15, v5.1.16, v5.1.17, v5.1.18, v5.1.19, v5.1.2, v5.1.20, v5.1.21, v5.1.22, v5.1.23, v5.1.24, v5.1.25, v5.1.3, v5.1.4, v5.1.5, v5.1.6, v5.1.7, v5.1.8, v5.1.9].
    - Installation request for laracasts/presenter 0.1.* -> satisfiable by laracasts/presenter[0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4].

I remember I posted a thread about this when it happened and it was ignored so that's why I moved on..

peanut left a reply on Recommended Laravel Presenter Package?

They may have fixed it then. About 3 months ago, there was some sort of dependency issue. Since it's been so long, I honestly can't remember. I have just avoided it since then, but since I hear it's fixed, I'll go ahead and use that since that's what I was comfortable with to begin with.

NEVERMIND.. I posted the problem below... still having it.

peanut started a new conversation Recommended Laravel Presenter Package?

Does anybody have a favorite package they like to use for presenters? I know Laracast's has one, just last time I used it with one of my Laravel 5.1 project's, it had a lot of things breaking that I can't remember since it's been a while. I think it was a dependency issue of some sort that I didn't feel like digging around for to fix it.

So just curious on if anybody has any favorite package they like for presenters to use in their Laravel 5.1 projects?

29 Nov
3 years ago

peanut left a reply on Calling Relation's Method

@thomaskim, not in my eyes no.

peanut left a reply on Calling Relation's Method

This seems to have fixed the issue :)

/**
 * Relation of badges
 * 
 * @return HasMany
 */
public function badges()
{
    return $this->belongsToMany(Badge::class, 'user_badges');
}

/**
 * Attach badge to user
 * 
 * @param string $name
 * @return UserBadge
 */
public function giveBadgeByName($name)
{
    $badgeId = $this->badges()->getRelated()->getByName($name)->id;

    return $this->badges()->attach($badgeId);
}

I had the relationship wrong :) Then I called getRelated() on the relationship to get the Badge model so I can call it's method! Dug into the code a little more. I didn't realize the relationship was where I was going wrong.

peanut left a reply on Calling Relation's Method

@bobbybouwmann there is no way to use your relationship?

peanut started a new conversation Calling Relation's Method

In my controller I have this:

$user->giveBadgeByName('beta');

$user holds a User instance. The model's method giveBadgeByName($name) looks like this:

/**
 * Relation of badges
 * 
 * @return HasMany
 */
public function badges()
{
    return $this->hasMany(UserBadge::class);
}

/**
 * Attach badge to user
 * 
 * @param string $name
 * @return UserBadge
 */
public function giveBadgeByName($name)
{
    $badgeId = $this->badges()->getBadgeByName($name)->id;

    return $this->badges()->attach($badgeId);
}

However, I'm getting this:

Call to undefined method Illuminate\Database\Query\Builder::getBadgeByName()

The UserBadge.php getBadgeByName() looks like this:

/**
 * Get badge by name
 * 
 * @param string $name
 * @return Badge
 */
public function getBadgeByName($name)
{
    return $this->badge()->getByName($name);
}

So the method does exist on that relationship. I thought you could always do stuff like this:

$user->roles()->where('name', 'admin')->first();

or something like that.. any insight would be great!

09 Nov
3 years ago

peanut left a reply on Register Service Provider And Facade Within Service Provider

Figured this out. For anybody having this issue, in your register method, add these lines:

// Bind breadcrumbs package
$this->app->register(
    'DaveJamesMiller\Breadcrumbs\ServiceProvider'
);

$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Breadcrumbs', 'DaveJamesMiller\Breadcrumbs\Facade');

Hopefully this helps somebody else out! This took me forever to find. I had to search through random Laravel 5 applications to see if anybody else was relying on other packages.

And for the person above, I did NOT want my user to have to register it themselves just to download my package because then they would have to register two service providers and alias two facades.. which is tacky.

peanut left a reply on Register Service Provider And Facade Within Service Provider

Still trying to figure this out...

06 Nov
3 years ago

peanut left a reply on Register Service Provider And Facade Within Service Provider

Any ideas on how to rely on other packages within your package? Thanks!

05 Nov
3 years ago

peanut started a new conversation Register Service Provider And Facade Within Service Provider

My package I'm developing depends on another package. Since I don't have the config/app.php file within my package, I'm trying to wrap my head around on how I would bind the service provider and facade of the package I'm trying to pull in.

So far, I have my package set up as a private repository so when I run composer update, the package I'm depending on DOES install in my root vendor directory.. so I feel like it should be recognized.

But this is what I have in my register() method within my package service provider:

// Bind breadcrumbs package
$this->app->register(
    'DaveJamesMiller\BreadCrumbs\ServiceProvider'
);
$this->app->alias('Breadcrumbs', 'DaveJamesMiller\Breadcrumbs\Manager');

It keeps saying these classes can't be found when I try to call Breadcrumbs::render('properties') or whatever method they have available.

Thanks for any help!

peanut left a reply on Laravel 5 Package Development Helpers File

For anybody curious on this, this is what I did:

In your ServiceProvider.php for your package, in the boot() method, I put this line:

$this->registerHelpers();

Then my method looks like this:

/**
 * Register helpers file
 */
public function registerHelpers()
{
    // Load the helpers in app/Http/helpers.php
    if (file_exists($file = app_path('Http/helpers.php')))
    {
        require $file;
    }
}

peanut started a new conversation Laravel 5 Package Development Helpers File

I'm developing a package in Laravel 5.1 and am trying to get a helpers.php function located in my src/Http folder. This is similar to how I do it outside of my packages (in my main laravel application). Then in my composer.json, I add it into the "files" section.

//src/Http/helpers.php

<?php

echo 'hit';

if (! function_exists('set_active'))
{
    function set_active($path, $active = 'active')
    {
        return Request::is($path) ? $active : '';
    }
}
// composer.json (package's composer file)

"autoload": {
    "psr-4": {
        "BlueWaterSolutions\\CvrAdmin\\": "src"
    },
   "files": ["src/Http/helpers.php"]
},
// composer.json (main application composer file

"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "BlueWaterSolutions\\CvrAdmin\\": "packages/BlueWaterSolutions/CvrAdmin/src",
        "App\\": "app/"
    }
},

I run a composer dump-autoload in both directories roots just to be sure.. and it still won't work.

Call to undefined function set_active()

I'm trying to call that in my package's views. Any help would be appreciated! Thanks!

26 Oct
3 years ago

peanut started a new conversation Set Table's Foreign Key Column In Relationship

So I have a version model that is used for all page models I have since they all have versioning and I rather not create a whole new model for each page that has versions of it. That will get lengthy and when other people use the CMS, it's silly to have to create two models for each new page type. Like:

Homepage.php HomepageVersion.php

Just to specify the version table. So I'm trying to define the versions() relationship on just the typical Page type like so:

$relation = $this->hasMany(PageVersion::class, $this->getVersionTable().'.record_id');

This spits out this:

HasMany {#218
  #foreignKey: "page_versions.site_tree_version.record_id"

I want it to just be site_tree_version (or whatever getVersionTable() returns), but it keeps tacking on the model's name.. How do you specify the table? I know you can setTable() on an Eloquent model, but I'm not sure how to do that when passing it to a relationship definition.

Thanks for any help!

peanut started a new conversation Eloquent GetTable() Not Grabbing $this->table

I'm trying to set the table property on a model from a different model like so:

$class = new PageVersion();
var_dump($this->getVersionTable());
$class->setTable($this->getVersionTable());
var_dump($class);
dd($class->getTable());

This is the output I'm getting:

string 'site_tree_version' (length=17)
object(Ventrac\CMS\Models\Page\PageVersion)[210]
  protected 'connection' => null
  protected 'table' => string 'site_tree_version' (length=17)
  protected 'primaryKey' => string 'id' (length=2)
  protected 'perPage' => int 15
  public 'incrementing' => boolean true
  public 'timestamps' => boolean true
  protected 'attributes' => 
    array (size=0)
      empty
  protected 'original' => 
    array (size=0)
      empty
  protected 'relations' => 
    array (size=0)
      empty
  protected 'hidden' => 
    array (size=0)
      empty
  protected 'visible' => 
    array (size=0)
      empty
  protected 'appends' => 
    array (size=0)
      empty
  protected 'fillable' => 
    array (size=0)
      empty
  protected 'guarded' => 
    array (size=1)
      0 => string '*' (length=1)
  protected 'dates' => 
    array (size=0)
      empty
  protected 'dateFormat' => null
  protected 'casts' => 
    array (size=0)
      empty
  protected 'touches' => 
    array (size=0)
      empty
  protected 'observables' => 
    array (size=0)
      empty
  protected 'with' => 
    array (size=0)
      empty
  protected 'morphClass' => null
  public 'exists' => boolean false
  public 'wasRecentlyCreated' => boolean false
"page_version"

It should be site_tree_version which is what shows, but getTable() is returning the logic that will return if the $table property isn't set.. Which setTable() should be doing as you can see above.

Is there something wrong or something that I'm missing?

24 Oct
3 years ago

peanut left a reply on Make Migration From Code

@ABDELRHMAN that's not what I was asking..

peanut left a reply on Make Migration From Code

Similar to Silverstripe. You create a new model for each page type you want and then go to dev/build and it grabs the models for each page type and creates the appropriate database tables and foreign key constraints to each site tree object. So the homepage will be unique compared to other pages. It may have more fields like a banner image, services section, etc. I'm making it user friendly so they would just create a Homepage model in App/Models/Page or whatever. I'm grabbing each new page type/model from that directory and am creating migrations on it.

You can see what I mean by going here: https://docs.silverstripe.org/en/3.2/tutorials/extending_a_basic_site/

peanut started a new conversation Make Migration From Code

So I'm trying to create a migration from one of my model's with it's model name (building a CMS so every time they build it, it will create the database fields (if they've changed from the last migration).

This is what I have so far:

$name = $this->getClassName();
        
$command = $this->artisan('make:migration create_' . strtolower($name) . '_table');
dd($command);


/****** METHOD IN CLASS ********/
/**
 * Call artisan method
 */
protected function artisan($command, array $args = [])
{
    $process = new Process('cd ' . base_path() . ' && php artisan ' . $command);
    return $process->run();
}

My question is after the migration is created, is there a way to edit it within Laravel? Or will I have to do some weird opening of the file, editing the up and down methods?

Thanks for any help!

22 Oct
3 years ago

peanut left a reply on Composer Update (php Artisan Clear-compiled) Error

Seemed like the error was because I had the service provider of the second package in there before I installed it. Woops!

peanut started a new conversation Composer Update (php Artisan Clear-compiled) Error

This is what is happening when I run composer update in my root directory:

Halichu@HALICHU-PC /c/Source/ventrac (master)
$ composer update
> php artisan clear-compiled
"forms"
Script php artisan clear-compiled handling the pre-update-cmd event returned wit
h an error



  [RuntimeException]
  Error Output:



update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock]
 [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-
progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]
 [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--pre
fer-lowest] [packages1] ... [packagesN]

I don't understand this error. This is what my composer looks like:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "illuminate/html": "5.*",
        "ventrac/cms": "dev-master",
        "ventrac/cmsforms": "dev-master"
    },
    "repositories": [{
        "type": "git",
        "url": "ssh://git@svn:7999/vp/cms.git"
    }, {
        "type": "git",
        "url": "ssh://git@svn:7999/vp/cmsforms.git"
    }],
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/",
            "Ventrac\\CMS\\": "packages/Ventrac/CMS/src",
            "Ventrac\\CMSForms\\": "packages/Ventrac/CMSForms/src"
        },
        "files": ["app/Http/helpers.php"]
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

I even got rid of the packages I'm developing and tried to run it again, but it's still outputting this error.. I don't get why it's echoing "forms" out into it.

Thanks for any help.

14 Oct
3 years ago

peanut left a reply on Routes - Return Controller Method In Callback

Yeah I don't know why I was thinking like that. I think I was overthinking it.

// CMS routes...
Route::any('{slug}', 'PageController@show')->where('slug', '([A-z\d-\/_.]+)?');

Then in the controller, it will do all the functionality (calling the Repo of course). Thanks!

peanut left a reply on Routes - Return Controller Method In Callback

Because when I navigate to "solutions/slope-mowing", it needs to know to pull that page through the CMS..

I'm building a CMS, that's why. There won't be an actual SlopeController or anything like that. Whenever they hit a page, I need to see which page that url is pointing to through the database columns:

Page:
    Solutions
        ID: 1
        URLSegment: 'solutions'
        ParentID: 0
    Slope Mowing
        ID: 2
        URLSegment: 'slope-mowing'
        ParentID: 1

Sorry, forgot to specify that this was a CMS system I'm building.

EDIT:: OHHH were you saying to pass the $slug into the PageController@show method? And do all my stuff there?

peanut started a new conversation Routes - Return Controller Method In Callback

NOTE:: I'm building a CMS!

In my routes.php file, I have this:

// CMS routes...
Route::any('{slug}', function($slug)
{
    // Stuffffffff
    return [
        'uses' => 'PageController@show'
    ];

})->where('slug', '([A-z\d-\/_.]+)?');

I want to be able to call PageController@show and pass in an $id so it hits this method:

/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return Response
 */
public function show($id)
{
    $page = $this->version->getLatest($id);

    return view('admin.pages.show', compact('page'));
}

Is there a way of doing this? I have to do some functionality in the route to grab the page ID based on the url segment that is given.

Thanks for any help.

12 Oct
3 years ago

peanut left a reply on Ajax Post (NO FORM) CSRF Error

@thomaskim yes. But for some odd reason, it's working fine now. I think it's whenever I do a dd() or var_dump() it throws that..

peanut started a new conversation Ajax Post (NO FORM) CSRF Error

I'm posting (well patching) through AJAX to my controller and keep getting the good old mismatch exception after calling that method the SECOND time. The first time works fine.

This is my Javascript:

this.$http.headers.common['X-CSRF-TOKEN'] = document.querySelector('#token').getAttribute('value');
this.$http.patch('/admin/pages/' + pageID + '/updateOrder', data, function(result, status, request)
{
    //
});

I have another patch inside a form that uses this same setup that works fine. But if my code isn't inside a form, it goes through once, then the second time, it throws the error.

Any ideas on this and any ideas on how to prevent this from happening? Thanks!

09 Oct
3 years ago

peanut left a reply on Install Package Dependencies?

Solved the issue. It was the Laracasts Presenter dependency. Once I removed that, everything worked great and it pulled the dependency over into my vendor directory.. Does anybody recommend any other presenter package? I'm not sure why the Laracasts one seems to freak out on dependencies.

Thanks!

peanut left a reply on Install Package Dependencies?

So I turned this into a private repo on Git. My main composer.json file looks like this:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "illuminate/html": "5.*",
        "ventrac/cms": "dev-master"
    },
    "repositories": [{
        "type": "git",
        "url": "ssh://git@svn:7999/vp/cms.git"
    }],
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        },
        "files": ["app/Http/helpers.php"]
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize",
            "php artisan vendor:publish --tag=public --force"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

This is the main part to look at:

       "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "illuminate/html": "5.*",
        "ventrac/cms": "dev-master"
    },
    "repositories": [{
        "type": "git",
        "url": "ssh://git@svn:7999/vp/cms.git"
    }],

It seems like everything pulls fine and it's "satisfiable", but I'm getting mainly these errors when running composer update:

Problem 1:
- Conclusion: remove laravel/framework 5.1.19
- Conclusion: don't install laravel/framework 5.1.19
- Conclusion: don't install laravel/framework 5.1.18
............
- Conclusion: don't install laravel/framework 5.1.3
- Installation request for ventrac/cms dev-master -> satisfiable by ventrac/cms[dev/master]
- Conclusion: don't install laravel/framework 5.1.2
............
- don't install illuminate/support 4.1.0|don't install laravel/framework 5.1.0
[this repeats for all the versions of illuminate/support]
...........
- Installation request for laravel/framework 5.1.* -> satisfiable by laravel/framework[5.1.0, 5.1.1, ......]

I'm not understanding why I'm getting this.. I followed a tutorial on Youtube to create private repos from bit to bit and his didn't end up doing this. It won't install the ventrac/cms under my vendor directory. Any help would be appreciated!

Btw, this is my composer.json file for ventrac/cms in my git repo:

{
    "name": "ventrac/cms",
    "description": "The CMS platform for Venture Products Inc.'s websites.",
    "license": "MIT",
    "authors": [
        {
            "name": "Haley Schillig",
            "email": "haley.schillig@ventrac.com"
        }
    ],
    "autoload": {
        "psr-4": {
            "Ventrac\\CMS\\": "src/"
        }
    },
    "minimum-stability": "dev",
    "require": {
        "illuminate/support": "~5",
        "laracasts/presenter": "0.1.*"
    }
}