rovshena

Member Since 1 Week Ago

Experience Points
5,970
Total
Experience

4,030 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
14
Lessons
Completed
Best Reply Awards
7
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.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 2
5,970 XP
Apr
15
1 day ago
Activity icon

Replied to Concatenate String On Blade

@Hammadrashid

@foreach($ind as $record1)
	@foreach($indus as $industry)
		@if($industry->id == $record1)
			{{ $industry->name }} {{ ($loop->count > 1 && !$loop->last) ? '|' : '' }}
		@endif
	@endforeach
@endforeach
Activity icon

Awarded Best Reply on Redirect On A 404

https://laravel.com/docs/8.x/routing#fallback-routes

Fallback Routes
Using the Route::fallback method, you may define a route that will be executed when no other route matches the incoming request. Typically, unhandled requests will automatically render a "404" page via your application's exception handler. However, since you would typically define the fallback route within your routes/web.php file, all middleware in the web middleware group will apply to the route. You are free to add additional middleware to this route as needed:

Route::fallback(function () {
    // 
});

The fallback route should always be the last route registered by your application.
Route::fallback(function () {
    return redirect('/');
});
Activity icon

Replied to Laravel8 Errors

Errors in browser console?

Activity icon

Replied to Redirect On A 404

https://laravel.com/docs/8.x/routing#fallback-routes

Fallback Routes
Using the Route::fallback method, you may define a route that will be executed when no other route matches the incoming request. Typically, unhandled requests will automatically render a "404" page via your application's exception handler. However, since you would typically define the fallback route within your routes/web.php file, all middleware in the web middleware group will apply to the route. You are free to add additional middleware to this route as needed:

Route::fallback(function () {
    // 
});

The fallback route should always be the last route registered by your application.
Route::fallback(function () {
    return redirect('/');
});
Apr
14
2 days ago
Activity icon

Replied to Can't Change Password . Password Not Match .

This is my changePassword method:

use App\Rules\Password; //my custom rule for password strength
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;

    public function changePassword(Request $request)
    {
        $user = $request->user();
        Validator::make($request->all(), [
            'password' => ['required', 'confirmed', 'string', 'max:250', new Password],
            'current_password' => ['required', 'string'],
        ])->after(function ($validator) use ($request, $user) {
            if (!Hash::check($request->current_password, $user->password)) {
                $validator->errors()->add('current_password', __('Current password mismatch.'));
            }
        })->validate();

        $user->password = Hash::make($request->password);

        if ($user->save()) {
            return back()->with('success', __('Password updated successfully.'));
        } else {
            return back()->with('error', __('Password can not updated.'));
        }
    }
Activity icon

Replied to Redirecting Index.php

Configure root directory of your web server. For example in local Apache web server

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/my_project/public"
    ServerName my-project.local
</VirtualHost>
Apr
13
3 days ago
Activity icon

Awarded Best Reply on Get Dynamic Value Of Data In Vuejs

<template>
	<div>
		<p> Index time: {{ getTime(index) }} </p> 
		<p> About time: {{ getTime(about) }} </p>
	</div>
</template>

<script>
export default {
    data() {
      return {
        index:{
          time: '00:00:05.000',
          timeBegan: null
        },
        about:{
          time: '00:00:10.000',
          timeBegan: null
        },
      }
    },
    methods: {
      getTime(param) {
        return param.time;
      }
    },
}
</script>
Apr
12
4 days ago
Activity icon

Replied to Modal Is Not Scrollable

In Bootstrap 4: You can create a scrollable modal that allows scroll the modal body by adding .modal-dialog-scrollable to .modal-dialog.

https://getbootstrap.com/docs/4.6/components/modal/#scrolling-long-content

<!-- Scrollable modal -->
<div class="modal-dialog modal-dialog-scrollable">
  ...
</div>
Apr
10
6 days ago
Activity icon

Replied to Storage:link Not Working In Host

1.Delete storage folder symbolic link in root_of_project/public/. If exists.
2.Run php artisan storage:link command.
3.Upload your files to root_of_project/storage/app/public/
Activity icon

Replied to LEFT JOIN

This is my last solution:

