hjortur17

hjortur17

Member Since 2 Years Ago

Grindavík

Experience Points
44,640
Total
Experience

360 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
263
Lessons
Completed
Best Reply Awards
1
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 9
44,640 XP
May
24
6 days ago
Activity icon

Replied to Use Goutte To Scrap Multiple Data From Single Div

@michaloravec - This is my first time working with this. Can you help me loop through this? I can't figure out how.

$crawler->filter('div > .product-details > .product-name')->first();
$crawler->filter('div > .product-details > .price-button')->last();
Activity icon

Started a new Conversation Use Goutte To Scrap Multiple Data From Single Div

Hi, I'm using Goutte to scrap websites containing prices. I want to know how can I scrap the title of the product and the price in one scrap?

This is the div:

<div class="product-details">
	<h4 class="product-name">Name</h4>
	<a class="price-button">Price</a>
</div>

What I have been doing to scrap a single thing from this div is this:

$crawler = Goutte::request('GET', 'https://elko.is/snjallheimilid/snjallperur');

$crawler->filter('div > .product-details > .price-button')->each(function ($node) {
	dump($node->text());
});

return view('welcome');
May
23
1 week ago
Activity icon

Replied to User Does Not Exist

Hi, is trying to use the csrf field here:

 <input type="submit" value="Sign In" value="Sign in" class="signin"> <br>
      {{ csrf_field() }}<br><br>        
          <label for="remember_me">
              <input type="checkbox" name="remember_me" id="remember_me" value="1">Remember Me
          </label>     
Activity icon

Replied to User Does Not Exist

You need csrf token in your form and head.

HEAD 

<meta name="csrf-token" content="{{ csrf_token() }}">

FORM

<form>
	@csrf
	
	<input>
</form>
May
22
1 week ago
Activity icon

Replied to Laravel Component Not Recognising My Variable.

Still prints this:

<?php echo e(session('flash.color')); ?>
Activity icon

Replied to Laravel Component Not Recognising My Variable.

@bobbybouwmann - Got an error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')'

Activity icon

Started a new Conversation Laravel Component Not Recognising My Variable.

Hi, I have a color variable in the session. But when I render my component (Flash) then it's just print's out this:

<?php echo e(session('flash.color')); ?>

Any idea why this is happening?

layout file
@if (session('flash.color') && session('flash.title') && session('flash.body'))
	<x-flash color="{{ session('flash.color') }}">
		<x-slot name="title">{{ session('flash.title') }}</x-slot>
		<x-slot name="body">{{ session('flash.body') }}</x-slot>
	</x-flash>
@endif
component

<div class="bg-{{ $color }}-100" role="alert">
	<div class="flex items-center">
		<div class="flex-1 px-2">
			<p class="text-base md:text-lg font-bold text-{{ $color }}-500">{{ $title }}</p>
			<p class="text-xs md:text-sm leading-relaxed">{{ $body }}</p>
		</div>
	</div>
</div>
controller 

if ($status == 200) {
	return redirect("/{$locale}/contact")->with('flash', [
		'color' => 'green',
		'title' => $sucess_title,
		'body' => $sucess_body,
	]);
} else if ($status == 403) {
	return redirect("/{$locale}/contact")->with('flash', [
		'color' => 'red',
		'title' => $error_title,
		'body' => $error_body,
	]);
}
May
13
2 weeks ago
Activity icon

Awarded Best Reply on I Need A Little Help With Laravel Language

@michaloravec - Thanks for the help. But this was the solution I ended up with.

{!! nl2br(e(__("case_studies/$work->slug.details"))) !!}

And this is how I fixed the array issue:

@foreach (__("case_studies/$work->slug.project") as $project)	
	<li>{{ $project }}</li>
@endforeach
Activity icon

Replied to I Need A Little Help With Laravel Language

@michaloravec - Thanks for the help. But this was the solution I ended up with.

{!! nl2br(e(__("case_studies/$work->slug.details"))) !!}

And this is how I fixed the array issue:

@foreach (__("case_studies/$work->slug.project") as $project)	
	<li>{{ $project }}</li>
@endforeach
Activity icon

Replied to I Need A Little Help With Laravel Language

So I'm trying to make @lang rend whitespace between lines. For example:

This is what I want it to render out:

lorem ass a asdasds sd 

