thewoodcutter

thewoodcutter

Member Since 1 Year Ago

Experience Points 3,760
Experience Level 1

1,240 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 31
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.

19 Jan
6 months ago

thewoodcutter left a reply on Is There Any Easy Methods To Using Ajax With Laravel?

Thanks @reached it does make a lot more sense with your explanation as well as that link you provided however I don't understand how I could have three elements: the wrapper, the trigger and the DOM item that gets updated. I have in a < big > tag the id of the wrapper, the "child" is only one available variable as far as I can tell it is the < a > tag that I want to remain as an < a > tag, then the DOM item that needs to change is the following upvote count number as not an < a > tag but just plain text.

I don't know how to arrange this. So if the child event that is firing is a seperate DOM item than the resulting changed DOM item how can I go about that?

I suffer with Javascript honestly, thanks for your help.

thewoodcutter left a reply on Is There Any Easy Methods To Using Ajax With Laravel?

Thanks @sergiu17 I'll look into it. I did find a good tutorial that explains how to use Ajax with Laravel and it actually really helped. I plan to use ajax a fair bit on my site HardTeckno.com over time and axios will definitely help.

Thing is now that my ajax requests when I click the link once it will update a seperate DOM item but when I click it again the DOM item doesn't update yet if I reload the page it indeed has updated.

EDIT: I would have posted my code but I do not know how to format it for this comment/post !

thewoodcutter started a new conversation Is There Any Easy Methods To Using Ajax With Laravel?

I want to do something that I've found rather complicated to do with Ajax using my Laravel 5.7 project. As nice and full bodied as Laravel is I imagine there could be some easy Ajax methods. Am I right? If so can you guide me?

12 Jan
7 months ago

thewoodcutter left a reply on Can You Help Me With This Ajax Request?

Can I directly inline put blade into javascript?? As I believe you can do with php generally?? Because I find a few ways that working in a foreach loop I believe it's called mass assignment and the declaration of things won't work. I don't believe..

thewoodcutter left a reply on Can You Help Me With This Ajax Request?

As well how could I pass the {{ $post->id }} into the ajax request so that it will increment the upvotes on the particular post in the foreach loop?

thewoodcutter started a new conversation Can You Help Me With This Ajax Request?

Hey, I see the site has been overhauled, hopefully I can still ask for help. I have a feature on my website HardTeckno.com and it's a +1 button on each post. Since I am often posting mixsets that are lengthy and I don't want them to interrupt with a page reload if somebody likes the post I want to use ajax for this. Problem is that I just cannot figure out how to do it.

In my view I have the counter of the likes on each post from a foreach loop as {{ $post->upvotes }} so I cannot wrap my head around how I can update that variable as well as have the original variable with PHP there too.

I've had other confusions with the process too. Can anybody help me please? I have spent a lot of time trying to figure out ajax and it is beyond confusing to me unfortunately. Perhaps I don't have the skill just yet.

31 Oct
9 months ago

thewoodcutter left a reply on Video Upload Form Results In Browser Displaying Only Absolute Path And Not The Redirect

I figured it out it was something super simple sorry. I only recently learned that 'return' can only be used once in a function otherwise that's where it stops. I was using old code and finally saw this. Thanks anyways :)

thewoodcutter started a new conversation Video Upload Form Results In Browser Displaying Only Absolute Path And Not The Redirect

Hello I'm having trouble understanding why when with my video upload form the video does copy (development server, upload otherwise) the video yet with a return redirect()->route(), and a couple of other return options I've tried, it returns the absolute path: "/var/www/..." in the browser in plain text nothing else.

Here is my controller method ('[email protected]'):