$artistArtworksAndShares = DB::table('artists')
            ->leftJoin('artworks', 'artists.id', '=', 'artworks.artist_id')
            ->leftJoin('artwork_shares', 'artist.id', '=', 'artwork_shares.viewer_id')
            ->select('artist.id', 'artworks.id', 'artworks.title', 'artworks.image_url', 'artwork_shares.title')
			->where('artists.id', 2)
            ->get();
Activity icon

Replied to Routing And Getting Data From A Dropdown

And this is Bootstrap 4 dropdown: https://getbootstrap.com/docs/4.6/components/dropdowns/

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown button
  </button>
  <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">

	@foreach($users as $user)
		<a class="dropdown-item" href="/user/{{ $user->id }}/create-address"> 
			{{ $user->name }} 
    	</a>
	@endforeach

  </div>
</div>
Activity icon

Replied to Routing And Getting Data From A Dropdown

Bootstrap 5 dropdown: https://getbootstrap.com/docs/5.0/components/dropdowns/

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown button
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
	
	@foreach($users as $user)
	<li>
		<a class="dropdown-item" href="/user/{{ $user->id }}/create-address"> 
			{{ $user->name }} 
    	</a>
	</li>
	@endforeach

  </ul>
</div>
Activity icon

Replied to Routing And Getting Data From A Dropdown

Put this in your dropdown component:

@foreach($users as $user)
	<a class="dropdown-item" href="/user/{{ $user->id }}/create-address"> 
		{{ $user->name }} 
    </a>
@endforeach
Activity icon

Replied to Laravel Pagination OnEachSide Is Not Working

In your controller:

​public function show()
​{
   ​$users = User::paginate(5, ['*'], __('page'))->onEachSide(2);

   ​return view('user-list-view', ['users' => $users]);
​}

In your view:

{{ $users->links() }
Activity icon

Replied to LEFT JOIN

What about this?

$artworks = Artwork::where('artist_id', $id)->get();

foreach($artworks as $artwork) {
	$artworkShares = $artwork->artworkShares;
	//...
}
Apr
09
1 week ago
Activity icon

Awarded Best Reply on How To Get The Value Of Sell Model

Try this:

{{ optional($healer->sell)->title }}
Activity icon

Replied to Verify Uploaded File/image

use Illuminate\Http\Request;

public function upload(Request $request)
{
	//The file under validation must be an image (jpg, jpeg, png, bmp, gif, svg, or webp).
	$request->validate([
		'my_image' => 'image',
	]);

	if ($request->hasFile('my_image') && $request->file('my_image')->isValid()) {

		// upload

	}
}
Activity icon

Replied to How To Get The Value Of Sell Model

Also try this:

{{ $healer->sell()->exists() ? $healer->sell->title : 'No sell'  }}
Activity icon

Replied to How To Get The Value Of Sell Model

Try this:

{{ optional($healer->sell)->title }}
Activity icon

Replied to How Can I Install 5.8 Laravel?

C:\xampp\htdocs
λ composer --version
Composer version 2.0.11 2021-02-24 14:57:23
C:\xampp\htdocs
λ php -v
PHP 7.4.12 (cli) (built: Oct 27 2020 17:18:47) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Activity icon

Replied to How Can I Install 5.8 Laravel?

C:\xampp\htdocs
λ composer create-project laravel/laravel blog "5.8.*"
Creating a "laravel/laravel" project at "./blog"
Installing laravel/laravel (v5.8.35)
  - Downloading laravel/laravel (v5.8.35)
  - Installing laravel/laravel (v5.8.35): Extracting archive
Created project in C:\xampp\htdocs\blog
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 86 installs, 0 updates, 0 removals
  - Locking beyondcode/laravel-dump-server (1.3.0)
  - Locking dnoegel/php-xdg-base-dir (v0.1.1)
  - Locking doctrine/inflector (1.4.3)
  - Locking doctrine/instantiator (1.4.0)
.
.
.
  - Locking theseer/tokenizer (1.2.0)
  - Locking tijsverkoyen/css-to-inline-styles (2.2.3)
  - Locking vlucas/phpdotenv (v3.6.8)
  - Locking webmozart/assert (1.10.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 86 installs, 0 updates, 0 removals
  - Downloading symfony/var-dumper (v4.4.21)
  - Downloading symfony/routing (v4.4.20)
  - Downloading symfony/http-foundation (v4.4.20)
  - Downloading symfony/error-handler (v4.4.21)
  - Downloading symfony/http-kernel (v4.4.21)
.
.
.

  - Downloading phpunit/php-code-coverage (6.1.4)
  - Downloading phpunit/phpunit (7.5.20)
  - Installing symfony/polyfill-php80 (v1.22.1): Extracting archive
  - Installing symfony/polyfill-php72 (v1.22.1): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.22.1): Extracting archive
  - Installing symfony/var-dumper (v4.4.21): Extracting archive
  - Installing symfony/polyfill-ctype (v1.22.1): Extracting archive
.
.
.
  - Installing phar-io/manifest (1.0.3): Extracting archive
  - Installing myclabs/deep-copy (1.10.2): Extracting archive
  - Installing phpunit/phpunit (7.5.20): Extracting archive
76 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
54 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan key:generate --ansi
Application key set successfully.

C:\xampp\htdocs
λ composer --version
Composer version 2.0.11 2021-02-24 14:57:23

C:\xampp\htdocs
λ php -v
PHP 7.4.12 (cli) (built: Oct 27 2020 17:18:47) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Activity icon

Replied to What Technology To Use For A New Project?

I recommend Laravel Lumen framework.

https://lumen.laravel.com/

Activity icon

Replied to Using Model Accessors And Mutators With Seeding And Testing (phpunit)

Change your mutator like this and then try:

public function setNameAttribute($value) 
{
	$this->attributes['name'] = $value;
}
Apr
08
1 week ago
Activity icon

Replied to I Need To Get Related Table In Array Format By 'with', But Pluck Not Work

Add this to Article Model

//Eager Loading By Default
protected $with = ['categories'];

public function getCategoriesId()
{
	return $this->categories->pluck('article_category_id');
}

And then try this code:

$articles = Article::all();

$arrayOfCategoriesId = $articles->getCategoriesId;
Activity icon

Replied to My Website Is Working Fine In Server But Same Laravel Project Not Working In Localhost Linux

Try to move your project somewhere outside xampp htdocs folder and then try php artisan serve. Do you get same error? What is your laravel version? Also share constants.php file.

Activity icon

Replied to My Website Is Working Fine In Server But Same Laravel Project Not Working In Localhost Linux

The problem is in your xampp configuration not in laravel. Do you configure correctly apache's virtual host configuration?

Activity icon

Replied to My Website Is Working Fine In Server But Same Laravel Project Not Working In Localhost Linux

Can you share the log file of nginx? Located at /var/logs/nginx/... access.log/error.log

Activity icon

Replied to My Website Is Working Fine In Server But Same Laravel Project Not Working In Localhost Linux

Can you share the log file located at ../storage/logs/laravel.log?

Activity icon

Replied to Problems Querying The Same Table(Self Referencing)

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    public function myBestFriend()
    {
        return $this->hasOne(User::class, 'friend_id');
    }
}

And query like this:

$users = User::all();

foreach($users as $user) {
	$myBestFriend = $user->myBestFriend;

	// $myBestFriend->email
}
Activity icon

Replied to Get Dynamic Value Of Data In Vuejs

<template>
	<div>
		<p> Index time: {{ getTime(index) }} </p> 
		<p> About time: {{ getTime(about) }} </p>
	</div>
</template>

<script>
export default {
    data() {
      return {
        index:{
          time: '00:00:05.000',
          timeBegan: null
        },
        about:{
          time: '00:00:10.000',
          timeBegan: null
        },
      }
    },
    methods: {
      getTime(param) {
        return param.time;
      }
    },
}
</script>
Activity icon

Replied to Get Dynamic Value Of Data In Vuejs

<template>
	<div>
		<p>{{ getTime('index').time }}</p>
	</div>
</template>