asdasdasd

But it renders it like this:

lorem ass a asdasds sd asdasdasd

And the second thing is to print out an array of things located inside the lang file

Activity icon

Replied to I Need A Little Help With Laravel Language

Fix it. It was supposed to be rendered.

May
12
2 weeks ago
Activity icon

Started a new Conversation I Need A Little Help With Laravel Language

Hi, I have two questions.

  1. Is it possible to make @lang render spaces? Example:
@lang("case_studies/$work->slug.details") // Change this

{!! nl2br(e(@lang("case_studies/$work->slug.details"))) !!} // To something to this
  1. Is it possible to make @lang render an array?
'project' => [
   'UX',
   'UI',
   'Vefhönnun',
   'Vefforritun'
]
May
09
3 weeks ago
Activity icon

Awarded Best Reply on Use Select To Change Location

Figured it out. A little workaround but it works.

<select>
	@if (strtoupper(Request::segment(1)) == "EN")
		<option value="/en/{{ last(request()->segments()) }}" selected>EN</option>
		<option value="/is/{{ last(request()->segments()) }}">IS</option>
	@else
		<option value="/is/{{ last(request()->segments()) }}" selected>IS</option>
		<option value="/en/{{ last(request()->segments()) }}">EN</option>
	@endif
</select>
Activity icon

Replied to Use Select To Change Location

Figured it out. A little workaround but it works.

<select>
	@if (strtoupper(Request::segment(1)) == "EN")
		<option value="/en/{{ last(request()->segments()) }}" selected>EN</option>
		<option value="/is/{{ last(request()->segments()) }}">IS</option>
	@else
		<option value="/is/{{ last(request()->segments()) }}" selected>IS</option>
		<option value="/en/{{ last(request()->segments()) }}">EN</option>
	@endif
</select>
Activity icon

Started a new Conversation Use Select To Change Location

Hi, I'm adding a new language to my website but I'm struggling to figure out how to make people able to switch between languages. I have been trying to use select and option but I can't figure out how to update my $locale variable.

<select>
	<option value="{{ $locale = "en" }}">EN</option>
	<option value="{{ $locale = "is" }}">IS</option>
</select>
Activity icon

Awarded Best Reply on Variable Does Not Work In Laravel Components

@james_moore - The syntax was correct but I needed to generate a component model by using the artisan command. I followed these instructions: https://laravel.com/docs/7.x/blade#components

Activity icon

Replied to Variable Does Not Work In Laravel Components

@james_moore - The syntax was correct but I needed to generate a component model by using the artisan command. I followed these instructions: https://laravel.com/docs/7.x/blade#components

Activity icon

Replied to Variable Does Not Work In Laravel Components

It's a Laravel component, not a Vue component.

Activity icon

Started a new Conversation Variable Does Not Work In Laravel Components

Hi, I'm passing some variables into my view but my component isn't receiving those variables.

This is how I'm passing it into my view:

return view('pages.index', ['title' => '| Full-Stack Developer', 'loc' => $loc, 'works' => $works]);
Activity icon

Replied to Clearing Cache From Site Users Google Chrome

Laravel has few commands to clear cache:

php artisan route:cache

php artisan cache:clear

php artisan config:cache

php artisan view:clear
Activity icon

Replied to Clearing Cache From Site Users Google Chrome

You can clear the cache like this:

php artisan cache:clear
Activity icon

Replied to <img> Arabic Name

Do you have:

<meta charset="utf-8">
May
01
4 weeks ago
Activity icon

Started a new Conversation Print Text Like It's Stored In The Database

Hi, how can I print out a text like it's in the database?

For example:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Prints out

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

I am printing out like this now:

{{ $work->details }}
Apr
30
1 month ago
Activity icon

Replied to Tailwindcss Purge

No, in first I thought it was some kind of script Laravel uses to transform .blade files into some .html files. But I think this is meant for Vue JS, I'm only using blade files. @tykus - Can you help me to link to the correct files for production

Activity icon

Started a new Conversation Tailwindcss Purge

Hi, how do you set this up with Laravel? Right now when I run production it erases all tailwindcss away. How do I link to the Laravel files?

tailwind.config.js

