hjortur17

hjortur17

Member Since 2 Years Ago

Grindavík

Experience Points
45,630
Total
Experience

4,370 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 10
45,630 XP
Aug
09
6 days ago
Activity icon

Awarded Best Reply on My Project Is Updating When I Push New Code

I did ssh into my server and did git pull. That solved it

Activity icon

Replied to My Project Is Updating When I Push New Code

I did ssh into my server and did git pull. That solved it

Activity icon

Started a new Conversation My Project Is Updating When I Push New Code

Hi, my website is running a few commits behind. My master branch is up to date but the server is running old commit. I have to try to Deploy using Forge but nothing happens.

I have tried to clear Application cache, Route cache, Configuration cache, and Compiled views.

Any idea how I can fix it?

Jul
21
3 weeks ago
Activity icon

Replied to Checkbox Checked

@bugsysha - Yes, via API call

getServices: function () {
			axios.get('/api/get/services')
			.then(response => {
				this.services = response.data;
			});
		}
Activity icon

Replied to Checkbox Checked

@bugsysha - I did add the v-model to my checkboxes, but when I want to push all the already chosen services I get this error:

This is how I'm trying to push to the array:

choosenServices: function () {
	let checkedServices = this.data.services;
	let filtered = _.filter(this.services, (v) => _.includes(checkedServices.map(a => a.id), v.id));

	return filtered.map(function (elem) {
		return this.checkedNames.push(elem.id); // here
	});
}
Jul
20
3 weeks ago
Activity icon

Started a new Conversation Checkbox Checked

Hi, how can I check a checkbox if a value from an array is the same as an id? I have a edit feature for a booking and it's loop through all services available and then I made a computed prop to see what services was chosen in the first place when the booking was made.

How can I check if any of the id's from already chosen services matches id's from all the services?

Here are my for loop (looping trough all the services available):

<div v-for="service in services" v-if="service.carSize === data.carSize && service.visible">
	<input type="checkbox" :value="service.id">
</div>

This is what I have been trying to see if it's was chosen or not:

:checked="checkedService === service.id" 
this on the input

And here is my method to collect all of the checked services:

checkedService: function () {
	let choosenServices = this.data.services;
	let filtered = _.filter(this.services, (v) => _.includes(choosenServices.map(a => a.id), v.id));

	return filtered.map(function (elem) {
		return elem.id;
	});
}

this returns: [4, 7]
Jul
17
4 weeks ago
Jul
04
1 month ago
Activity icon

Started a new Conversation Check If Value From Array1 Is In Array2

Hi, I have been trying to find a good solution to look trough two array's and see if the same id is in both of them. So array1 is all the services we offer, array2 is all services a user has chosen before.

So this is a booking system, and I want people to be able to change or add a service to there order. So I'm trying to print out every service we offer and mark those checked which the user ordered in the first place.

These are my array's:

array1

services:Array[24]
	0:Object
		carSize:"Fólksbíll/Jepplingur"
		created_at:null
		description:"Alþrif"
		id:7
		price:19900
		updated_at:null
		visible:0
	1:Object
	2:Object
	3:Object
	...
array2

data:Object
	services:Array[1]
		0:Object
			carSize:"Fólksbíll/Jepplingur"
			created_at:null
			description:"Rúðuvökvi áfylling"
			id:7
			pivot:Object
			price:2000
			updated_at:null
			visible:1

I'm using belongsToMany('App\Service') relationship

Jun
28
1 month ago
Activity icon

Replied to Trying To Load Services With Booking

That's true, but do you know if it's possible to load the services by using the variable? Because my route looks like this:

Route::get('/stjornbord/bokanir/{booking}', '[email protected]');

And this is my method:

public function showBooking(Booking $booking)
	{
		return view('dashboard.showBooking', compact('booking'));
	}

So I'm trying to loop through every service chosen with Vue but it doesn't recognize any when I try $booking->services

Activity icon