<script>
export default {
	data() {
      return {
        times: [
          {
            item: 'index',
            time: '00:00:05.000',
            timeBegan: null
          },
          {
            item: 'about',
            time: '00:00:10.000',
            timeBegan: null
          }
        ]
      }
    },
    methods: {
      getTime(param) {
        return this.times.find(time => {
          return time.item === param;
        });
      }
    },
}
</script>
Activity icon

Replied to Get Dynamic Value Of Data In Vuejs

Try this:

methods: {
	getTime(param) {
		if(param === 'index') {
			return this.index.time;
		} else {
			return this.about.time;
		}
	}
}
Activity icon

Replied to Get Dynamic Value Of Data In Vuejs

  data() {
      return {
        index:{
          time: '00:00:05.000',
          timeBegan: null
        },
        about:{
          time: '00:00:10.000',
          timeBegan: null
        }
      }
    },
    methods: {
      getTime(param) {
        return eval( 'this.' + param + '.time');
      }
    }

Activity icon

Awarded Best Reply on Redirect After Failed Login In Laravel 8?

Edit AuthenticatedSessionController::class store method

../app/Http/Controllers/Auth/AuthenticatedSessionController

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;

    public function store(LoginRequest $request)
    {
        //$request->authenticate();

        $request->ensureIsNotRateLimited();

        if (! Auth::attempt($request->only('email', 'password'), $request->filled('remember'))) {
            RateLimiter::hit($request->throttleKey());

            return redirect('/your_login_route')->withErrors(['email' => __('auth.failed')]);
        }

        RateLimiter::clear($request->throttleKey());

        $request->session()->regenerate();

        return redirect()->intended(RouteServiceProvider::HOME);
    }
Activity icon

Replied to Redirect After Failed Login In Laravel 8?

Edit AuthenticatedSessionController::class store method

../app/Http/Controllers/Auth/AuthenticatedSessionController

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;

    public function store(LoginRequest $request)
    {
        //$request->authenticate();

        $request->ensureIsNotRateLimited();

        if (! Auth::attempt($request->only('email', 'password'), $request->filled('remember'))) {
            RateLimiter::hit($request->throttleKey());

            return redirect('/your_login_route')->withErrors(['email' => __('auth.failed')]);
        }

        RateLimiter::clear($request->throttleKey());

        $request->session()->regenerate();

        return redirect()->intended(RouteServiceProvider::HOME);
    }
Activity icon

Replied to LEFT JOIN

I assume that you have these Models:

Artist.php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Artist extends Model
{
    public function artworks()
	{
		return $this->hasMany(Artwork::class);
	}
	
	public function artworkShares()
    {
        return $this->hasManyThrough(ArtworkShare::class, Artwork::class);
    }
}

Artwork.php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Artwork extends Model
{
    public function artist()
	{
		return $this->belongsTo(Artist::class);
	}
	
	public function artworkShares()
	{
		return $this->hasMany(ArtworkShare::class);
	}
}

ArtworkShare.php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ArtworkShare extends Model
{
    public function artwork()
	{
		return $this->belongsTo(Artwork::class);
	}
}

And then try this.

$artist = Artist::find(2);

$artworksOfArtist = $artist->artworks;
$artworkSharesOfArtist = $artist->artworkShares;
Activity icon

Replied to I Need To Get Related Table In Array Format By 'with', But Pluck Not Work

Add this to Article Model

//Eager Loading By Default
protected $with = ['categories'];

public function getCategoriesId()
{
	return $this->categories->pluck('article_category_id');
}

And then try this code:

$articles = Article::all();

$arrayOfCategoriesId = $articles->getCategoriesId();
Activity icon

Awarded Best Reply on View [layouts.guest] Not Found.

After installing Laravel Breeze package, you have to run these commands in order to use breeze.

php artisan breeze:install

npm install

npm run dev

php artisan migrate

After running these commands all your views, routes, controllers, and other resources will published to your application.

