realrandyallen

realrandyallen

Sarasota, FL

Member Since 2 Years Ago

Experience Points 97,330
Experience
Level
Lessons Completed 560
Lessons
Completed
Best Reply Awards 65
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

16 Dec
9 hours ago

realrandyallen left a reply on Get The Latest Record ID - Smartest Solution

Redis seems like overkill for this and you’re opening a can of worms if you do it that way - what do your invoice numbers look like in the DB? Are they just 1, 2, 3 etc or formatted differently?

realrandyallen left a reply on Get The Latest Record ID - Smartest Solution

You could use an Event on saved , this way you’ll have the new id of the record and will be able to generate your invoice number and save it.

Either way you’re doing another query but this way feels a little more clean and if you ever needed to do anything else on `sav you could put it here as well.

https://laravel.com/docs/5.7/eloquent#events

15 Dec
1 day ago

realrandyallen left a reply on Accessing Array Of Array

@ALLW - Not if all your relationships are setup properly and you also bring in the student for each result set

Sorry I haven’t been much help here - it’s difficult sometimes when you don’t know exactly what the person is looking to do and how everything is setup

realrandyallen left a reply on Accessing Array Of Array

@ALLW - Then the easiest way will probably be to eager load the results with the paper - so you’ll have access to `pap and `paper.resul

realrandyallen left a reply on Giving The User Options To Include Files, Codes, Etc. In Between Their Texts.

@BLUE-TURTLE - I think it does - it just requires more setup and a bit of coding

realrandyallen left a reply on Giving The User Options To Include Files, Codes, Etc. In Between Their Texts.

Check out Trix, it's what Laravel Nova uses, it can do everything you mentioned

https://trix-editor.org/

realrandyallen left a reply on Accessing Array Of Array

@ALLW - What about this approach?

        <div v-for="student in students">
            <h1>{{ student.name }}</h1>
            <div v-for="(result, key) in student.results" :key="key">
                <div v-text="getPaper(result.paper_id)"></div>
                <input type="text" class="text-center" v-model="result.mark">
            </div>
        </div>

Vue method

        methods: {
            getPaper(paper) {
                return _.find(this.papers, ['id', paper]).name;
            }
        }

realrandyallen left a reply on Accessing Array Of Array

I see, can you key the results by the paper I’d? Then you could do

v-model="student.results[paper.id].mark"

realrandyallen left a reply on Accessing Array Of Array

You should just be able to do

v-for=“paper.mark”
14 Dec
2 days ago

realrandyallen left a reply on PHP Artisan Tinker Crashing From Any Command

There’s been a few people having issues with 7.3 - you may want to go back down to 7.2 and see if it resolves your issue.

realrandyallen left a reply on Issue Trying To Show Grouped Array Length

Should just be

posts.length

realrandyallen left a reply on Multiple Values To Decide Current Element Class

@NHAYDER - If you already have access to the widget from vuex you should be able to just do this:

return this.widget.bg_color;

realrandyallen left a reply on Multiple Values To Decide Current Element Class

You could use a computed property to return a class name based on bgType...then in your CSS have a class with that name.

...

    <div :class="[ background, widget.wide, widget.pt, widget.pb, 'mx-auto' ]">
      
      <component :is="widget.name" :widget="widget"></component>

    </div>

</section>


<script>
    export default {
    ...

        computed: {
            background() {
                if(bgType == 'color'){

                    return 'bg-brand-color'; // widget.bg_color is pulled from vuex store

                }elseif(bgType == 'image'){

                    // do somthing

                }elseif(bgType == 'gradient'){

                    // do somthing

                }elseif(bgType == 'video'){

                    // do somthing
                }
            }
        },
...
    }
</script>

<style>
    .bg-brand-color {
        background-color: purple;
    }
</style>

realrandyallen left a reply on From Shared Hosting And Filezilla/Putty To Git.. I'm Lost

Yup! There are plenty of extras you could use but they are not necessary

realrandyallen left a reply on How To Change Owl Carousel Slide, Depending On Current Time...?

You can use momentjs to compare the current time to your desired time frames.

        let startPosition = moment().isAfter(moment('10:20am', 'h:mma'))
            ? 1 : moment().isAfter(moment('9:35am', 'h:mma'))
                ? 3
                : 2

        $('.owl-carousel').owlCarousel({
            loop:true,
            margin:10,
            nav:true,
            startPosition: startPosition,
            responsive:{
                0:{
                    items:1
                },
                600:{
                    items:3
                },
                1000:{
                    items:5
                }
            }
        })

realrandyallen left a reply on From Shared Hosting And Filezilla/Putty To Git.. I'm Lost

Git's pretty intimidating at first but the basics really aren't that bad - honestly Jeffrey's lesson on it is really good

https://laracasts.com/series/git-me-some-version-control

realrandyallen left a reply on Paginate A Database's Complete Results?

@UCCDEV - I think that's what @thoasty is trying to tell you is that the pagination feature does exactly that. Also, when you click a new page (whether it be next or previous) you will get the previous 50 or next 50 automatically (Laravel Magic)...you don't need any extra logic in your controller or anywhere else.

realrandyallen left a reply on File Upload - Failed To Open Stream: Permission Denied

@ZIBEN69 - This part of the path seems strange, maybe it's actually not being found?

\storage\app/public\public/storage/
``

realrandyallen left a reply on Getting Empty ID After Running $model->save()

Your PDO dumps says you're not in a transaction but I'm wondering if this particular mysql server is configured differently than your others, the only thing I can think of is maybe the AUTOCOMMIT option...I'm just spitting out ideas though, check this:

http://php.net/manual/en/pdo.lastinsertid.php

Remember, if you use a transaction you should use lastInsertId BEFORE you commit otherwise it will return 0

realrandyallen left a reply on Pagination Is Over Http Instead Of Https

Check this thread:

https://laracasts.com/discuss/channels/laravel/laravel-pagination-returns-links-in-http-and-not-https

Seems like the solution is doing this in your AppServiceProvider:

/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
    $this->app['request']->server->set('HTTPS', true);
}

realrandyallen left a reply on Many Users Belong To One Team Which Belongs To One Project - Relationship Problems

@DANHORTON - Consider this structure, it eliminates the Team model but should still do what you need:

Create a bid_user table

Schema::create('bid_user', function (Blueprint $table) {
    $table->increments('id');
    $table->unsignedInteger('bid_id');
    $table->unsignedInteger('user_id');
    $table->timestamps();
});

Relationships

// Bid model
...
public function team()
{
    return $this->belongsToMany('App\User');
}

// User model
public function bids()
{
    return $this->belongsToMany('App\Bid');
}

This structure will allow you to your original goal:

@foreach($bid->team as $user)

@endforeach     

realrandyallen left a reply on Google Map Api

The main issue is the code is using the id property to geocode and populate the fields. The id field has to be unique so you cannot have duplicates on the same page. You'll need to change each autocomplete to a class on the address input and then change the Google code to get by class name:

<input type="text" class="autocomplete" name="address">

autocomplete = new google.maps.places.Autocomplete(
    (document .getElementsByClassName('autocomplete')),
    {types: ['geocode']}
);

The same is true for every address field, the id will need to be changed to a name attribute

<input type="text"  name="street_number">

for (var component in componentForm) {
    document.getElementsByName(component).value = '';
    document.getElementsByName(component).disabled = false;
}

... 

document.getElementsByName(addressType).value = val;

You're probably still going to run into some naming conflicts, you'll probably need to initAutocomplete each instance of '.autocomplete' separately

realrandyallen left a reply on Many Users Belong To One Team Which Belongs To One Project - Relationship Problems

@DANHORTON - A bid has many teams so you're getting a collection that you'd also have to loop over to get users

@foreach($bid->team as $team)
    @foreach($team->user as $user)
        ...
    @endforeach
@endforeach

You also may want to consider making these relationship names plural since there can be multiple instances in each case

// bid model
public function teams()
{
    return $this->hasMany('App\Team');
}

// team model
public function users()
{
    return $this->belongsToMany('App\User', 'teams', 'id', 'user_id');
}

// user model
public function teams()
{
    return $this->belongsToMany('App\Team');
}

realrandyallen left a reply on SQLSTATE[42S22] I Have Problem Sql In Laravel..

You need to change that orWhere or a orWhereRaw

  $seeker = job_seeker::selectRaw('*, YEAR(CURRENT_TIMESTAMP) - YEAR(seeker_DOB) AS ages')
                            ->whereRaw('seeker_gender LIKE "%'.$request->input('dd-gender').'%"')
                            ->whereRaw('seeker_state LIKE "%'.$request->input('dd-state').'%"')
                            ->orWhereRaw('YEAR(CURRENT_TIMESTAMP) - YEAR(seeker_DOB) BETWEEN 20 AND 30')
                            ->orderby('created_at', 'DESC')->paginate(15);

realrandyallen left a reply on How Can Count Table Column Unique Values In Laravel 5.6?

$projectCount = DB::table('projects')->select('type')->distinct()->get()->count();
13 Dec
3 days ago

realrandyallen left a reply on Error 419 But I Am Passing The Token

@MARIOEID - Try passing the token in the headers:

$.ajax({
...
headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
...
});

realrandyallen left a reply on Query To Relationship

@SOCIEBOY - Hope it works out, if so please close out the thread :)

realrandyallen left a reply on Query To Relationship

@SOCIEBOY - I would just add an owner_id field to your projects table and setup your relationships this way:

// project model
class Project extends Model
{
    protected $guarded = [];

    public function owner()
    {
        return $this->belongsTo(User::class, 'owner_id')->withDefault([
            'owner_id' => auth()->id(),
        ]);
    }

    public function users()
    {
        return $this->belongsToMany(User::class);
    }
}

// user model
class User extends Authenticatable
{
...
    public function projects()
    {
        return $this->belongsToMany(Project::class);
    }   

    public function ownedProjects()
    {
        return $this->hasMany(Project::class, 'owner_id');
    } 
}

realrandyallen left a reply on Fetching Result From DB

At the very least you're missing = in your joins

$votes = DB::table('vote')->where('vote_question_id', $question_id)
                ->join('sondage', 'sondage.sondage_id', '=', 'vote.vote_question_id')
                ->join('sondage_reponse' ,'sondage_reponse.reponse_id', '=', 'vote.vote_reponse_id' )
                ->where('Sondage_date_debut' ,'<=', $this->today)
                ->where('Sondage_date_fin','>=' ,$this->today)
                ->get();

realrandyallen left a reply on Query To Relationship

Setup a Many to Many relationship between Users and Projects. This will result in three tables users, projects, and project_user. Your User model will look like this:

<?php

namespace App;

use App\Project
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    public function projects()
    {
        return $this->belongsToMany(Project::class);
    }
}

Then you'll be able to do exactly what you wanted:

$projects = User::find(1)->projects;

// or for the current authenticated 

$projects = auth()->user()->projects;

This example in the documentation is pretty much exactly what you want:

https://laravel.com/docs/5.7/eloquent-relationships#many-to-many

realrandyallen left a reply on Error 419 But I Am Passing The Token

What happens if you try:

$.ajax({
    url:url,
    type: 'POST',
    data: {
        "_token": "{{ csrf_token() }}",
        "_method": 'DELETE'
    },
    dataType: 'JSON',
    success:function(data)
    {
        th.remove();
    },
});

realrandyallen left a reply on Collection::orderBy Does Not Exist On Concat

@SPLENDIDKEEN - It's using [https://laravel.com/docs/5.7/collections#higher-order-messages](Higher Order Messages), basically short-hand...this would be the long version:

$users = $partners->map(function ($partner) {
    return $partner->users;
})->reject(function ($partner) {
    return $partner->isEmpty();
})->flatten();

realrandyallen left a reply on Set Data In VUE Dinamic

That looks fine, only way it should fail is if this is not in the scope of where you are executing

this[data.type] = data.result; 

realrandyallen left a reply on Collection::orderBy Does Not Exist On Concat

@SPLENDIDKEEN - This may or may not work depending on how your relationships are setup:

$users = $partners->map->users->reject->isEmpty()->flatten();

realrandyallen left a reply on Collection::orderBy Does Not Exist On Concat

It's hard to say without knowing how this is setup or how they're related to each other.

What do you expect $usertest to be? A collection of users that each partner is partnered with?

realrandyallen left a reply on Collection::orderBy Does Not Exist On Concat

@SPLENDIDKEEN - Try:

$collection = optional($users->concat($events), function ($collection) {
        return $collection->sortByDesc('created_at')->take(5);
    }))

realrandyallen left a reply on Collection::orderBy Does Not Exist On Concat

@SPLENDIDKEEN - Try:

$collection = optional($users->concat($events))->sortByDesc('updated_at')->take(5);

realrandyallen left a reply on Collection::orderBy Does Not Exist On Concat

You're mixing Query Builder functions and Collection functions, you'll have to use sortByDesc instead:

https://laravel.com/docs/5.7/collections#method-sortbydesc

You already have your results from the DB, you're now working with a Collection so things like orderBy, and limit won't work. Instead of limit use take

https://laravel.com/docs/5.7/collections#method-take

And you won't need the last get

$collection = $users->concat($events)->sortByDesc('updated_at')->take(5);

realrandyallen left a reply on Why Is A Function Necessary In Route::get?

It's not necessary, it's just an option...you could also pass a controller and method you want to handle the request. There are many many options when it comes to routing:

https://laravel.com/docs/5.7/routing

realrandyallen left a reply on Noob Question - PHP Fatal Error : Trying To Install Valet

Apparently this is a known bug in PHP 7.3:

https://bugs.php.net/bug.php?id=77260

You can follow the instructions here for a workaround or uninstall PHP 7.3 and use 7.2

https://stackoverflow.com/questions/53690624/errors-installing-composer-on-macos-jit-compilation-failed

realrandyallen left a reply on Store 2 Out Of 3 Fields In The Database

There's a lot that could be done here but to fix your error this should work:

$filename = $request->has('lic_file_' . $i) ? $request->file('lic_file_' . $i)->store('licenses') : null;

realrandyallen left a reply on Head Tag Title, Blade, And Language

Try this:

@section('title', trans('inventory.tab'))

realrandyallen left a reply on Vue, OnChange, Foreach Loop, Display With New Html Elements

@THEUNFORGIVEN - That's an odd error given the fact that you are receiving results from the axios call...can you post the code of the component again?

12 Dec
4 days ago

realrandyallen left a reply on Multiple Joins With Where's

@JHUTTO - Happens to us all :)

realrandyallen left a reply on Address Bar Problems

The route helper you're using accepts a route name, you've specified 'admin' so you need to change your route to this to add the admin name:

Route::get('/', ['uses'=>'Admin\[email protected]'])->name('admin');

realrandyallen left a reply on Add Message For User

@ROMULO27 - There's dozens of packages that can display a fancy looking alert

https://www.npmjs.com/package/vue-sweetalert2

One I like:

https://www.npmjs.com/package/vue-notification

realrandyallen left a reply on Multiple Joins With Where's

Your join in Laravel is different than your raw SQL sample:

->join('instructors', 'somascourses.SemesterID', '=', 'instructors.id')

INNER JOIN instructors ON somascourses.Instructorid = instructors.id

// should be:
->join('instructors', 'somascourses.Instructorid', '=', 'instructors.id')