peterdickins

peterdickins

Member Since 1 Month Ago

Experience Points
590
Total
Experience

4,410 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
2
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 1
590 XP
May
28
6 days ago
Activity icon

Started a new Conversation Removing Code From Controller

Hi,

I am trying improve my controller fu nations which seem messy in my opinion. I have a form on my page that allows user to input month and year. In the database it is stored as a normal MySQL date so I add -01 to the end. So my controller looks like this.

public function store()
{
    $attributes = $this->validateRequest();
    $attributes['start_date'] = Carbon::parse(request('start_date') . '-01')->toDateString();
    $attributes['end_date'] = null !== request('end_date') ? Carbon::parse(request('end_date') . '-01')->toDateString() : null;
    $attributes['is_present'] = request('is_present') == 'on' ? true : false;

    $role = auth()->user()->roles()->create($attributes);
    return redirect('/admin');
}

I am trying to improve my code and I understand that skinny controllers are good practice, but I am not sure where I am can move the date processing to? Would it be a service? If so I would appreciate any guidance on this.

May
23
1 week ago
Activity icon

Replied to Validation Required_without And Date_format

Hmmm, it's still not quite right, in this request it passes validation:

"position" => "asdfdg"
"company" => "afsdg"
"location" => "wfagehrs"
"start_date" => "2020-10"
"is_present" => "on"
"skills" => "Asf"
"description" => "asfdg"

But this fails:

"position" => "asdfdg"
"company" => "afsdg"
"location" => "wfagehrs"
"start_date" => "2020-10"
"end_date" => null
"is_present" => "on"
"skills" => "Asf"
"description" => "asfdg"
Activity icon

Replied to Validation Required_without And Date_format

Thank you, but end date should be able to be null if is_present is checked

Activity icon

Started a new Conversation Validation Required_without And Date_format

I have a form on my page that is for a users job history. They can either select an end date or that it is their present role.

return $attributes = request()->validate([
        'position' => 'required',
        'company' => 'required',
        'start_date' => 'date_format:Y-m|required',
        'end_date' => 'date_format:Y-m|required_without:is_present',
        'is_present' => 'required_without:end_date',
        'description' => 'required',
        'location' => 'required',
    ]);

However when I submit the form with end_date empty, I get the following validation response:

The end date does not match the format Y-m.

Any idea why this is?

May
22
1 week ago
Activity icon

Replied to Update Request Value

Thanks, but how would I update the request value so it is stored in the database?

Activity icon

Started a new Conversation Update Request Value

Hi,

I have a date picker on my form that allows users to select a month and year. The value is submitted as YYYY/MM. How can I update the value so that I can save it in a mysql date field?

May
10
3 weeks ago
Activity icon

Started a new Conversation MySQL Directory In Project

Hi,

I have been working on a laravel project for a few weeks and a mysql folder has just appeared in the root of the project. I have checked /etc/mysql/my.cnf in Vagrant and it has the following:

!includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/

Any idea how I can resolve this?

May
09
3 weeks ago
Activity icon

Started a new Conversation Page Specific Javascript And Webpack

Hi,

I have javascript files that are only required on some pages, if there are included in other pages then they cause console errors.

Should I include these files in app.js for compiling assets with Laravel Mix or just put the in public/js manually and include them in my blade templates where required?

Activity icon

Replied to Javascript Console Error

Perfect, thank you :)

Activity icon

Started a new Conversation Javascript Console Error

Hi,

I am trying to use a theme into my Laravel project. The theme has javascript files that use tiny-slider and js-cookie packages. Here is my setup:

// webpack.mix.js
const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');


// resources/js/app.js
require('./bootstrap');
import '@fortawesome/fontawesome-free/js/all.js';
import { tns } from 'tiny-slider/src/tiny-slider.js';
import Cookies from 'js-cookie';

require('./theme/dark-mode.js');
require('./theme/testimonials.js');


// resources/js/theme/testimonials.js
const slider = tns({
    container: '.testimonial-carousel',
    loop: true,
    items: 3,
    responsive: {
        0:{
            items:1,
        },
        768:{
            items:2,
        },
        1200: {
            items:3,
        }

    },
    slideBy: 'page',
    nav: true,    
    autoplay: true,
    autoplayButtonOutput: false,
    mouseDrag: true,
    lazyload: true,
    gutter: 30,
    navPosition: 'bottom',
    mouseDrag: true,
    controls: false,
    speed: 800,

});

// resources/js/theme/dark-mode.js
$(document).ready(function() {

function setThemeFromCookie() {
	// Check if the cookie is set 
	if (typeof Cookies.get('mode') !== "undefined" ) {
		$('body').addClass("dark-mode");
		$('#darkmode').attr('checked', true); // toggle change
		console.log('Cookie: dark mode' );
	} else {
		$('body').removeClass("dark-mode");
		$('#darkmode').attr('checked', false); // toggle change
		console.log('Cookie: light mode' );
	}
}

setThemeFromCookie();

$('#darkmode').on('change', function(e){

	if ($(this).is(':checked')) {
		$('body').addClass('dark-mode');
		//Set cookies for 7 days 
		Cookies.set('mode', 'dark-mode', { expires: 7 });
		
	} else {
		$('body').removeClass('dark-mode');
		//Remove cookies
		Cookies.remove('mode');
	}
});
});	

When I load the app, I am getting the following errors:

Uncaught ReferenceError: tns is not defined
at Object../resources/js/theme/testimonials.js (app.js:46323)
at __webpack_require__ (app.js:20)
at Module../resources/js/app.js (app.js:46099)
at __webpack_require__ (app.js:20)
at Object.0 (app.js:46368)
at __webpack_require__ (app.js:20)
at app.js:84
at app.js:87


Uncaught ReferenceError: Cookies is not defined
at setThemeFromCookie (app.js:46177)
at HTMLDocument.<anonymous> (app.js:46190)
at mightThrow (app.js:14654)
at process (app.js:14722)

Can anyone tell me what I am doing wrong here please?

Apr
09
1 month ago
Activity icon

Started a new Conversation Using Themes With Laravel

I have seen some great looking themes on the Bootstrap website, and would like to use one with a project idea I have to get something up and running quickly.

I am fairly good with Laravel backend but not so hot with front end development, hence why I am keen to use a theme.

Are there any drawbacks to this approach? Are Bootstrap themes compatible with Laravel and Vue?