If you already run these commands but don't have view files.

  1. ../resources/views/layouts/app.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
        <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:[email protected];600;700&display=swap">

        <!-- Styles -->
        <link rel="stylesheet" href="{{ asset('css/app.css') }}">

        <!-- Scripts -->
        <script src="{{ asset('js/app.js') }}" defer></script>
    </head>
    <body class="font-sans antialiased">
        <div class="min-h-screen bg-gray-100">
            @include('layouts.navigation')

            <!-- Page Heading -->
            <header class="bg-white shadow">
                <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
                    {{ $header }}
                </div>
            </header>

            <!-- Page Content -->
            <main>
                {{ $slot }}
            </main>
        </div>
    </body>
</html>

  1. ../resources/views/layouts/guest.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
        <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:[email protected];600;700&display=swap">

        <!-- Styles -->
        <link rel="stylesheet" href="{{ asset('css/app.css') }}">

        <!-- Scripts -->
        <script src="{{ asset('js/app.js') }}" defer></script>
    </head>
    <body>
        <div class="font-sans text-gray-900 antialiased">
            {{ $slot }}
        </div>
    </body>
</html>
  1. ../resources/views/layouts/navigation.blade.php
<nav x-data="{ open: false }" class="bg-white border-b border-gray-100">
    <!-- Primary Navigation Menu -->
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex justify-between h-16">
            <div class="flex">
                <!-- Logo -->
                <div class="flex-shrink-0 flex items-center">
                    <a href="{{ route('dashboard') }}">
                        <x-application-logo class="block h-10 w-auto fill-current text-gray-600" />
                    </a>
                </div>

                <!-- Navigation Links -->
                <div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex">
                    <x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
                        {{ __('Dashboard') }}
                    </x-nav-link>
                </div>
            </div>

            <!-- Settings Dropdown -->
            <div class="hidden sm:flex sm:items-center sm:ml-6">
                <x-dropdown align="right" width="48">
                    <x-slot name="trigger">
                        <button class="flex items-center text-sm font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out">
                            <div>{{ Auth::user()->name }}</div>

                            <div class="ml-1">
                                <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                    <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                </svg>
                            </div>
                        </button>
                    </x-slot>

                    <x-slot name="content">
                        <!-- Authentication -->
                        <form method="POST" action="{{ route('logout') }}">
                            @csrf

                            <x-dropdown-link :href="route('logout')"
                                    onclick="event.preventDefault();
                                                this.closest('form').submit();">
                                {{ __('Log out') }}
                            </x-dropdown-link>
                        </form>
                    </x-slot>
                </x-dropdown>
            </div>

            <!-- Hamburger -->
            <div class="-mr-2 flex items-center sm:hidden">
                <button @click="open = ! open" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out">
                    <svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24">
                        <path :class="{'hidden': open, 'inline-flex': ! open }" class="inline-flex" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
                        <path :class="{'hidden': ! open, 'inline-flex': open }" class="hidden" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                    </svg>
                </button>
            </div>
        </div>
    </div>

    <!-- Responsive Navigation Menu -->
    <div :class="{'block': open, 'hidden': ! open}" class="hidden sm:hidden">
        <div class="pt-2 pb-3 space-y-1">
            <x-responsive-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
                {{ __('Dashboard') }}
            </x-responsive-nav-link>
        </div>

        <!-- Responsive Settings Options -->
        <div class="pt-4 pb-1 border-t border-gray-200">
            <div class="flex items-center px-4">
                <div class="flex-shrink-0">
                    <svg class="h-10 w-10 fill-current text-gray-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
                    </svg>
                </div>

                <div class="ml-3">
                    <div class="font-medium text-base text-gray-800">{{ Auth::user()->name }}</div>
                    <div class="font-medium text-sm text-gray-500">{{ Auth::user()->email }}</div>
                </div>
            </div>

            <div class="mt-3 space-y-1">
                <!-- Authentication -->
                <form method="POST" action="{{ route('logout') }}">
                    @csrf

                    <x-responsive-nav-link :href="route('logout')"
                            onclick="event.preventDefault();
                                        this.closest('form').submit();">
                        {{ __('Log out') }}
                    </x-responsive-nav-link>
                </form>
            </div>
        </div>
    </div>
</nav>

Activity icon

Replied to View [layouts.guest] Not Found.

Do you have GuestLayout.php component in your ../app/View/Components directory?

Activity icon

Replied to View [layouts.guest] Not Found.