module.exports = {
	purge: {
		content: ['./src/**/*.html'] // I think i need to change this...
	},
	theme: {
		extend: {
			height: {
				xl: '25rem'
			}
		},
	},
	variants: {},
	plugins: [],
}
webpack.mix.js

const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');

 mix
	.js('resources/js/app.js', 'public/js')
	.sass('resources/sass/app.sass', 'public/css').options({
		processCssUrls: false,
		postCss: [ tailwindcss('./tailwind.config.js') ],
	});
Activity icon

Replied to Possible To Not Use JQuery For This?

I get TypeError: null is not an object (evaluating 'document.getElementById('#mobile_nav').addEventListener')

Activity icon

Awarded Best Reply on Animation

Figured it out:

div[role=alert]
	opacity: 100%
	right: -900px
	animation: slideleft 1.5s forwards, slideright 1s forwards 5s

@keyframes slideup
	0%
		bottom: -50px
	100%
		bottom: 0

@keyframes slideleft
	100%
		right: 0

@keyframes slideright
	0%
		right: 0

	100%
		right: -900px
Activity icon

Started a new Conversation Possible To Not Use JQuery For This?

Hi, I'm using jQuery for one small hamburger menu which is only displayed on mobile. Is there any other way to do this without using jQuery?

Best regards

import $ from 'jquery';

$(document).ready(function(){
	$('#mobile_nav').click(function(){
		$('#mobile_nav').toggleClass('mobile_nav_link_active');
	});
});
Activity icon

Replied to Animation

Figured it out:

div[role=alert]
	opacity: 100%
	right: -900px
	animation: slideleft 1.5s forwards, slideright 1s forwards 5s

@keyframes slideup
	0%
		bottom: -50px
	100%
		bottom: 0

@keyframes slideleft
	100%
		right: 0

@keyframes slideright
	0%
		right: 0

	100%
		right: -900px
Activity icon

Started a new Conversation Animation

Hi, I need some advice. I'm trying to how a component slide in from the right corner and after 6s slide back out. But I can't get it to work (I do not understand CSS animation enough). Please help :)

div[role=alert]
	opacity: 100%
	right: -900px
	animation: slideleft 1s forwards
@keyframes slideleft
	100%
		right: 0

@keyframes slideright
	100%
		right: -900px
Apr
29
1 month ago
Activity icon

Awarded Best Reply on Is It Possible To Store An Array In A Database?

I was actually able to store into my database by doing it like this:

["UI", "UX", "Web Design", "Web Development"]

Some problem with TablePlus if you use 'UI'

Activity icon

Replied to Is It Possible To Store An Array In A Database?

Single column ' was not working, did need to use double "

Activity icon

Started a new Conversation Could Not Resolve Hostname Github.com

Can anyone help me figure out what is causing this error:

Cloning into 'hjorturfreyr.com'...
ssh: Could not resolve hostname github.com: Temporary failure in name resolution
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Apr
27
1 month ago
Activity icon

Replied to Is It Possible To Store An Array In A Database?

<ul>
	@foreach ($work->project as $project)	
		<li>{{ $project }}</li>
	@endforeach
</ul>
Activity icon

Replied to Is It Possible To Store An Array In A Database?

I was actually able to store into my database by doing it like this:

["UI", "UX", "Web Design", "Web Development"]

Some problem with TablePlus if you use 'UI'

Activity icon

Started a new Conversation Is It Possible To Store An Array In A Database?

Hi, I'm trying to figure out if it's possible to store a array of things inside a database? I tried to do this:

MIGRATION
$table->json('project');
MODEL

protected $casts = [
	'project' => 'array'
];

And last, this is how I'm trying to make the array inside TablePlus

UI, UX, Web Design, Web Development

Is there any other way, a better way to make an array?

Apr
25
1 month ago
Activity icon

Replied to Token API

You can just create random string when the user is created. For example:

$user = User::create([
	'name' => $data['name'],
	'email' => $data['email'],
	'password' => Hash::make($data['password']),
	'api_token' => Str::random(60),
]);
Apr
24
1 month ago
Activity icon

Replied to Where Are You All From?

Grindavík, Iceland

Activity icon

Replied to Display A Sweet Alert Box When Login Is Successful In Laravel 7

You might do something like this:

return redirect(RouteServiceProvider::HOME)->with('alert', ['code' => 'success', 'title' => 'Hello!', 'subtitle' => 'You have been logged in!']);
Apr
23
1 month ago
Activity icon

