1,090 experience to go until the next level!
In case you were wondering, you earn Laracasts experience when you:
Earned once you have completed your first Laracasts lesson.
Earned once you have earned your first 1000 experience points.
Earned when you have been with Laracasts for 1 year.
Earned when you have been with Laracasts for 2 years.
Earned when you have been with Laracasts for 3 years.
Earned when you have been with Laracasts for 4 years.
Earned when you have been with Laracasts for 5 years.
Earned when at least one Laracasts series has been fully completed.
Earned after your first post on the Laracasts forum.
Earned once 100 Laracasts lessons have been completed.
Earned once you receive your first "Best Reply" award on the Laracasts forum.
Earned if you are a paying Laracasts subscriber.
Earned if you have a lifetime subscription to Laracasts.
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.
Earned once you have achieved 500 forum replies.
Earned once your experience points passes 100,000.
Earned once your experience points hits 10,000.
Earned once 1000 Laracasts lessons have been completed.
Earned once your "Best Reply" award count is 100 or more.
Earned once your experience points passes 1 million.
Earned once your experience points ranks in the top 50 of all Laracasts users.
hjortur17 left a reply on Request Return Null
Thanks @edoc - There was nothing wrong with to function. But here is the final result:
$camping = Camping::where('id', '=', $id)->first();
$data = $request->except('image_path');
$data['image_path'] = request()->file('image_path')->store('images', 'public');
$camping->update($data);
hjortur17 started a new conversation Request Return Null
Hello, i'm trying to update a image in my dashboard but when I submit the update form it always return with:
Call to a member function store() on null
I have dd and look in the request and it looks like i'm passing in a image. Any ideas how to fix that? This posed is relate to my other post: https://laracasts.com/discuss/channels/laravel/update-a-image-path
But here is my update method in the Controller:
´´´ public function update(Request $request, $id) { $data = $request->except('image_path'); $data['image_path'] = request()->file('image_path')->store('images', 'public'); $camping->update($data);
return redirect('/stjornbord/tjaldsvæði/breyta');
}
´´´
hjortur17 left a reply on Need Help With JQuery
@cronix - Thank you for the help, it worked.
hjortur17 left a reply on Need Help With JQuery
hjortur17 left a reply on Need Help With JQuery
@CRONIX - Can you show my example? Because Im not that good in jQuery and want to get better at it. But I cant figure out were to have the other function while still have access to the varibles from the success.
hjortur17 left a reply on Need Help With JQuery
@cronix - Where should I put my .calc function? If I move it out of the success it response with Can't find variable: input_ISK
hjortur17 left a reply on Need Help With JQuery
@realrandyallen - Didn't work. Nothing happend.
hjortur17 left a reply on Need Help With JQuery
@wilk_randall - It will not change the value :/
hjortur17 started a new conversation Need Help With JQuery
Hi, I'm building a currency converter for my app using an API. I'm trying to make it possible to put the amount in input and it will display how much it is. I'm trying to have it like this:
Before you type anything in the input it will display how much 1 ISK is in EUR, USD and GBP and then if you insert anything to the input it will calculate that. And right now it's always stuck with the value of 1 ISK.
This is my jQuery code:
$(document).ready(function () {
$.ajax({
'url': 'https://apis.is/currency/arion',
'type': 'GET',
'dataType': 'json',
'success': function(response) {
console.log(response);
var text_ISK = response.results[0].shortName;
var text_EUR = response.results[3].shortName;
var text_USD = response.results[1].shortName;
var text_GBP = response.results[2].shortName;
var input_ISK = response.results[0].value;
var input_EUR = response.results[3].value;
var input_USD = response.results[1].value;
var input_GBP = response.results[2].value;
$('#text_ISK').append(text_ISK);
$('#text_EUR').append(text_EUR);
$('#text_USD').append(text_USD);
$('#text_GBP').append(text_GBP);
var first_val_eur = input_ISK / input_EUR;
var first_val_usd = input_ISK / input_USD;
var first_val_gbp = input_ISK / input_GBP;
$('#ISK').val(input_ISK);
$('#EUR').val(first_val_eur.toFixed(2));
$('#USD').val(first_val_usd.toFixed(2));
$('#GBP').val(first_val_gbp.toFixed(2));
$(".calc").bind("keyup change", function(e) {
var val_eur = input_ISK / input_EUR;
var val_usd = input_ISK / input_USD;
var val_gbp = input_ISK / input_GBP;
if (!isNaN(val_eur) && val_eur !== Infinity) {
$("#EUR").val(val_eur.toFixed(2));
}
if (!isNaN(val_usd) && val_usd !== Infinity) {
$("#USD").val(val_usd.toFixed(2));
}
if (!isNaN(val_gbp) && val_gbp !== Infinity) {
$("#GBP").val(val_gbp.toFixed(2));
}
});
}
});
});
hjortur17 left a reply on Simple Update Not Working.
I recently changed the name from part to role and forgot to change it in the $fillable. Thank you @
hjortur17 started a new conversation Simple Update Not Working.
Hi, I have an update feature for my app. I having a problem updating Users role in the app. When I submit the update form I'm redirected back but the change didn't go through. Any ideas?
This is my function:
public function update(Request $request, $id)
{
$user = User::where('id', '=', $id)->first();
$user->update($request->all());
return redirect()->route('dashboard');
}
And this is the input:
<div class="flex items-center px-4 py-4">
<div class="w-1/6">
<p>Hlutverk</p>
</div>
<div class="w-5/6">
<input class="appearance-none block w-full bg-grey-lighter text-grey-darker border-2 border-grey-lighter rounded py-2 px-4 leading-tight focus:outline-none focus:bg-white focus:border-yellow-dark" type="text" name="role" value="{{ $user->role }}">
</div>
</div>
hjortur17 left a reply on Access Denied For User 'root'@'localhost'
The problem was more than one MySQL installation.
hjortur17 left a reply on TailwindCSS
Got it to work like this:
let mix = require('laravel-mix');
let tailwindcss = require('tailwindcss');
mix
.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.sass', 'public/css')
.options({
processCssUrls: false,
postCss: [ tailwindcss('./tailwind.js') ],
})
.browserSync({
proxy: 'project.test',
notify: {
styles: {
top: 'auto',
bottom: '20px'
}
}
});
PS. You don't need the .browserSync to get this to work.
hjortur17 left a reply on Unable To Deploy To Server
I found a way. I SSH into the server and did git checkout .
and it worked.
hjortur17 left a reply on Tag System
Thank you!
hjortur17 left a reply on Update A Image Path
@cronix - I am passing in an image but it always returns with Call to a member function store() on null. I tried dd and it showed like an image was in the request.
hjortur17 started a new conversation Tag System
Hello, I need help figuring out how to get my Tag system to work. This is my store function and I'm trying to store a array of tags. But I always get this error:
Call to a member function tags() on array
I have this in my Camping model:
public function tags()
{
return $this->belongsToMany('App\Tag');
}
And this in my store function:
$data = $request->except('image_path','tags');
$data->tags()->sync($request->tags, false);
$data['image_path'] = request()->file('image_path')->store('images', 'public');
$camping = Camping::create($data);
hjortur17 left a reply on Update A Image Path
@cronix - Now I'm getting this error on the update function (The store function worked).
Call to a member function store() on null
This is how the function looks like:
public function update(Request $request, $id)
{
// $data = Camping::where('id', '=', $id)->first();
$data = $request->except('image_path');
$data['image_path'] = request()->file('image')->store('images', 'public');
$camping->update($data);
return redirect('/stjornbord/tjaldsvæði/breyta');
}
And the input:
<span>Veldu mynd</span>
<input type="file" name="image" class="hidden">
hjortur17 started a new conversation Update A Image Path
Hello I'm building a dashboard with a update feature. On my thread I have image witch I store like this:
$camping = Camping::create([
'title' => request('title'),
'en_title' => request('en_title'),
'state' => request('states'),
'address' => request('address'),
'body' => request('body'),
'en_body' => request('en_body'),
'phone' => request('phone'),
'email' => request('email'),
'website' => request('website'),
'opening' => request('opening'),
'image_path' => request()->file('image')->store('images', 'public')
]);
And now I'm trying to figure out how to update it when I post the update form. This is how the controller looks like right now:
public function update(Request $request, $id)
{
$camping = Camping::where('id', '=', $id)->first();
$camping->update($request->all());
$request->image->store('images', 'public');
return redirect()->route('dashboard');
}
hjortur17 left a reply on Method Illuminate\Auth\SessionGuard::camping Does Not Exist
Yeah I see the problem now I accidentally changed the $user to $camping when I moved it over. Thank you @snapey
hjortur17 left a reply on Method Illuminate\Auth\SessionGuard::camping Does Not Exist
Yeah I see the problem now I accidentally changed the $user to $camping when I moved it over. Thank you @snap
hjortur17 left a reply on Method Illuminate\Auth\SessionGuard::camping Does Not Exist
Yeah I see the problem now I accidentally changed the $user to $camping when I moved it over. Thank you @sna
hjortur17 left a reply on Method Illuminate\Auth\SessionGuard::camping Does Not Exist
Okay so I have a button on the dashboard which is linked to a camping site and when I'm redirected to the site the input should have the value connected to the link.
And the error looks like this:
public function __call($method, $parameters) { if (! static::hasMacro($method)) { throw new BadMethodCallException(sprintf( 'Method %s::%s does not exist.', static::class, $method )); }
$macro = static::$macros[$method];
if ($macro instanceof Closure) {
return call_user_func_array($macro->bindTo($this, static::class), $parameters);
}
return call_user_func_array($macro, $parameters);
}
hjortur17 left a reply on Method Illuminate\Auth\SessionGuard::camping Does Not Exist
I have no idea what Session Guard is. But the error message is like this
hjortur17 left a reply on Method Illuminate\Auth\SessionGuard::camping Does Not Exist
I made special Middleware called IsAdmin. I got this form on the dashboard.
hjortur17 left a reply on Method Illuminate\Auth\SessionGuard::camping Does Not Exist
I'm trying to update my Campingsite in the CampingController (usually I did it in the DashboardController).
hjortur17 left a reply on Method Illuminate\Auth\SessionGuard::camping Does Not Exist
Sorry about that
hjortur17 started a new conversation Method Illuminate\Auth\SessionGuard::attempt Does Not Exist. (View:
Hi, I have no idea why I'm getting this error message. Please help :)
hjortur17 left a reply on Returning XML File
@SNAPEY - Im jusing this package, but im not sure if I need to make Route for it or anything like that. I have this file in the public folder and I connected Google Search Engine to /sitemap
hjortur17 left a reply on Returning XML File
@CRONIX - Hi, I don't understand XML. I moved it to the rood of my project and I still don't understand how to get it to work
hjortur17 started a new conversation Returning XML File
Hello, I'm having trouble to upload sitemap and getting it to work. I have a controller where I'm trying to return a view to the public folder where I'm storing my sitemap.xml file. I'm trying to use Google Search Console and read mydomain.is/sitemap but I can't figure out how to load the file from Laravel.
My Controller is like this:
class SitemapController extends Controller
{
public function index()
{
return view(asset('sitemap.xml');
}
}
My Route is like this:
Route::get('/sitemap', '[email protected]');
hjortur17 left a reply on Storage
@ARUSZALA - I SSH into the server and ran these commands and it worked.
And it magically worked. Thanks everybody for helping out. Special thanks to for providing the last help.
hjortur17 left a reply on Storage
I SSH into the server and ran these commands and it worked.
And it magically worked. Thanks everybody for helping out.
hjortur17 started a new conversation Foreach
Hi, I need quick help regarding my foreach loop. I want to run though all the places that is in the state Vestfirdir. But I can't figure out have I can only get these place insted of every places. Do I need to do this in the Controller?
@if ($places->contains('state', 'vestfirdir'))
@foreach ($places as $place)
<div class="w-auto lg:w-64 xl:w-64 p-2 text-center lg:text-left xl:text-left">
<a href="{{ $place->path() }}" class="font-light link text-blue-light">{{ $place->title }}</a>
/div>
@endforeach
@else
<div class="w-auto lg:w-64 xl:w-64 p-2 text-center">
<p class="font-light link text-grey-darker">@lang('camping.announcment')</p>
</div>
@endif
hjortur17 left a reply on Storage
@aruszala - this didn't work 'image_path' => request->file('image')->store('images', 'public') :/
hjortur17 left a reply on Storage
Here is my code where I'm getting the image.
@extends ('layouts.post')
@section ('main')
<div class="container mx-auto py-12">
<div class="flex flex-col lg:flex-row xl:flex-row justify-between pt-8">
<div class="w-auto lg:w-3/5 xl:w-3/5 px-12 lg:px-4 xl:px-4">
<img class="block rounded-lg shadow-lg" src="{{ asset($camping->image_path) }}">
<div class="w-full h-auto bg-white shadow-lg rounded-lg mt-8 py-6 px-4">
<h2 class="text-yellow-dark mb-6 noselect">@lang('campsite.info')</h2>
<ul class="list-reset">
<li class="font-light">
<p class="mb-6 items-center">
<i class="fal fa-map-pin w-12 fa-lg text-center"></i>{{ $camping->address }}
</p>
</li>
<li class="font-light">
<p class="mb-6 items-center">
<i class="fal fa-mobile w-12 fa-lg text-center"></i><a class="link " href="tel:+354 {{ $camping->phone }}">{{ $camping->phone }}</a>
</p>
</li>
<li class="font-light">
<p class="mb-6 items-center">
<i class="fal fa-envelope w-12 fa-lg text-center"></i><a class="link " href="mailto:{{ $camping->email }}">{{ $camping->email }}</a>
</p>
</li>
<li class="font-light">
<p class="mb-6 items-center">
<i class="fal fa-globe-europe w-12 fa-lg text-center"></i><a class="link " href="{{ $camping->website }}">{{ $camping->website }}</a>
</p>
</li>
<li class="font-light">
<p class="mb-6 items-center">
<i class="fal fa-calendar w-12 fa-lg text-center"></i>{{ $camping->opening }}
</p>
</li>
</ul>
</div>
</div>
<div class="w-auto lg:w-2/5 xl:w-2/5 px-12 lg:px-4 xl:px-4 mt-12 lg:mt-0 xl:mt-0">
@if (App::isLocale('en'))
<h1 class="font-bold text-4xl text-grey-darker mb-6">{{ $camping->en_title }}</h1>
<p class="font-light leading-loose text-md mb-8">{{ $camping->en_body }}</p>
@else
<h1 class="font-bold text-4xl text-grey-darker mb-6">{{ $camping->title }}</h1>
<p class="font-light leading-loose text-md mb-8">{{ $camping->body }}</p>
@endif
<ul class="list-reset">
<li class="font-light">
<p class="mb-6 items-center text-3xl">
<i class="fal fa-swimmer pr-4 pb-4"></i>
<i class="fal fa-tint pr-4 pb-4 text-blue"></i>
<i class="fal fa-tint pr-4 pb-4 text-red"></i>
<i class="fal fa-toilet pr-4 pb-4"></i>
<i class="fal fa-shower pr-4 pb-4"></i>
<i class="fal fa-battery-three-quarters pr-4 pb-4"></i>
<i class="fal fa-golf-club pr-4 pb-4"></i>
<i class="fal fa-basketball-ball pr-4 pb-4"></i>
<i class="fal fa-tv pr-4 pb-4"></i>
</p>
</li>
</ul>
</div>
</div>
</div>
@endsection
hjortur17 left a reply on Storage
@aruszala - Im not using the Storage modal.
This is my controller:
public function store(Request $request)
{
$this->validate($request, [
'is-title' => 'required',
'en-title' => 'required',
'states' => 'required',
'address' => 'required',
'is-body' => 'required',
'en-body' => 'required',
'phone' => 'required',
'email' => 'required|email',
'website' => 'required',
'opening' => 'required',
'image' => 'required|image',
]);
$camping = Camping::create([
'title' => request('is-title'),
'en-title' => request('en-title'),
'state' => request('states'),
'address' => request('address'),
'body' => request('is-body'),
'en-body' => request('en-body'),
'phone' => request('phone'),
'email' => request('email'),
'website' => request('website'),
'opening' => request('opening'),
'image_path' => request('image')->store('images', 'public')
]);
return redirect('/stjornbord/bæta');
}
hjortur17 started a new conversation Storage
Hi, I can't see what is causing my image not to load. It's loading in the test environment but on the server, it's not loading. I'm using Laravel Storage and I have already made a link between them (Storage - Public). Inspect Elements say: Failed to load resource: the server responded with a status of 404 ()
hjortur17 started a new conversation GMAIL
Hi, I can't figure out how to receive emails from my contact form. I have allowed LESS SECURED APPS in my Google Settings and my .env file looks like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=MY_EMAIL
MAIL_PASSWORD=MY_PASSWORD
MAIL_ENCRYPTION=ssl
hjortur17 left a reply on AJAX Data
One simple question, have any of you guys idea how to get the last result for T
For example, now hardcoded 100 but I want to use i
let i;
for (i = 0; i < response.results[0].forecast.length; i++) {
console.log(i);
}
let degrees = response.results[0].forecast[100].T // W = lýsing
let city = response.results[0].name // F = vindhraði
let wind = response.results[0].forecast[100].F // D = vindátt
let windd = response.results[0].forecast[100].D // T = gráður
$('#degrees').append(degrees);
$('#city').append(city);
$('#wind').append(wind);
$('#windd').append(windd);
hjortur17 left a reply on Redirect Won't Work
I have my project at GitHub if you like to see all the routes and everything. https://github.com/Hjortur17/travelcard
hjortur17 left a reply on AJAX Data
@hectix @burlresearch - I understand the code but for some reason it will not print out in the #report ul
hjortur17 left a reply on Redirect Won't Work
No, I don't have any GET /hafa-samband
hjortur17 left a reply on Redirect Won't Work
So I have the same contact form on two pages. The home page and the about us and I initialise $places there