After installing Laravel Breeze package, you have to run these commands in order to use breeze.

php artisan breeze:install

npm install

npm run dev

php artisan migrate

After running these commands all your views, routes, controllers, and other resources will published to your application.

If you already run these commands but don't have view files.

  1. ../resources/views/layouts/app.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
        <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:[email protected];600;700&display=swap">

        <!-- Styles -->
        <link rel="stylesheet" href="{{ asset('css/app.css') }}">

        <!-- Scripts -->
        <script src="{{ asset('js/app.js') }}" defer></script>
    </head>
    <body class="font-sans antialiased">
        <div class="min-h-screen bg-gray-100">
            @include('layouts.navigation')

            <!-- Page Heading -->
            <header class="bg-white shadow">
                <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
                    {{ $header }}
                </div>
            </header>

            <!-- Page Content -->
            <main>
                {{ $slot }}
            </main>
        </div>
    </body>
</html>

  1. ../resources/views/layouts/guest.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
        <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:[email protected];600;700&display=swap">

        <!-- Styles -->
        <link rel="stylesheet" href="{{ asset('css/app.css') }}">

        <!-- Scripts -->
        <script src="{{ asset('js/app.js') }}" defer></script>
    </head>
    <body>
        <div class="font-sans text-gray-900 antialiased">
            {{ $slot }}
        </div>
    </body>
</html>
  1. ../resources/views/layouts/navigation.blade.php
<nav x-data="{ open: false }" class="bg-white border-b border-gray-100">
    <!-- Primary Navigation Menu -->
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex justify-between h-16">
            <div class="flex">
                <!-- Logo -->
                <div class="flex-shrink-0 flex items-center">
                    <a href="{{ route('dashboard') }}">
                        <x-application-logo class="block h-10 w-auto fill-current text-gray-600" />
                    </a>
                </div>

                <!-- Navigation Links -->
                <div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex">
                    <x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
                        {{ __('Dashboard') }}
                    </x-nav-link>
                </div>
            </div>

            <!-- Settings Dropdown -->
            <div class="hidden sm:flex sm:items-center sm:ml-6">
                <x-dropdown align="right" width="48">
                    <x-slot name="trigger">
                        <button class="flex items-center text-sm font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out">
                            <div>{{ Auth::user()->name }}</div>

                            <div class="ml-1">
                                <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                    <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                </svg>
                            </div>
                        </button>
                    </x-slot>

                    <x-slot name="content">
                        <!-- Authentication -->
                        <form method="POST" action="{{ route('logout') }}">
                            @csrf

                            <x-dropdown-link :href="route('logout')"
                                    onclick="event.preventDefault();
                                                this.closest('form').submit();">
                                {{ __('Log out') }}
                            </x-dropdown-link>
                        </form>
                    </x-slot>
                </x-dropdown>
            </div>

            <!-- Hamburger -->
            <div class="-mr-2 flex items-center sm:hidden">
                <button @click="open = ! open" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out">
                    <svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24">
                        <path :class="{'hidden': open, 'inline-flex': ! open }" class="inline-flex" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
                        <path :class="{'hidden': ! open, 'inline-flex': open }" class="hidden" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                    </svg>
                </button>
            </div>
        </div>
    </div>

    <!-- Responsive Navigation Menu -->
    <div :class="{'block': open, 'hidden': ! open}" class="hidden sm:hidden">
        <div class="pt-2 pb-3 space-y-1">
            <x-responsive-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
                {{ __('Dashboard') }}
            </x-responsive-nav-link>
        </div>

        <!-- Responsive Settings Options -->
        <div class="pt-4 pb-1 border-t border-gray-200">
            <div class="flex items-center px-4">
                <div class="flex-shrink-0">
                    <svg class="h-10 w-10 fill-current text-gray-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
                    </svg>
                </div>

                <div class="ml-3">
                    <div class="font-medium text-base text-gray-800">{{ Auth::user()->name }}</div>
                    <div class="font-medium text-sm text-gray-500">{{ Auth::user()->email }}</div>
                </div>
            </div>

            <div class="mt-3 space-y-1">
                <!-- Authentication -->
                <form method="POST" action="{{ route('logout') }}">
                    @csrf

                    <x-responsive-nav-link :href="route('logout')"
                            onclick="event.preventDefault();
                                        this.closest('form').submit();">
                        {{ __('Log out') }}
                    </x-responsive-nav-link>
                </form>
            </div>
        </div>
    </div>