public function postUpload(Request $request) {
    
    // Change these PHP configurations:
        // <?php echo phpinfo() ?\>
        // /etc/php/7.2/apache2/php.ini

        // upload_max_filesize = 200M
        // post_max_size = 210M
        // memory_limit = 200M

    $this->validate($request, [
        'name' => 'max:80'
        // 'movie' => 'mimes:mp4,flv,ogg,mov,qt'
    ]);

    $movie = new Movie;
    $movie->name = Purifier::clean($request->name);

    if($request->hasFile('movie')) {

        $file = $request->file('movie');
        $filename = $file->getClientOriginalName();
        $path = "/var/www/html/wdwsignup/public/.vids/collection/";
        return $file->move($path, $filename);
    }

    $movie->caption = Purifier::clean($request->caption);
    $movie->save();

    return redirect()->route('admin.videos');
}

Here is the form used to upload:

{{ Form::open(['action' => '[email protected]', 'method' => 'post', 'files' => true]) }}
        
    <label>Title:</label><br>
    <input type="text" name="name" class="form-control">
    <br>
    
    <label>Video:</label><br>
    <input type="file" name="movie">
    <br>

    <label>Caption:</label><br>
    <textarea name="caption" cols="30" rows="6" class="form-control"></textarea>
    <br>

    <input type="submit" name="submit" class="form-control">
{{ Form::close() }}
<br><br>

And it doesn't appear to fulfil the request because my route is: Route::post('admin/videos/upload', '[email protected]')->name('admin.videos.upload');

And the ending URL is '/admin/videos/upload' whereas the resulting URL should have redirected to '/admin/videos' back to the view directory's folder index file.

I do not understand enough about requests so any knowledge is appreciated, thanks.

30 Oct
9 months ago

thewoodcutter left a reply on Terms Of Service Gate Using Laravel And Cookies

Okay that's good to know @shez1983 . I read about the things you're talking about only noticing that now. Thanks.

27 Oct
9 months ago

thewoodcutter left a reply on How To Order By "most" Of Something From The Pivot Table?

Like this: "withCount()->orderByDesc(_count)"

As is a pivot table relation does this extended (so it seems) relationship work in other methods? An alias is .. and I will look it up. Thanks again.

thewoodcutter left a reply on Terms Of Service Gate Using Laravel And Cookies

@tykus I've figured out since I posted this how to get a session variable (using cookie as session driver) and use it in middleware so that I have a @include that includes only when the session variable is false. This is just an age warning with a button that links to an electronic consent terms page and once clicked changes the session variable to true. So that the @include doesn't come up anymore.

It's not fully obstructive but I don't know how to populate the database with visitor's information if I want to use database as a session driver.

I imagine if I used the database for sessions I could do all the other session management things I would like to do. Can you or anybody lead me in the right direction?

thewoodcutter left a reply on How To Order By "most" Of Something From The Pivot Table?

Yes, thank you very much @staudenmeir that worked perfectly. Is there a syntax convention going on with the underscore in "orderByDesc('followed_count') that helped this work? I'm thinking the underscore appended count to followed as like functions?

thewoodcutter started a new conversation How To Order By "most" Of Something From The Pivot Table?

Hello. I am hoping there is a way to do this like this:

I have to arrange multiple profiles, on a browse page, decending from the highest 'followed()->count()' of all the profiles followers. Such as that at the first in the list is a profile with the highest amount of followers and at the last one is probably zero followers. There is a pivot table named 'followers' between 'User' and 'Profile' model classes and I would like to get the count of each profile's followers and use that to order the output of profiles and paginate 16 counts at a time on the browse page. As well a couple of other pages too similarly.

Profile model:

public function user() {
    return $this->belongsTo('App\User');
}

public function followed()
{
    return $this->belongsToMany(User::class, 'followers', 'leader_id', 'follower_id')->withTimestamps();
}

public static function followedCount() {
    //
}

public function photos() {
    $this->belongsToMany('App\Photo');
}

// public function assets() {
//     return $this->hasMany('\App\Asset'); // as owner of assets
// }