Replied to Transform <a> To An File Input

Solved it by doing it like this:

<a class="..." onclick="document.getElementById('file-input').click();">
	Add an attachment
</a>

<input type="file" name="file" id="file-input" class="hidden">
Activity icon

Started a new Conversation Transform <a> To An File Input

Hi, I'm trying to make a contact form and I'm trying to have an attachment link in it. But I want to style it just like a simple link. Any suggestion on how to make it just like a link but work like a file input?

This is the link now:

<a class="inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800 duration-200 ease-in-out">
	Add an attachment
</a>
Activity icon

Replied to Need Help Sending Email

This is what I needed to do:

Mail::send('emails.form', ['form' => $request], function ($message) use ($request) {
			$message->from($request->email, $request->name);

			$message->to(env("MAIL_TO_ADDRESS"))->subject($request->subject);
		});

Added use ($request)

Activity icon

Replied to Need Help Sending Email

@atef95 - If I do this, I get: Undefined variable: request

public function sendEmail(Request $request)
{
	Mail::send('emails.form', ['form' => $request], function ($message) {
		$message->from($request->email, $request->name);
		
		$message
			->to(env("MAIL_TO_ADDRESS"))
			->subject($request->subject);
	});
}
Apr
22
1 month ago
Activity icon

Replied to Need Help Sending Email

This is not what I'm looking for. Just want to send simple email

Activity icon

Started a new Conversation Need Help Sending Email

Hi, I'm trying to send an email to myself through my website but I'm struggling using Laravel Mail. I can't figure out how to access the data correctly in the Mail function and then in the email blade file. Can somebody please explain it for me :)

Mail::send('emails.form', $request, function ($message) {
	$message->from($request->email, $request->name);

	$message
		>to(env("MAIL_TO_ADDRESS"))
		->subject($request->subject);
});
<!DOCTYPE html>
<html>
<head>
	<link href="https://fonts.googleapis.com/css2?family=Poppins:[email protected];600&display=swap" rel="stylesheet">
</head>
<body>
	<h1>{{ $form->subject}}</h1>
	<p>{{ $form->content }}</p>
</body>
</html>
Apr
15
1 month ago
Activity icon

Started a new Conversation Need Help Choosing Between Shopify Or Woocommerce

Hi, I'm building an e-commerce website for a client and I would like to get your opinion on what to use.

What I'm mainly focusing on by using Shopify/WooCommerce is the inventory, I want to use them to add products, change prices and so on. But use Laravel/Vue JS to create the Front-End.

I saw that Shopify has some payment feature, so I was wondering if we choose to use Shopify with Laravel if I could integrate the Shopify payment into the website. If that is not possible, I was thinking to use Stripe for payments, is then Stripe is taking 3,5% of each payment on top of the 3,5% which the Shopify charges?

Could someone explain this for me :) Thanks in advance

Apr
04
1 month ago
Activity icon

Replied to Make The First Word In A Sentence Bold

@jlrdw - Could you explain why this adds < b > < /b > around the hole string not just the first word?

boldString: function (string) {
	let result = string.split('?');

	let firstWord = result[0].bold();

	return firstWord + (result[1] ?? '') + (result[2] ?? '') + (result[3] ?? '');
}

Result: < b >Kia Sorento< /b >

Apr
02
1 month ago
Activity icon

Started a new Conversation Make The First Word In A Sentence Bold

Hi, can anyone help me find the first word in a sentence and make it bold?

I have been making it bold like this:

<h2 class="font-light text-2xl"><strong class="font-semibold">Mercedes-Benz</strong> EQC</h2>
Apr
01
1 month ago
Activity icon

Replied to Customizing The Laravel Verify Email

@snapey - Sorry if I'm annoying, but do you know how to change this line (your solution didn't do the trick)

If you’re having trouble clicking the \":actionText\" button, copy and paste the URL below\ninto your web browser

I tried:

"If you’re having trouble clicking the \":actionText\" button, copy and paste the URL below\ninto your web browser: [:actionURL](:actionURL)": "Ef þú ert í vandræðum með að smella á hnappinn \":actionText\", afritaðu og límdu slóðina hér að neðan\ní vafra þinn: [:actionURL](:actionURL)",