</nav>

Apr
07
1 week ago
Activity icon

Replied to Laravel With Sweetalert & Toast

If you want to show form request validation errors in sweet alert do these steps:

  1. Include sweet-alert style and script to your layout view.

https://cdn.jsdelivr.net/npm/sweetalert2@10.16.0/dist/sweetalert2.min.css https://cdn.jsdelivr.net/npm/sweetalert2@10.16.0/dist/sweetalert2.min.js

  1. Add these to your layout view.
@if (session()->has('success'))
    <script>
        swal.fire({
            title: "{{ __('Success!') }}",
            text: "{{ session('toast_success') }}",
            type: "success"
        });
    </script>
@endif

@if (session()->has('error'))
    <script>
        swal.fire({
            title: "{{ __('Error!') }}",
            text: "{{ session('toast_error') }}",
            type: "error"
        });
    </script>
@endif

@if ($errors->any())
    <script>
        swal.fire({
            title: "{{ __('Error in form request!') }}",
            text: "{{ implode(" ", $errors->all()) }}",
            type: "error"
        });
    </script>
@endif
Activity icon

Replied to Laravel 8 - How To Use Another Login Page For Custom Guard?

  1. Edit laravel source file located at this path:

root_of_your_project\vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php

// root_of_your_project\vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php

    /**
     * Handle an unauthenticated user.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  array  $guards
     * @return void
     *
     * @throws \Illuminate\Auth\AuthenticationException
     */
    protected function unauthenticated($request, array $guards)
    {
        throw new AuthenticationException(
            'Unauthenticated.', $guards, $this->redirectTo($request, $guards)
        );
    }

    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    protected function redirectTo($request, array $guards)
    {
        //
    }
  1. Edit Authenticate middlewre:
namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware
{
    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    protected function redirectTo($request, array $guards)
    {
        if (! $request->expectsJson()) {

            if (empty($guards)) {
                $guards = [null];
            }

            foreach ($guards as $guard) {
                if ($guard === 'web') {
                    return route('default.login');
                }

                if ($guard === 'account') {
                    return route('account.login');
                }
            }
        }
    }
}
Activity icon

Awarded Best Reply on Livewire: How To Get The Image Name?


public function store(){

	$action = '';

	$data = $this->validate([
		'profile' => 'image|max:1024',
		'last_name' => 'required',
		'first_name' => 'required',
		'middle_name' => 'required',
		'street' => 'required',
		'barangay' => 'required',
		'city' => 'required',
		'province' => 'required',
		'sketch' => 'image|max:1024',
		'birth_date' => 'required | date',
		'gender_id' => 'required',
		'civil_status_id' => 'required',
		'spouse' => 'required',
		'tel_no' => 'required',
		'cell_no_1' => 'required',
		'cell_no_2' => 'required',
		'employer' => 'required',
		'employer_address' => 'required',
		'employer_contact_no' => 'required'
	]);

    if(!empty($this->profile)){
		$filename = 'profile.' . time() . $this->profile->getClientOriginalExtension();

		$this->profile->storeAs('public/images', $filename);

		$data['profile'] = $filename;
	}

	if(!empty($this->sketch)){
		$filename = 'sketch.' . time() . $this->sketch->getClientOriginalExtension();

		$this->sketch->storeAs('public/images', $filename);

		$data['sketch'] = $filename;
	}

	if($this->customerId){
		Customer::find($this->customerId)->update($data);
		$action = 'edit';
	}else{
		Customer::create($data);
		$action = 'store';
	}

	$this->emit('showEmitedFlashMessage', $action);
	$this->resetInputFields();
	$this->emit('refreshParent');
	$this->emit('closeCustomerModal');

}
Apr
06
1 week ago
Activity icon

Replied to Get Single Role From User

I have expanded my reply.