public static function profileAge($profile) {
    $dob = $profile->dob;
    $dob = explode("-", $dob);
    $age = (date("md", date("U", mktime(0, 0, 0, $dob[1], $dob[2], $dob[0]))) > date("md")
        ? ((date("Y") - $dob[0]) - 1)
        : (date("Y") - $dob[0]));
    $dob = $age;
    
    return $dob; 
}

public static function age() {
    $user = Auth::user();
    $dob = $user->dob;
    $dob = explode("-", $dob);
    $age = (date("md", date("U", mktime(0, 0, 0, $dob[1], $dob[2], $dob[0]))) > date("md")
        ? ((date("Y") - $dob[0]) - 1)
        : (date("Y") - $dob[0]));
    $dob = $age;
    
    return $dob;
}

In the ProfileController:

public function getIndex() {
    $user = Auth::user();
    $profiles = Profile::get();
    // dd($profiles);

    foreach($profiles as $profile) {
        $count = $profile->followed()->count();
    }
    dd($count);

    // we want each followed->count of each Profile
    // we will loop over each $profile and get the count of followers
    // give that variable as output to: a variable ordered by highest to lowest
    // count?

    // foreach($profiles as $profile) {
        // create an array with "$count = $profile->followed->count();" as an individual item in the array?
        // we need this foreach loop to create items in this array?
    // }
    
    return view('user.profile.index', compact('profiles','user'));
}

I do not understand programming, PHP or Laravel well enough to figure this out, any help please?

03 Sep
11 months ago

thewoodcutter left a reply on ManyToMany Not Gathering Multiple Pivot Entries

Okay cool that works now I have to go on to debug the functions that attach a profile being followed. Thank you.

thewoodcutter started a new conversation ManyToMany Not Gathering Multiple Pivot Entries

Hi I've been struggling for days now with a many to many relationship where I have profiles and users models. I want to get all the followed profiles that a user is related to (multiple) so I can further deal with the data and I keep getting only one profile when there are two or more in my test situation. Please help?

Here is my User model:

public function profile() {
    return $this->hasOne('\App\Profile');
}

public function followers()
{
    return $this->belongsToMany(Profile::class, 'followers', 'leader_id', 'follower_id')->withTimestamps();
}

Here is my profiles model:

public function user() {
    return $this->belongsTo('App\User');
}

public function followed()
{
    return $this->belongsToMany(User::class, 'followers', 'follower_id', 'leader_id')->withTimestamps();
}

This is my pivot table for this purpose:

public function up()
{
    Schema::create('followers', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('follower_id')->unsigned();
        $table->integer('leader_id')->unsigned();
        $table->timestamps();

        $table->foreign('follower_id')->references('id')->on('users')->onDelete('cascade');
        $table->foreign('leader_id')->references('id')->on('profiles')->onDelete('cascade');
    });
}

And in my controller where I am trying to get the multiple profiles only related to the user having followed those profiles:

public function getFaves($dreamer) {
    $user = Auth::user();
    $following = $user->followers()->get();

    dd($user,$following);
    return view('user.dreamer.faves');
}

The output from this gives me only one collection instance of the profile, the first one. I am not too experienced in programming or working with arrays.

I am curious if there's a simple mistake, or if there's not supposed to be this many relationships with the same two models as I also have a one to one relationship from a profile belonging to a user. I am at a complete loss please advise me what to do.

24 Aug
11 months ago

thewoodcutter left a reply on Terms Of Service Gate Using Laravel And Cookies

We want to have adult content available for guest users but now that I think about it perhaps it's not entirely necessary at these early stages of our application.. I will ask and thank you @tykus

22 Aug
11 months ago

thewoodcutter started a new conversation Terms Of Service Gate Using Laravel And Cookies

How can I create an restrictive modal popup that can bind my customers to a terms of service agreement that scrolls the agreement and has a checkbox? Does this typically use cookies? I'm using Laravel 5.5 for this project.

10 Jun
1 year ago

