PT-83

PT-83

Member Since 9 Months Ago

Experience Points
19,560
Total
Experience

440 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
169
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 4
19,560 XP
Jul
03
2 months ago
Activity icon

Awarded Best Reply on How To Setup Multiple Sites On One Droplet With Laravel Forge?

I figured this out. It was nothing to do with forge or nginx but instead my home route.

Instead of Route::get('/home', @ controller it should have been Route::get('/', @ controller) It couldn't locate the public directory causing the 404.

Activity icon

Replied to How To Setup Multiple Sites On One Droplet With Laravel Forge?

I figured this out. It was nothing to do with forge or nginx but instead my home route.

Instead of Route::get('/home', @ controller it should have been Route::get('/', @ controller) It couldn't locate the public directory causing the 404.

Jun
30
2 months ago
Activity icon

Replied to Forge Provisioned DigitalOcean Nginx 404 Not Found

Can you explain how in more detail how you got this working in experiencing the same 404 issues.

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name ###.com;
    server_tokens off;
    root /home/forge/###.com/public;

  

    ssl_protocols TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA5SHA384:DHE-RS
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;


    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

Activity icon

Replied to How To Setup Multiple Sites On One Droplet With Laravel Forge?

Both websites are listening to the same 443 ssl http2. But one is working other 404.

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name ###.com;
    server_tokens off;
    root /home/forge/###.com/public;

  

    ssl_protocols TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA5SHA384:DHE-RS
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;


    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

Jun
26
2 months ago
Activity icon

Started a new Conversation How To Setup Multiple Sites On One Droplet With Laravel Forge?

I already have a digital droplet created and using it on another site. I am using laravel forge to deploy it all.

In terms of Forge, I simply added another website using the existing server which is showing me it’s functioning.

In Digital Ocean under networks, I added the other two domains @ (123.com & www.123.com). At Namecheap (where I purchased domain) I added the custom DNS ns1.digitalocean.com, 2, and 3.

But it’s still showing me a 404 when visiting the site?

Both sites are showing green on forge, but still, the second site is showing the 404. I am completely puzzled.

Activity icon

Replied to Upload Image To Existing Form

Hi @michaloravec update on this..

I pushed this to production and yet again the image upload breaks. There is not photo being rendered... Any idea why that is?

Jun
24
3 months ago
Activity icon

Replied to Using JS (Vue) In Larvel To Toggle Hamburger Button

Can you give me an example of this?

Jun
23
3 months ago
Activity icon

Replied to Using JS (Vue) In Larvel To Toggle Hamburger Button

Would this be a proper Vue registration?

window.Vue = require("vue");

Vue.component("menu", require("./components/menu.vue").default);```
Jun
18
3 months ago
Activity icon

Started a new Conversation Using JS (Vue) In Larvel To Toggle Hamburger Button

Hi all,

I am trying to get the hamburger toggle to open and close when clicked. I am using Laravel, tailwindcss, Vue, and JS.

My issue is I am confused about where to actually put the JS/Vue code.

I have js.app file, bootstrap.js file, components->exampleComponent (Vue file), but then there's also the Sass folder and files...

where would I put this logic?

const Vue = require("vue");
new Vue({
    el: "#nav",
    data: {
        isOpen: false
    },
    methods: {
        toggle() {
            this.isOpen = !this.isOpen;
        }
    }
});` 

Heres my webpack.mx.js file

const tailwindcss = require("tailwindcss");

mix.js("resources/js/app.js", "public/js")
    .sass("resources/sass/app.scss", "public/css")
    .options({
        processCssUrls: false,
        postCss: [tailwindcss("./tailwind.config.js")]
    });
Jun
16
3 months ago
Activity icon

Replied to Somehow I Lost My CSS Using Tailwind

I forgot to re-add the below inside app.scss file

@import "tailwindcss/base";

@import "tailwindcss/components";

@import "tailwindcss/utilities";

thanks @snapey

Jun
15
3 months ago
Activity icon

Started a new Conversation Somehow I Lost My CSS Using Tailwind

I wanted to install Vue in my Laravel project and did that, however, my webpack.mix.js reset. Now I pasted the code back as it was before re-run npm watch and now my CSS is gone?

Does anyone know what the issue is?

webpack

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

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

Layout

<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link href="{{ asset('css/app.css') }}" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.js" defer></script>
  <script src ="/js/app.js" defer></script>

 
  <script src="//cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script> 
Jun
11
3 months ago
Activity icon

Replied to Best Text Editor Or Option For An User To Publish An Article

Reviving this thread as I'm sure there are some newer text editors out there. What be would one that includes image uploads?

TinyMCE is no longer free.

Activity icon

Replied to Why Does The Blog Card Repeat Itself Below (Tailwind/Laravel)?

I changed the whole codebase to fix this essentially. Got it working now.

For those who may be interested

extends('layout')
@section('title', 'Blog')

@section('content')

<!---- start of blog cards --->
 

<body class="text-cw-grey-700 ">
  <main class="container mx-auto max-w-6xl px-5">
    <article class="border-t border-cw-grey-100 flex justify-between py-10">
      <a href="#" class="w-1/2 mr-12">
        <img src="images/T-Sky.jpg" alt="" class="border-sm">
      </a>
      <div class="w-1/2 mt-4">
        <a href="#" class="text-cw-blue-300 hover:text-cw-blue-600 hover:underline text-sm mb-1 block">Link</a>
        <h1 class="mb-3"><a href="#"
            class="font-bold font-work-sans text-3xl text-cw-gray-800 leading-tight hover:text-cw-blue-600 hover:underline"></a>
        </h1>
        <p class="leading-relaxed"></p>
      </div>
    </article>

    <!--- begin posts container -->
    <div class="mt-4 grid grid-cols-3 gap-8 row-gap-6">

    <!-- iterate posts --->
@foreach ($posts as $post)
      <article>
        <a href="#">
          <img src="https://images.unsplash.com/photo-1590173872084-274b70b057a4?ixlib=rb-1.2.1&auto=format&fit=crop&w=3151&q=80"  alt="" class="mb-2">
        </a>
        <a href="#" class="text-cw-blue-300 hover:text-cw-blue-600 hover:underline text-sm mb-1 block">Text here</a>
        <h2><a href="#"
        class="font-bold font-work-sans text-xl text-cw-gray-900 hover:text-cw-blue-600 hover:underline "><a href="/posts/{{$post->id}}">{{ $post->title }}</a>
        </h2>
        <p class="text-sm leading-loose">{{ $post->excerpt }}</p>
      </article>
@endforeach

@endsection
Jun
05
3 months ago
Activity icon

Started a new Conversation Why Does The Blog Card Repeat Itself Below (Tailwind/Laravel)?

Hi all,

I have a blog template I am experimenting with but I ran into this issue of the blog post aligns vertically instead of horizontally.

How do I get the cards to line up in a 3 x3 row? https://ibb.co/8sgWd8w

index.blade.php

@section('title', 'Blog')

@section('content')

<div class="relative bg-gray-50 py-16 px-4 sm:px-6 lg:px-8">
<div class="absolute inset-0">
<div class="bg-white h-1/3 sm:h2/3"></div>
<div class="relative max-w-7xl mx-auto">
<div class="text-center">
<h2 class="text-4xl leading-10 tracking-tight font-extrabold text-gray-900 mt-10">From the Blog</h2>
<p class="mt-5 max-w-2xl mx-auto text-xl leading-7 text-gray-500">The subject matter will include Entrepreneurship, Marketing, Community, Social Media Growth and much more... </p>
</div>
</div>
</div>
@foreach ($posts as $post)
<section class="text-gray-700 body-font mt-10">
    <div class="container px-5 py-24 mx-auto">
      <div class="flex flex-wrap -m-4">
        <div class="p-4 md:w-1/3">
          <div class="h-full border-2 border-gray-200 rounded-lg overflow-hidden">
            <img class="lg:h-48 md:h-36 w-full object-cover object-center" src="https://images.unsplash.com/photo-1526657782461-9fe13402a841?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1538&q=80" alt="blog">
            <div class="p-6">
              <h2 class="tracking-widest text-xs title-font font-medium text-gray-500 mb-1">Blog</h2>
            <h1 class="title-font text-lg font-medium text-gray-900 mb-3">{{ $post->title }}</h1>
            <p class="leading-relaxed mb-3">{{ $post->excerpt }}</p>
              <div class="flex items-center flex-wrap ">
                <a class="text-indigo-500 inline-flex items-center md:mb-2 lg:mb-0">Learn More
                  <svg class="w-4 h-4 ml-2" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
                    <path d="M5 12h14"></path>
                    <path d="M12 5l7 7-7 7"></path>
                  </svg>
                </a>
                <span class="text-gray-600 mr-3 inline-flex items-center lg:ml-auto md:ml-0 ml-auto leading-none text-sm pr-3 py-1 border-r-2 border-gray-300">
                  <svg class="w-4 h-4 mr-1" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24">
                    <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
                    <circle cx="12" cy="12" r="3"></circle>
                  </svg>1.2K
                </span>
                <span class="text-gray-600 inline-flex items-center leading-none text-sm">
                  <svg class="w-4 h-4 mr-1" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24">
                    <path d="M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z"></path>
                  </svg>6
                </span>
              </div>
            </div>
          </div>
        </div>
    @endforeach
  </section>

@endsection
May
23
4 months ago
Activity icon

Replied to Upload Image To Existing Form

Yes, its solved! Thank you so much, this has been a great learning experience for me with your help!

Activity icon

Replied to Upload Image To Existing Form

I think this is it... I opened the broken image link in a separate tab

http://127.0.0.1:8000/posts/uploads/aFnj5O1jSpv3nb.jpeg -> not the right url

http://127.0.0.1:8000/storage/uploads/aFnj5O1jSpv3nb.jpeg -> this is the URL it should be fetching and the image is rendering fine.

May
22
4 months ago
Activity icon

Replied to Upload Image To Existing Form

No luck yet I've tried other variations of code but nothing seems to get the image to load.

This is what I am seeing https://ibb.co/dpZmGDV

I can see the image when I visit http://127.0.0.1:8000/storage/uploads/image_name.jpeg and when I connect to tableplus GUI it is being passed to the table???

May
20
4 months ago
Activity icon

Replied to Upload Image To Existing Form

I used guarded.


namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    protected $guarded = [];
}
Activity icon

Replied to Upload Image To Existing Form

sure, updated original post

Activity icon

Replied to Upload Image To Existing Form

@michaloravec sorry about that. I get null

Activity icon

Replied to Upload Image To Existing Form

Done. I got another error this time Class 'App\Http\Controllers\Storage' not found however I used use Illuminate\Support\Facades\Storage; which solved that (getting used to that)..

Everything is functioning fine but the image is still not being shown. Perhaps something in the form (show.blade.php) fie?

Activity icon

Replied to Upload Image To Existing Form

Class 'App\Http\Controllers\Str' not found @michaloravec by the way you are solid thanks so much for the help so far!!!

error points to $filename = Str::random(14).'.'.request()->image->getClientOriginalExtension()

Activity icon

Replied to Upload Image To Existing Form

Installed... I always get an error this time its Intervention\Image\Exception\NotReadableException Image source not readable image is a jpg.

Activity icon

Replied to Upload Image To Existing Form

@michaloravec I think this is the problem. I just uploaded the photo from my desktop no other installations and not using any program or code like image.intervention.io

But I'm assuming by installing the above it would then function, correct?

Activity icon

Replied to Upload Image To Existing Form

Done. New error Class 'Intervention\Image\Facades\Image' not found

Activity icon

Replied to Upload Image To Existing Form

@michaloravec yes I can. localhost address /storage/uploads/name of file.

Interesting now I submitted the form and got an error (that I didn't get before) the image is still passed but the error is Class 'App\Http\Controllers\Image' not found and it references $image = Image::make(public_path('storage/' . $post->image))->fit(500, 500, null, 'top-left'); code.

Activity icon

Replied to Upload Image To Existing Form

Hi @michaloravec

Yes the image exists in two places.

App/storage/uploads I then create a storage link which makes the file available in public/storage/uploads

Activity icon

Replied to Upload Image To Existing Form

Hi @nishan12 no adding 'uploads' didn't work unfortunately.

Activity icon

Started a new Conversation Upload Image To Existing Form

Hi all, I have successfully added an image file picker to an existing form.

Also, I have php artisan storage:link to access the public/storage/uploads folder which contains the image that was uploaded.

Next step I included an @if statement in my show view to render the image when looking at post details. However, the image is not showing at all in the show view? I am perplexed as to what I'm missing???

PostController

<?php

namespace App\Http\Controllers;

use App\Post;
use Auth;
use Illuminate\Http\Request;
use Intervention\Image\Facades\Image;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Storage;
 

class PostController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $posts = Post::all();

        return view('post.index', compact('posts'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $post = new Post();

        return view('post.create', compact ('post'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */

    public function store(Request $request)
    {
        $request->validate([
            'title' => 'required',
            'body' => 'required',
        ]);
        $post = new Post();
        $post->user_id = Auth::user()->id;
        $post->title = $request->title;
        $post->body = $request->body;
        $this->storeImage($post);
        $post->save();


        return redirect('/posts');
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Post  $post
     * @return \Illuminate\Http\Response
     */
    public function show(Post $post)
    {
        return view('post.show', compact('post'));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Post  $post
     * @return \Illuminate\Http\Response
     */
    public function edit(Post $post)
    {
        return view('post.edit', compact('post'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Post  $post
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Post $post)
    {
        $post->update($this->validatedRequest());

        $this->storeImage($post);

        return redirect('/posts');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Post  $post
     * @return \Illuminate\Http\Response
     */
    public function destroy(Post $post)
    {
        $post->delete();

        return redirect('/posts');
    }

    private function validatedRequest()
    {
        return request()->validate([
            'title' => 'required',
            'body' => 'required',
            'image' => 'sometimes|file|image|max:5000',
        ]);
    }
        
    private function storeImage($post)
    {

        if (request()->has('image')) {
            $filename = Str::random(14).'.'.request()->image->getClientOriginalExtension();
        
            $image = Image::make(request()->image)->fit(500, 500, null, 'top-left')->encode();
        
            Storage::disk('public')->put("uploads/{$filename}", (string) $image);
        
            $post->update([
                'image' => "uploads/{$filename}"
            ]);
        }
    }
}

Form (show.blade.php)

@extends('layouts.app')

@section('content')

<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="pt-3 pl-3 pr-3 card">
                <h1 class="text-secondary">Post Details</h1>

                    <div>
                        <a href="/posts"><- Back</a>
                    </div> 

                    <strong class="text-secondary mt-2">Title</strong>
                         <p>{{ $post->title }}</p>

                    <strong class="text-secondary mt-2">Body</strong>
                        <p>{{ $post->body }}</p>

                @if($post->image)
                    <div class="row">
                        <div class="col-12">
                            <img src="{{ asset('storage/' . $post->image) }}" alt="" class="img-thumbnail">
                        </div>
                    </div>
                @endif

                <div>
                    <a href="/posts/{{ $post->id }}/edit">Edit</a>

                    <form action="/posts/{{ $post->id }}" method="post">
                         @method('DELETE')
                        @csrf

                        <button class="btn btn-danger mt-3 mb-3">Delete</button>  
                    </form>
                </div> 
            </div>
        </div>
    </div>
</div>
@endsection
May
19
4 months ago
Activity icon

Awarded Best Reply on ArgumentCountError Too Few Arguments

Hey all,

I found the issue, at the protected function create(array $data) I was using the wrong instance meaning no data was being sent. So I changed the code like so protected function create(Request $data) which is now working great.

Activity icon

Replied to Where Are You All From?

Toronto, Canada :)

Activity icon

Replied to 500 Server Error Again

Thanks, @sergiu17 !!!

I am also experiencing a server error when I submit the post. I was able to get the upload image file to be visible on the form itself, but once I submit the post it gives me a server 500 again...(bane of my existence). Any idea?

Activity icon

Started a new Conversation 500 Server Error Again

Hi again, I'm sorry for another server error post but I'm not sure what I did to get this error. My create post form was working fine until I tried to add a new field "image" upload to the form. Now when I visit the /posts/create page I get a server error 500.

Any idea why this is occurring?

web.php

<?php

use Illuminate\Support\Facades\Route;
use App\Mail\WelcomeMail;

Route::group(['middleware' => 'web'], function () {
    Route::auth();

    Route::get('/', function () {
        return view('welcome');
    });

Route::get('/home', '[email protected]');
});

Route::get('/about', function () {
    return view('about');
}); 

Route::get('/email', function () {
    return new WelcomeMail();
});

Auth::routes();

Route::get('/posts', '[email protected]');
Route::get('/posts/create', '[email protected]');
Route::post('/posts/create', '[email protected]');
Route::get('/posts/{post}', '[email protected]');
Route::get('/posts/{post}/edit', '[email protected]');
Route::patch('/posts/{post}', '[email protected]');
Route::delete('/posts/{post}', '[email protected]');

Route::post('/register', 'Auth\[email protected]')->name('register');

Route::get('/contact', '[email protected]');
Route::post('/contact', '[email protected]');

Form

<div class="container">
    <div class="row justify-content-cemter">
       <div class="col-md-8">
           <div class="card">
               <div class="card-header">Create New Post</div>


                <div class="card-body">
                    <form action="/posts/create" method="POST" enctype="multipart/form-data">


                        @csrf

                        <div class="form-group">
                            <label for="title">Title</label>
                            <input name="title" type="text" class="form-control" id="title" aria-describedby="titleHelp" placeholder="Enter Title" autocomplete="off">
                            <small id="titleHelp" class="form-text text-muted">Give your post a title that will describe your post easily</small>
                        </div>

                        <div class="form-group">
                            <label for="body">Body</label>
                            <textarea type="text" name="body" cols="30" rows="3" class="form-control" id="body" aria-describedby="bodyHelp" placeholder="Enter Post Body" autocomplete="off"></textarea>
                             <small id="bodyHelp" class="form-text text-muted">Enter as much detail you'd like!</small>
                        </div>

                        <div class="form-group d-flex flex-column">
                            <label for="image">Image</label>
                            <input type="file" name="image" class="py-2">
                        <div>{{ errors->first('image') }}</div>
                        </div>

                        <button type="submit" class="btn btn-primary">Create Post</button>

                        @if (session('message'))

                            <div>
                                {{ session('message') }}
                            </div>
                        @endif

                    </form>

                    @if ($errors->any())
                        <div class="alert alert-danger mt-5">
                            <ul>
                     @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                    @endforeach
                            </ul>
                        </div>
                    @endif
                </div>
            </div>
        </div>
    </div>
</div>

migration


use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePostsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id');
            $table->string('title');
            $table->longText('body');
            $table->string('image')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('posts');
    }
}
Activity icon

Replied to ArgumentCountError Too Few Arguments

Hey all,

I found the issue, at the protected function create(array $data) I was using the wrong instance meaning no data was being sent. So I changed the code like so protected function create(Request $data) which is now working great.

May
18
4 months ago
Activity icon

Started a new Conversation ArgumentCountError Too Few Arguments

Hi all,

On localhost when I try to register a new user I get this error "ArgumentCountError Too few arguments to function App\Http\Controllers\Auth\RegisterController::create(), 0 passed and exactly 1 expected".

However, I am not entirely sure why it's throwing this error. Hoping for some guidance on this one (like many others..) The RegisterController is the default when installing in Laravel.

I should note in production I can register no problem just on localhost it gives me the too few arguments error. I want to test new features on localhost prior to making it to production.

Web.php

<?php

use Illuminate\Support\Facades\Route;
use App\Mail\WelcomeMail;

Route::group(['middleware' => 'web'], function () {
    Route::auth();

    Route::get('/', function () {
        return view('welcome');
    });

Route::get('/home', '[email protected]');
});

Route::get('/about', function () {
    return view('about');
}); 

Route::get('/email', function () {
    return new WelcomeMail();
});

Auth::routes();

Route::get('/posts', '[email protected]');
Route::get('/posts/create', '[email protected]');
Route::post('/posts/create', '[email protected]');
Route::get('/posts/{post}', '[email protected]');
Route::get('/posts/{post}/edit', '[email protected]');
Route::patch('/posts/{post}', '[email protected]');
Route::delete('/posts/{post}', '[email protected]');

Route::post('/register', 'Auth\[email protected]')->name('register');

Route::get('/contact', '[email protected]');
Route::post('/contact', '[email protected]');

RegisterController


namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */
    protected $redirectTo = RouteServiceProvider::HOME;

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }
}
Activity icon

Started a new Conversation One To One, And One To Many Relationships?

Hello,

In my web application, when I create a post, it can be seen by other users. Therefore, each user can see other user's posts.

In order to have the users post only visible to themselves, would it make sense to create a 'user can have many posts' but 'a post can only have one user' relationship? Would that be done by using eloquent?

Also, the next step would be if the user would like the post to become public, that can simply click share and it would be visible to all.

How would I be able to accomplish the above? any resources I can look into or video lessons, etc?

thanks in advance.

May
09
4 months ago
Activity icon

Replied to Integrating Mail-chimp API In Laravel

Thanks I'll take a look!!

Activity icon

Started a new Conversation Integrating Mail-chimp API In Laravel

Hey all,

As the title suggests is there a resource or can you point me in the right direction on how to correctly set up a Mailchimp API?

I have zero experience doing this but I need to get it implemented in my application as there are users signing up, but I have no way to respond currently (other than manually adding the users to a list).

Thanks in advance.

May
06
4 months ago
Activity icon

Replied to Php Returning Empty Array?

Hi all, thanks for your assistance. I am not sure what I did wrong here, but I moved on with the tutorial lesson and got it to work with different data. I did tinker with localhost which could have solved the issue also.

Consider this closed.

Thank you all.

May
05
4 months ago
Activity icon

Replied to Php Returning Empty Array?

I tried but nothing the same things occur. The bulleted list with no data from the array being passed. I have a funny feeling this is a localhost issue on my end. I will try and diagnose and see what I can come up with.

Activity icon

Replied to Php Returning Empty Array?

@james_moore after var_dump nothing is happening and the 4 bullet list is still showing with no additional data. Also I noticed this on localhost Closed without sending a request; it was probably just an unused speculative preconnection not sure if that's causing an issue.

I also edited the <?= $key; ?> to use <?php tags instead

Activity icon

Replied to Php Returning Empty Array?

Hi @james_moore, I am getting the bullet list also but the problem is it's not passing the array data to the list for some reason.

Activity icon

Replied to Php Returning Empty Array?

@michaloravec unfortunately, it's still showing a bullet but with no data from the array.

Activity icon

Started a new Conversation Php Returning Empty Array?

Following along in the php series there's homework about arrays.

When I run the code (that's replicated from the video) it's outputting an empty array, not sure why that's happening? Any idea what im doing wrong?

index.php

<?php


$person = [
    'age' => 31,
    'height' => 5,
    'profession' => 'unkown'
];

require 'index.view.php'; 

index.view.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <ul>    

        <?php foreach ($person as $key => $feature) : ?>

            <li><strong><?= $key; ?></strong> <?= $feature; ?></li>

        <?php endforeach; ?>

    </ul>
    
</body>
</html>
May
04
4 months ago
Activity icon

Commented on Step 7: Associative Arrays

When I run the code is outputting an empty array, not sure why that's happening? Any idea what im doing wrong?

index.php

<?php


$person = [
    'age' => 31,
    'height' => 5,
    'profession' => 'unkown'
];

require 'index.view.php'; 

index.view.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <ul>    

        <?php foreach ($person as $key => $feature) : ?>

            <li><strong><?= $key; ?></strong> <?= $feature; ?></li>

        <?php endforeach; ?>

    </ul>
    
</body>
</html>
Activity icon

Started a new Conversation I Love Laravel But I Am Not Understanding All The Concepts Etc

I have dabbled in code like completing the css/html on freecode camp. I have touched javascript but really don't remember much.

I love Laravel as it supplies so much out of the box, but when watching videos like building an app for instance there is a lot of things going on I don't necessarily understand, which I think is limiting my coding to very basic concepts. To give you an example, when I see something like this; $this->get($post)->where()->auth() return, etc.. I really don't understand what exactly is happening here.

My question is what resource should I be looking at to really grasp these concepts? Should I begin with PHP then move to Laravel at that point? What are good resources to look at?

I stated laravel learn the basics and began with laravel 6 start from scratch series, is that a good place to start?

Thanks for your help

May
01
4 months ago
Activity icon

Replied to Email Service

According to Mailguns site, the free tier is still available, "Try us out! Get 5,000 free emails per month for 3 months, then only pay for what you send" if I'm understanding this correctly, after the trial period you can still send 1000 emails for free but 0.80 per email afterward.

Are there any other good options?

Activity icon

Replied to Footer That Stays At The Bottom?

@michaloravec Works but it covers the CTA button on the homepage.