Replied to Trying To Load Services With Booking

Yes, I'm sure that I'm sending the CSRF token.

When I console.log out the response.status, I get 200 when it's finds a booking but this message when I got 404: Error: Request failed with status code 404

Activity icon

Replied to Trying To Load Services With Booking

@snapey - Hi, I'm having trouble getting Axios to display alert if I get 404 from the controller. Any idea?

if (response.status === 200) {
	window.location.href = "/stjornbord/bokanir/" + response.data.id;
} else if (response.status === 404) {
	alert('Engin bókun með þetta númer!');
}
Activity icon

Replied to Trying To Load Services With Booking

No, it's not different. But I change my search method to only see if the booking with that id you typed in exist and then redirect to edit page for that booking. And that's why I need to load services associated with that booking, so I can choose or remove a another service.

So this is my search method on the BookingController:

$booking = Booking::where('id', '=', $request->bookingId)->first();

return $booking;

And that's my search vue file:

search: function (e) {
			e.preventDefault();
			e.stopPropagation();

			axios.post('/api/booking/search?api_token=' + this.user.api_token, {
				bookingId: this.bookingId
			})
			.then(response => {
				if (response.data) {
					window.location.href = "/stjornbord/bokanir/" + response.data.id;
				} else {
					alert('Engin bókun með þetta númer!');
				}

			})
			.catch(function (error) {
				console.log(error);
			});
		}
Activity icon

Replied to Trying To Load Services With Booking

@snapey - So what I'm trying to do is to have input on my website where you can look up booking id. If they exist, the page will redirect you to a edit page for that booking. But if no booking has that id, you typed in, it will display alert.

Jun
27
1 month ago
Activity icon

Replied to Trying To Load Services With Booking

How can I load the services in my showBooking method?

Can I use the $booking?

public function showBooking(Booking $booking)
	{
		return view('dashboard.showBooking', compact('booking'));
	}
Activity icon

Started a new Conversation Trying To Load Services With Booking

Hi, I'm trying to get services by using ->with, but it doesn't load the services. I have on my Booking model a belongsToMany relationship.

So this is what I'm doing, I have a VUE search input which looks up Bookings by there booking ID, and that's open a link using window.href.

Here is my code:

MODEL

public function services()
{
	return $this->belongsToMany('App\Service');
}
CONTROLLER

public function search(Request $request)
	{
		$booking = Booking::where('id', '=', $request->bookingId)->with('services')->first();

		return $booking;
	}
SEARCHBOOKING.VUE

<template>
	<div>
		<input class="appearance-none block w-full bg-gray-300 text-gray-700 border border-gray-200 rounded py-2 px-4 focus:outline-none focus:bg-white focus:border-main transition" type="number" placeholder="Leita af bókun" v-model="bookingId" @keyup.enter="search">
	</div>
</template>

<script>
export default {
	data() {
		return {
			user: window.App.user,
			bookingId: ''
		}
	},

	methods: {
		search: function (e) {
			e.preventDefault();
			e.stopPropagation();

			axios.post('/api/booking/search?api_token=' + this.user.api_token, {
				bookingId: this.bookingId
			})
			.then(response => {
				window.location.href = "/stjornbord/bokanir/" + response.data.id;
			})
			.catch(function (error) {
				console.log(error);
			});
		}
	},
};
</script>
ROTUES

Route::post('/booking/search', '[email protected]');

Route::get('/stjornbord/bokanir/{booking}', '[email protected]');
Jun
20
1 month ago
Activity icon

Started a new Conversation Property [description] Does Not Exist On This Collection Instance.

Hi, I can't figure out why I'm getting this error message when I'm trying to load the service description from the booking. This is the error message I get: Property [description] does not exist on this collection instance.

BOOKING MODEL

public function services()
{
	return $this->belongsToMany('App\Service');
}

FOREACH LOOP