thewoodcutter left a reply on How Can I Use A "/public/<dir-name>/*" Directory In My Controllers And Return Not 'views' But Link References?

Okay, that's actually exactly what I thought. I'm trying over again and starting from the views folder. Sorry if my questions make no sense.

thewoodcutter started a new conversation How Can I Use A "/public/<dir-name>/*" Directory In My Controllers And Return Not 'views' But Link References?

I'm having a bit of a hard time and maybe somebody knows how I might substitute a 'return veiw()" for a url at "/public/dw" ? It seems I cannot imagine how to return at the end of my controller methods a url, with variables. What is the function/call and how can I use it?

I have a flash object that I'm trying to understand routing around that I do not know if I can simply put the 'plugin's' entire directory into a 'resources/views/*' directory can I? If I could use the plugin directory in my views folder and reference to their filenames that would maybe work.

Thanks in advance !

thewoodcutter left a reply on How Do I Use Roles And Permissions In Controllers?

Ahh okay, so use Gates. I just finished getting routeMiddleware to work with backpack/permissionsmanager by copying three files from the latest version of spatie/laravel-permissions source.. I now can 'gate' my routes with it.

I actually understand the use of Gate you're mentioning, though I haven't looked at Gates just yet. Is your example using the spatie package ( hasRole() is a specific from that? )?

Thanks @bencarter78

thewoodcutter started a new conversation How Do I Use Roles And Permissions In Controllers?

Hello again. I think I've got a handle on the front end using blade with the (I'm using backpack permissions) Laravel Permissions, such as using the @can and @if(auth()->user()->hasRole('Admin')) but I'm now trying to understand how to gate my controllers using roles. The logic required I haven't found online or can figure out as I'm rather new to PHP. Any links/explains would help, thanks :)

05 Jun
1 year ago

thewoodcutter left a reply on First Question I Have Is About Variables, Where In Laravel Would I Put This, How?:

Yeah okay thank you. I was afraid I'd have to do that. I guess I can just back up my database.

thewoodcutter started a new conversation How Can I Route A Directory With The Auth Middleware?

Hello. I have the Live Broadcasting from Video Whisper bare PHP plugin and it has a flash object that requires things I cannot change such as vc_login.php (and it's query string, as far as I know I can't change it) and I would like to avoid having to basically rewrite the whole structure just for now.

Is there anyway I can put the plugin folder somewhere for now and gate it with the auth middleware?

I have it in public/ but it's not secure there like it is. Later on I want to add it to a user panel. I don't understand routing that well so is there a way to put this whole directory (with .php and .swf files that need to be in the same directory) into my resources/views directory and route it? Route it inside the auth middleware? Any help is appreciated, even links to advanced stuff if you have an idea.

thewoodcutter left a reply on First Question I Have Is About Variables, Where In Laravel Would I Put This, How?:

@topvillas I am trying to be able to highlight one of my posts for my Laravel blog as 'pinned post' for my front page. I want to simply be able to either use a form input or click and reload the page then highlight a star on the pinned post (panel side).

@martinbean I wondered how I could use a variable instead of a database query?

I want to grab the Post::get() of just that one post and I don't understand how I'd signify that post without writing to a database, but rather to a variable. I don't know the scope or the right place anywhere for such a variable or if what I want is possible. I don't want to have to migrate:fresh over my database or have to back it up.

Thanks :)

thewoodcutter left a reply on First Question I Have Is About Variables, Where In Laravel Would I Put This, How?:

@martinbean well just one that will hold a boolean without me having to modify existing tables. that way i can attach a true or false (default) to various IDs. Can I write a variable somewhere in Laravel? I struggle with variables at times :S

thewoodcutter started a new conversation First Question I Have Is About Variables, Where In Laravel Would I Put This, How?:

as well how can i assign a variable somewhere, that can change, without the database and highlight as many of the statuses as I want? then also go ahead and have a pinned post.