@foreach ($bookingsGoingOut as $booking)
	<tr>
		<td class="border px-4 py-2">{{ optional($booking->services)->description }}</td>
	</tr>
@endforeach
CONTROLLER

$bookingsGoingOut = Booking::where('pickUpDate', '=', $today)->with('services')->paginate(15);
Activity icon

Started a new Conversation Error While Upgrading From 6.8 To 7.X

Hi, I went through the upgrade guide on the website but when I did run composer upgrade I got this error in the end:

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
PHP Fatal error:  Declaration of App\Exceptions\Handler::report(Exception $exception) must be compatible with Illuminate\Foundation\Exceptions\Handler::report(Throwable $e) in /Users/hjorturfreyrlarusson/websites/bilahotel/app/Exceptions/Handler.php on line 37
PHP Fatal error:  Uncaught ReflectionException: Class App\Exceptions\Handler does not exist in /Users/hjorturfreyrlarusson/websites/bilahotel/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
Stack trace:
#0 /Users/hjorturfreyrlarusson/websites/bilahotel/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): ReflectionClass->__construct('App\Exceptions\...')
#1 /Users/hjorturfreyrlarusson/websites/bilahotel/vendor/laravel/framework/src/Illuminate/Container/Container.php(687): Illuminate\Container\Container->build('App\Exceptions\...')
#2 /Users/hjorturfreyrlarusson/websites/bilahotel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\Container\Container->resolve('App\Exceptions\...', Array, false)
#3 /Users/hjorturfreyrlarusson/websites/bilahotel/vendor/laravel/framework/src/Illuminate/Container/Container.php(265): Illuminate\Foundation\Application->resolve('App\Exceptions\...', Array, false)
#4 /Users/hjorturfreyrlarusson/websites/bilahotel/vendor/larav in /Users/hjorturfreyrlarusson/websites/bilahotel/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 807
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255

How can I fix this?

Jun
18
1 month ago
Activity icon

Started a new Conversation Cannot Send Message Without A Sender Address

Hi, I'm getting error when trying to send email from my application. I'm using pair.com services and this is my mail settings:

MAIL_DRIVER=smtp
MAIL_HOST=username.mail.pairserver.com
MAIL_PORT=587
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

Has anyone used pair.com service or know anything about this error message.

Jun
17
1 month ago
Activity icon

Replied to I Need Help Removing Unused Javascript

@niush - Your solution did the best job. @jlrdw - I did your solution helped but did not benefit enough :)

Jun
14
2 months ago
Activity icon

Replied to For Loop Renders Different Way In Production

Getting the services now like this from the controller:

public function getServices()
{
	$services = Service::orderBy('id', 'asc')->get();

	if (request()->wantsJson()) {
		return $services;
	}

	return $services;
}
Activity icon

Replied to For Loop Renders Different Way In Production

This is how I'm using Axios to get the services:

getServices: function () {
	axios.get('/api/get/services')
	.then(response => {
		this.services = response.data;
	});
},

And this is from the controller:

public function getServices()
{
	$services = Service::latest()->get();

	if (request()->wantsJson()) {
		return $services;
	}

	return $services;
}
Activity icon

Replied to For Loop Renders Different Way In Production

@bugsysha - So my loop is printing the other way around in production. I'm expecting:

1 2 3 4 5 6 7 8 9

But I get

9 8 7 6 5 4 3 2 1
Activity icon

Replied to I Need Help Removing Unused Javascript

@jlrdw - I have tried to split it into 3 different files but it's having to compile BookingSystem.vue. It's always some 800KiB. Can you help me, or tell me what I can refactor?

Link to file: https://github.com/Hjortur17/bilahotel/blob/master/resources/js/components/BookingSystem.vue

Jun
13
2 months ago
Activity icon

Started a new Conversation For Loop Renders Different Way In Production

I'm having trouble figuring out why my for loop is rendering correctly in my testing environment but the opposite way in production. Any ideas?

Here is the loop:

<div v-for="service in services" v-if="service.carSize === booking.carSize && service.visible" class="w-full md:w-1/3 -mx-4">
					<div class="flex p-4">
						<div class="flex-1">
							<input class="leading-tight" type="checkbox" :value="service.id" v-model="booking.checkedService" @click="addToArray(service.id);" :aria-label="service.description">
						</div>
						<div class="w-full ml-2 self-center">
							<p class="font-bold" v-text="service.description"></p>
							<p class="italic" v-text="service.price + 'kr'"></p>
						</div>
					</div>
				</div>
Activity icon

Replied to I Need Help Removing Unused Javascript

@jlrdw - Can you explain how I would do that?

This is my app.js

require('./bootstrap');

window.Vue = require('vue');

const files = require.context('./', true, /\.vue$/i)
files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))

const app = new Vue({
	el: '#app',
});
Activity icon

Started a new Conversation I Need Help Removing Unused Javascript

Hi, can anybody tell my about a good way to remove unused Javascript? When I run my website through Google Lighthouse it's always complaining about the Javascript file to be too big. Can anyone help me :)

Note: I don't have any extra compiling tools, I just use the build-in webpack.

Activity icon

Started a new Conversation Add Load Button While Waiting For Axios To Finish.

Hi, how can I add a spinning icon while Axios is finishing a POST request? I am creating and updating a booking in one request and it takes 1-2 second and I don't want people to think nothing happens and start clicking the button again and again...

BUTTON

<form method="POST" @submit.prevent="createBooking($event)" v-else>
	<button type="submit">Greiða</button>
</form>


AXIOS CALL

axios.post('/api/booking/create', {
					name: this.booking.name,
					socialId: this.booking.socialId,
					email: this.booking.email,
					phone: this.booking.phone,

					carNumber: this.booking.carNumber,
					carSize: this.booking.carSize,
					carMake: this.booking.carMake,
					carType: this.booking.carType,
					carColor: this.booking.carColor,

					dropOffDate: dayjs(this.booking.dropOffDate).format('DD/MM/YYYY'),
					dropOffTime: this.booking.dropOffTime,
					pickUpDate: dayjs(this.booking.pickUpDate).format('DD/MM/YYYY'),
					pickUpTime: this.booking.pickUpTime,

					numberOfDays: this.booking.numberOfDays, 

					accepted_terms: this.booking.termsChecked,
					send_bill: this.booking.send_bill,

					checkedService: this.booking.checkedService,

					discountUsed: this.couponInput,

					priceForServices: this.servicesPrice,
					priceForStorage: this.daysPrice,
					price: this.finalPrice,
					
					randomKey: randomKey
				})
				.then(response => {
					axios.post('/api/booking/update', {
						reference: response.data.randomKey
					})
					.then(response => {
						window.location.href = '/?status=1';
					});
				})
				.catch(function (error) {
					alert('Aðgerð tókst ekki!');

					console.log(error);

					return false;
				});
Jun
11
2 months ago
Activity icon

Replied to Change Auth Routes.

@sergiu17 - Hi, if I try your solution I get this error: Target class [App\Http\Controllers\LoginController] does not exist.

These are the additional routes I added:

Route::get('/innskra', '[email protected]');
Route::post('/innskra', '[email protected]');
Route::get('/lykilord/endurstilla', '[email protected]');
Route::post('/lykilord/endurstilla', '[email protected]');
Route::get('/lykilord/endurstilla/{token}', '[email protected]');
Route::post('/lykilord/netfang', '[email protected]');
Route::get('/lykilord/stadfesta', '[email protected]');
Route::post('/lykilord/stadfesta', '[email protected]');
Route::post('/netfang/endursenda', '[email protected]');
Route::get('/netfang/stadfesta', '[email protected]');
Route::get('/netfang/stadfesta/{id}/{hash}', '[email protected]');
Route::get('/notendur/{user}', '[email protected]');
Route::post('/notendur/{user}/oryggi', '[email protected]');
Route::post('/notendur/{user}/personu-upplysingar', '[email protected]');
Route::post('/nyskra', '[email protected]');
Route::get('/nyskra', '[email protected]');
Activity icon

Started a new Conversation Change Auth Routes.

Hi, how can I change the auth routes when I push to production? I have changed them in my development but when I push my code to Github, I don't changing. How can I push these changes to Github?

For example:

/login => /innskra /regiester => /nyskra /utskra => /utskra

May
31
2 months ago
Activity icon

Replied to Laravel Component Not Recognising My Variable.

@snapey - I don't understand. But if I remove : in front color I don't get a error message but it dosen't render the color.

Activity icon

Replied to Laravel Component Not Recognising My Variable.

I'm running 7.6.2

Here is the whole error message:

Facade\Ignition\Exceptions\ViewException
syntax error, unexpected '<' (View: /Users/hjorturfreyrlarusson/websites/portfolio/resources/views/components/layout.blade.php)
lluminate\View\Engines\PhpEngine::evaluatePath
resources/views/components/layout.blade.php:33

	@if (app()->environment('production'))
		<!-- Global site tag (gtag.js) - Google Analytics -->
		<script async src="https://www.googletagmanager.com/gtag/js?id=UA-156510698-2"></script>
		<script>
			window.dataLayer = window.dataLayer || [];
			function gtag(){dataLayer.push(arguments);}
			gtag('js', new Date());
 
			gtag('config', 'UA-156510698-2');
		</script>
	@endif
 
	<link rel="stylesheet" href="{{ asset('/css/app.css') }}">
</head>
<body>
	<div class="flex content-between flex-wrap min-h-screen py-8 md:py-16" id="app">
		{{ $slot }}
	</div>
 
	@if (session('flash.color') && session('flash.title') && session('flash.body'))
		<x-flash :color="{{ session('flash.color') }}"> // this line
			<x-slot name="title">{{ session('flash.title') }}</x-slot>
			<x-slot name="body">{{ session('flash.body') }}</x-slot>
		</x-flash>
	@endif
 
	<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>
 

Activity icon

Replied to Help With Json_encode

@tykus - I'm using this package right here, https://github.com/dweidner/laravel-goutte

Activity icon

Replied to Help With Json_encode

Looks nice, but I'm receiving this error:

Call to undefined method Symfony\Component\DomCrawler\Crawler::map()
Activity icon

Replied to Help With Json_encode

@tykus - When I try to use array_combine like this:

dump(array_combine(['title', 'sku', 'description', 'price', 'empty'], $dump));

I get this error message:

array_combine() expects parameter 2 to be array, string given

The code looks like this now:

$result = $crawler->filter('.product-details')->each(function ($node) {
		$dump = json_encode($node->children()->each(function ($product) {
			return $product->text();
		}), JSON_UNESCAPED_UNICODE);

		dump(array_combine(['title', 'sku', 'description', 'price', 'empty'], $dump));
	});
Activity icon

Replied to Help With Json_encode

@tykus - That fixed the language issue. Can you help me figure out how to get the whole title?

Activity icon

Started a new Conversation Help With Json_encode

Hi, I'm using json_encode to generate for me an object for each product I'm scraping from a website. But when I use json_encode it's changes some Icelandic character into some weird characters. Any idea how to fix that?

This: Philips Hue úti hreyfiskynjari


Turns into this: Philips Hue \u00fati hreyfiskynjari

And another thing, is it possible for me to name each object?

For example:

This: "["Philips Hue hreyfiskynjari","HUEOUTDOORSENS","hreyfiskynjari Vatnshelt","7.995 kr.",""]

Would be: "[title => "Philips Hue hreyfiskynjari",sku => "HUEOUTDOORSENS", description => "hreyfiskynjari Vatnshelt",price => "7.995 kr.",""]

Because when I try to get the title now in my blade file, doing this {{ $item[0] }}. It returns ", but not the title.

Activity icon

Replied to Laravel Component Not Recognising My Variable.

@snapey - This how I'm sending the flash session over to the blade file:

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,
			]);
		}
Activity icon

Replied to Laravel Component Not Recognising My Variable.

If I do it like this:

<x-flash :color="{{ session('flash.color') }}">

I get this error message.

syntax error, unexpected '<'

in this line - <x-flash :color="{{ session('flash.color') }}">
May
30
2 months ago
Activity icon

Replied to Undefined Variable: Object

This is what I ended up with:

$result = $crawler->filter('.product-details')->each(function ($node) {
		return json_encode($node->children()->each(function ($product) {
			return $product->text();
		}));
	});

	foreach ($result as $item) {
		echo $item;
	}
Activity icon

Replied to Undefined Variable: Object

So this:

$crawler->filter('.product-details')->each(function ($node) {
		$object = json_encode($node->children()->each(function ($product) {
			return $product->text();
		}));

		dump(json_decode($object));
	});

Returns this:

array:5 [▼
  0 => "Philips Hue úti hreyfiskynjari"
  1 => "HUEOUTDOORSENS"
  2 => "Nákvæmur hreyfiskynjari Fjölbreyttar stillingar Þráðlaus skynjari Vatnshelt"
  3 => "7.995 kr."
  4 => ""
]
array:5 [▼
  0 => "NanoLeaf viðbótar snjalllýsing - 3 stk"
  1 => "NL3300666"
  2 => "Fyrir NanoLeaf Viðbótarlýsing Þarfnast stjórnstöðvar 3 stk í pakka"
  3 => "8.995 kr."
  4 => ""
]

And I want to loop through this. I'm not familiar enough with map to know it that's the right move.

Activity icon

Started a new Conversation Undefined Variable: Object

Hi, can anybody help me figure out why the variable object is undefined?

$crawler->filter('.product-details')->each(function ($node) {
		return $object = json_encode($node->children()->each(function ($product) {
			return $product->text();
		}));
	});

	dump($object);
Activity icon

Replied to Laravel Component Not Recognising My Variable.

@bobbybouwmann - This is the current status of the code.

layout.blade.php

@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
flash.blade.php

<div class="bg-{{ $color }}-100" role="alert">
	<div class="flex items-center">
		<div class>
			<svg>
		</div>
		<div class="flex-1 px-2">
			<p class="text-{{ $color }}-500">{{ $title }}</p>
			<p>{{ $body }}</p>
		</div>
	</div>
</div>
Activity icon

Replied to Laravel Component Not Recognising My Variable.

Can anybody help me with this?

Activity icon

Replied to How To Create A Tailwind.css File From A Config File

I did understand this like he was looking for the command. My misunderstanding.

Activity icon

Awarded Best Reply on Use Goutte To Scrap Multiple Data From Single Div

I was able to figure this out.

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

$crawler->filter('.product-details')->each(function ($node) {
	$object = json_encode($node->children()->each(function ($product) {
		return $product->text();
	}));

	dump(json_decode($object));
});

return view('welcome');
Activity icon

Replied to Use Goutte To Scrap Multiple Data From Single Div

I was able to figure this out.

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

$crawler->filter('.product-details')->each(function ($node) {
	$object = json_encode($node->children()->each(function ($product) {
		return $product->text();
	}));

	dump(json_decode($object));
});

return view('welcome');
Activity icon

Replied to How To Create A Tailwind.css File From A Config File

@connecteev - This might help

  1. Install Tailwind:
# Using npm
npm install tailwindcss

# Using Yarn
yarn add tailwindcss
  1. Add Tailwind to your CSS
@tailwind base;

@tailwind components;

@tailwind utilities;
  1. Create your Tailwind config file
npx tailwindcss init
Activity icon

Replied to Use Goutte To Scrap Multiple Data From Single Div

Can anybody else help me with this?

May
24
2 months 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();