Neeraj1005

Member Since 1 Year Ago

Experience Points
34,530
Total
Experience

470 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
150
Lessons
Completed
Best Reply Awards
2
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 7
34,530 XP
Jan
27
19 hours ago
Activity icon

Awarded Best Reply on Sync() Add Additional Column Value In Pivot Table

Solved

$task->assignTo()->sync([
            $this->assign_to => [
                'status_id' => 1,
            ],
        ]);
Activity icon

Replied to Sync() Add Additional Column Value In Pivot Table

Solved

$task->assignTo()->sync([
            $this->assign_to => [
                'status_id' => 1,
            ],
        ]);
Activity icon

Started a new Conversation Sync() Add Additional Column Value In Pivot Table

In my project I have User,Task,Status model. and I have pivot table which stores task_id, user_id, status_id. Then problem is now if I sync or store the value status_id is not stored can anyone tells me how to store 3rd value in pivot table.

// IN Task Model I have relationship like
    public function assignTo()
    {
        return $this->belongsToMany(User::class,'task_user','task_id','user_id');
    }

code

    $task = auth()->user()->tasks()->create([
            'name' => $this->title,
            'message' => $this->message,
            'department_id' => $this->department_id,
            'deadline_id' => $this->deadline_id,
        ]);

        $task->assignTo()->sync([
            'user_id' => $this->assign_to,
            'status_id' => 1,
            'created_at' => now(),
        ]);
Jan
26
1 day ago
Activity icon

Replied to Retrieve An Input Form The Query String

do you want to get 50 items ? then do this

$todos = $this->user->todos()->take(50)->get(['id', 'title', 'body', 'completed', 'created_by']);
OR
$todos = $this->user->todos()->paginate(50);

return response()->json($todos->toArray());

If you are creating an API user Laravel API https://laravel.com/docs/8.x/eloquent-resources#resource-collections technique

Activity icon

Replied to Department, User, Task Assign

okk I'll try this...

Activity icon

Replied to JQuery Reset Selected Option

@www888 Then why you tried this for ajax...? just use simple jquery...for dom changes..

Activity icon

Replied to BelongsToMany With UpdateOrCreate

@eddieace check this link you will get why every time new database record is created... https://stackoverflow.com/a/42696141/8455396

Activity icon

Replied to Department, User, Task Assign

@nimrod Yes for future reference task would be assigned to multiple users... So I have to create another intermediate table now...?

Activity icon

Replied to JQuery Reset Selected Option

so you want to create 3rd level descendent dropdown level..?

Activity icon

Replied to JQuery Reset Selected Option

@www888 what are trying actually...? however, if you change the selectA then there below children selected attribute will be reset..?

Activity icon

Started a new Conversation Department, User, Task Assign

In my project I stuck with some table relationship. Hope anyone can solve my problem to resolve schema relationship between tables...

Basic steps... First Admin login Second He will create a department Third, add users with assign department

Now I'm stucking in fourth point: Fourth, Then after creating user with department He will goes for Creating Task where he create the task. But my questing if user hasMany Tasks then how he would be assign the task?

should I have to create intermediate table assign_task like that because in tasks table there is already a user_id column

tasks table

id
task_name
task_message
slug
department_id
user_id  //this would be user id => created by

How can I implement assign to 
should I have to add another column for assign_id like that and what would be the relationship..Or either should go for another new intermediate table?
Activity icon

Replied to Bootstrap5 ERROR In ./node_modules/bootstrap/dist/js/bootstrap.esm.js 6:0-41

@sami.chkeir @devingray_ I solved this issue few days ago... sorry to check this late...

https://popper.js.org/ I run this command and my error solved

npm i @popperjs/core
Jan
23
4 days ago
Activity icon

Started a new Conversation Bootstrap5 ERROR In ./node_modules/bootstrap/dist/js/bootstrap.esm.js 6:0-41

ERROR in ./node_modules/bootstrap/dist/js/bootstrap.esm.js 6:0-41
Module not found: Error: Can't resolve '@popperjs/core' in 'C:\laragon\www\tasky\node_modules\bootstrap\dist\js'

webpack compiled with 1 error
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `mix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Nick\AppData\Roaming\npm-cache\_logs21-01-23T14_13_45_627Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Nick\AppData\Roaming\npm-cache\_logs21-01-23T14_13_45_776Z-debug.log

I installed fresh laravel project with laravel/ui package. And I installed new bootstrap5 for this project but when I tried to run npm run dev command this send the error. can anyone know how to install bootsrap 5 in laravel 8?

Jan
15
1 week ago
Activity icon

Awarded Best Reply on How Do You Pass Data To A Partial?

@vusumzi Like this In laravel there is no command for viewComposer so you have to manually create viewComposerFile inside App\Http\View\Composers\YourFileNameComposer

Then paste these code inside your composer file

<?php

namespace App\Http\View\Composers;

use Illuminate\View\View;

class YourFileNameComposer
{
    public function __construct()
    {
    }

    /**
     * Bind data to the view.
     *
     * @param  View  $view
     * @return void
     */
    public function compose(View $view)
    {
        $view->with(
            'notifications', auth()->user()->unreadNotifications,
        );
   	$view->with(
            'unread',auth()->user()->unreadNotifications->count(),
        );
    }
}

Then after Register it into AppServiceProvider like this

 View::composer(
            ['partials._topbar'], 'App\Http\View\Composers\YourFileNameComposer',
        );
Activity icon

Replied to How Do You Pass Data To A Partial?

@vusumzi Like this In laravel there is no command for viewComposer so you have to manually create viewComposerFile inside App\Http\View\Composers\YourFileNameComposer

Then paste these code inside your composer file

<?php

namespace App\Http\View\Composers;

use Illuminate\View\View;

class YourFileNameComposer
{
    public function __construct()
    {
    }

    /**
     * Bind data to the view.
     *
     * @param  View  $view
     * @return void
     */
    public function compose(View $view)
    {
        $view->with(
            'notifications', auth()->user()->unreadNotifications,
        );
   	$view->with(
            'unread',auth()->user()->unreadNotifications->count(),
        );
    }
}

Then after Register it into AppServiceProvider like this

 View::composer(
            ['partials._topbar'], 'App\Http\View\Composers\YourFileNameComposer',
        );
Activity icon

Replied to How Do You Pass Data To A Partial?

@vusumzi you did wrong...

  • First create view composer
  • then write condition under view composer
  • register view composer file inside AppServiceProvider.
Activity icon

Replied to Am I Writing Laravel The Right Way !

it is easy and useful...instead of writing sql queries... eloquent is too much user friendly to write query..... just read the docs and watch tutorial...there are plenty free video course on laravel...just watch...

Activity icon

Replied to Bootstrap4 Datetimepicker

there are several library for this you can checkout these

these two i mostly used...

Activity icon

Replied to How Do You Pass Data To A Partial?

@vusumzi there is two way you can pass data to your partials:

  • using view composer
  • using blade component technique

read on laravel docs...you will get this idea.

Jan
07
2 weeks ago
Activity icon

Started a new Conversation Create:893 Livewire: The Published Livewire Assets Are Out Of Date See: Https://laravel-livewire.com/docs/installation/

I don't know why a few days ago my project with livewire was working good...But now today suddenly it won't work. It return some error in console.

create:893 Livewire: The published Livewire assets are out of date
 See: https://laravel-livewire.com/docs/installation/

Uncaught TypeError: window.livewire.devTools is not a function
    at create:902

can anyone tells me what was the exact problem

Activity icon

Started a new Conversation Spatie/laravel-ray 1.0.0 Requires Spatie/ray Dev-master -> Satisfiable By Spatie/ray[dev-master].

In my laravel app I'm trying to install https://spatie.be/docs/ray/v1/getting-started/installation-in-laravel ray. But after running the command in terminal it throw me some error. can anyone tells me how to solve this...?

λ composer require spatie/laravel-ray --dev
Using version ^1.0 for spatie/laravel-ray
./composer.json has been updated
Running composer update spatie/laravel-ray
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - spatie/laravel-ray 1.0.0 requires spatie/ray dev-master -> satisfiable by spatie/ray[dev-master].
    - spatie/laravel-ray 1.0.1 requires spatie/ray ^1.0 -> satisfiable by spatie/ray[1.0.0, 1.0.1].
    - spatie/ray[dev-master, 1.0.0, ..., 1.0.1] require symfony/console ^4.2|^5.2 -> found symfony/console[v4.2.0-BETA1, ..., 4.4.x-dev, v5.2.0-BETA1, ..., 5.x-dev] but the package is fixed to v5.1.8 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - Root composer.json requires spatie/laravel-ray ^1.0 -> satisfiable by spatie/laravel-ray[1.0.0, 1.0.1].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Did anyone try to install and runs the command spatie/ray. And my Operating system is windows

Activity icon

Replied to Pagination With Search Filter

@usamafiaz Can you show your controller method what query you have executed..?

In your controller if you have query like this

$users = User::search(request('search_input'))->paginate(15);

then appendwithQueryString() after paginate.

$users = User::search(request('search_input'))->paginate(15)->withQueryString();
Activity icon

Replied to How To Pass Id For Update In Laravel

@mrperfectionist Try this technique

const id = $("#ID").val();
const route= "{{ route('admin.department.update')}}";

const updateUrl= route+id;

$.ajax({
   url: updateUrl
});

Or instead of route you can use url: 'your_url'+ id

Jan
05
3 weeks ago
Activity icon

Started a new Conversation Preg_match(): Delimiter Must Not Be Alphanumeric Or Backslash (View: C:\laragon\www\crm\resources\views\rfq\lists-rfq.blade.php)

In my project I have file upload system with file and image support... In front page I want to perform a query if user has upload an image then image show other wise not show document... So I make a function in model it throw some errro can anyone tell what i did wrong

  protected $fillable = [
        'imageable_id',
        'imageable_type',
        'file_name',
        'mime_type',
        'file_path',
    ];

public function fileType()
    {
        $value = preg_match('image/',$this->mime_type);
        if ($value) {
            return true;
        }
    }
Activity icon

Replied to File(docx,pdf) And Image(jpeg,png Etc..) Support Validation Laravel

@snapey should I have to remove image?

'images.*' => 'mimes:jpg,bmp,png,pdf,docx|max:1024'

like this => it is correct way..?

Activity icon

Started a new Conversation File(docx,pdf) And Image(jpeg,png Etc..) Support Validation Laravel

In my form I have a file upload tag....but I want to both type of file upload support such as user can upload pdf,docx,image aswell. Can anyone tell me what validation I have to make...?

This is my validation

$validatedData = $this->validate([
            'product_name' => 'required',
            'images.*' => 'image|max:1024',
        ]);
Activity icon

Replied to How To Add Multiple Foreign Key In Migration File

@aasifkhan is your states/doctors/countries id does contains unsignedInteger type?....check their id types.... and try to use unsignedInteger

$table->unsignedInteger('state_id', 255)->nullable();

Jan
04
3 weeks ago
Activity icon

Started a new Conversation Bootstrap Modal Descendent Dropdown Not Working

In my project, For storing data I’m using the bootstrap modal. But the problem I faced In my modal that is the descendent dropdown is not working. If I used this wire: ignore method if I removed this wire: ignore method then the modal hides. Can anyone tell me how can I render the dynamic data while using the wire:ignore method. This is my LIvewire component methods

<?php

namespace App\Http\Livewire\Poi;

use App\Poi as AppPoi;
use Livewire\Component;
use App\Tbl_productcategory;
use App\Tbl_product_subcategory;

class Poi extends Component
{
    public $product_name;
    public $user_id;
    public $product_category_id;
    public $sub_category_id;
    public $isActive;
    
    public $subcategories = [];

    public function store()
    {
        $validatedData = $this->validate([
            'product_name' => 'required',
            'product_category_id' => 'required',
            'sub_category_id' => 'required',
        ]);

        $validatedData['user_id'] = auth()->user()->id;

        AppPoi::create($validatedData);

        session()->flash('message', 'Row data successfully created.');

        $this->reset();

    }

    public function render()
    {
        try {
            if (!empty($this->product_category_id)) {
                $this->subcategories = Tbl_product_subcategory::where('procat_id', $this->product_category_id)->get();
            }
            return view('livewire.poi.poi')->with([
                'product_of_interests' => AppPoi::get(),
                'categories' => Tbl_productcategory::has('tbl_product_subcategory')->get(),
            ]);
        } catch (\Throwable $th) {
            dd('catch exception', $th->getMessage());
        }
    }
}

This is my blade component

<div wire:ignore>
    <!-- Modal -->
    <div class="modal fade" id="poiModal" tabindex="-1" aria-labelledby="poiModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="poiModalLabel">Add New</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <form wire:submit.prevent="store">
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="product_name">Product Name</label>
                            <input wire:model="product_name" type="text" class="form-control" id="product_name" placeholder="eg: shoes">
                        </div>
                        <div class="form-group">
                            <label for="product_category_id">Category</label>
                            <select class="form-control required"
                                wire:model="product_category_id" name="product_category_id" id="product_category_id">
                                <option value="0">Select Category</option>
                                @foreach($categories as $cat)
                                    <option value="{{ $cat->procat_id }}">{{ $cat->category }}</option>
                                @endforeach
                            </select>
                        </div>
        
                        <div class="form-group">
                            <label for="sub_category_id">SubCategory</label>
                            <select class="form-control required"
                                wire:model="sub_category_id" name="sub_category_id" id="sub_category_id">
                                <option value="">select subcategory</option>
                                @foreach($subcategories as $subcat)
                                    <option value="{{ $subcat->prosubcat_id }}">{{ $subcat->category }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary">Save changes</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
Jan
02
3 weeks ago
Activity icon

Replied to Call To Undefined Method Illuminate\Database\Eloquent\Relations\MorphMany::attach()

@tisuchi basically I tried the attached for rfqs and images oneToMany relationship table. And user_id is used in rfqs table.

Activity icon

Replied to BelongsToMany Take 1 .

@binggle your relationship is wrong...make proper relationship...as @tisuchi said.

  • cat Model hasMany videos
  • videos Model belongsToMany cats
Activity icon

Replied to Call To Undefined Method Illuminate\Database\Eloquent\Relations\MorphMany::attach()

@tray2 Ohh! so attach used in only manyTomany case...? Instead of save can I use create also?

Activity icon

Started a new Conversation Call To Undefined Method Illuminate\Database\Eloquent\Relations\MorphMany::attach()

In my laravel project I'm trying to add mulitple image for RFQ table...can anyone tell me what i did wrong. My relationship like: rfq hasMany images AND images belongsTo rfqs This is my livewire method

public function store()
    {
        $validatedData = $this->validate([
            'product_name' => 'required',
            'product_category_id' => 'required|not_in:0',
            'sub_category_id' => 'required|not_in:0',
            'product_quantity' => 'required',
            'unit_id' => 'required|not_in:0',
            'purchase_price' => 'nullable',
            'city' => 'required|',
            'isChecked' => 'required|accepted',
            'details' => 'required|string|min:1|max:500',
            'images.*' => 'image|max:1024',
        ]) + [
            'user_id' => auth()->user()->id,
        ];

        $rfqData = Rfq::create($validatedData);

        // if ($this->images) 
        // {
            foreach ($this->images as $photo) {
                $path_url = $photo->storePublicly('rfqs', 'public');

                $rfqData->images()->attach($photo,[
                    'file_name' => $photo->getClientOriginalName(),
                    'file_path' => $path_url,
                ]);
            }
        // }


        session()->flash('message', 'RFQ submitted successfully.');

        $this->reset();
    }
Dec
31
3 weeks ago
Activity icon

Replied to SQLSTATE[HY000]: General Error: 1366 Incorrect Integer Value: 'on' For Column 'isChecked' At Row 1 (SQL: Insert Into `rfqs` (`product_name`, `product_category_id`, `sub_category_id`, `product_quantity`, `unit_id`, `city`, `isChecked`, `details`, `user_id`

@tisuchi okk I tried it letter but I solve this problem using this conditional statements.

     $validatedData = $request->validate([
            'product_name' => 'required',
            'product_category_id' => 'required',
            'sub_category_id' => 'required',
            'product_quantity' => 'required',
            'unit_id' => 'required|not_in:0',
            'purchase_price' => 'nullable',
            'city' => 'required|',
            'isChecked' => 'required|accepted',
            'details' => 'nullable',
        ])+[
            'user_id' => auth()->user()->id,
        ];

        if (request('isChecked') === 'on') {
            $validatedData['isChecked'] = true;
        }
Activity icon

Started a new Conversation SQLSTATE[HY000]: General Error: 1366 Incorrect Integer Value: 'on' For Column 'isChecked' At Row 1 (SQL: Insert Into `rfqs` (`product_name`, `product_category_id`, `sub_category_id`, `product_quantity`, `unit_id`, `city`, `isChecked`, `details`, `user_id`

SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'on' for column 'isChecked' at row 1 (SQL: insert into `rfqs` (`product_name`, `product_category_id`, `sub_category_id`, `product_quantity`, `unit_id`, `city`, `isChecked`, `details`, `user_id`, `updated_at`, `created_at`) values (Watch, 1, 1, 1, 1, Delhi, on, ?, 37, 2020-12-31 11:10:16, 2020-12-31 11:10:16))

Basically this return error for checkbox. In my table isCheckedcolumn is boolean. And I try dd() it return on for isChecked value. Can anyone tells me how return true/false for isChecked? Controller Method

    public function store(Request $request)
    {
        $validatedData = $request->validate([
            'product_name' => 'required',
            'product_category_id' => 'required',
            'sub_category_id' => 'required',
            'product_quantity' => 'required',
            'unit_id' => 'required|not_in:0',
            'city' => 'required|',
            'isChecked' => 'required|accepted',
        ])+[
            'details' => $request->details,
            'user_id' => auth()->user()->id,
        ];

        Rfq::create($validatedData);

        return redirect()->withMessage('RFQ submitted successfully.');
    }
Activity icon

Replied to How To Add Middleware Auth Condition For Submit Form In Livewire Component

@tray2 ok..but I put the login route then how can I redirect back at the same form...? Because I did try this but it return to me a dashboard page... Should I have to chage redirectRoute...?

Activity icon

Started a new Conversation How To Add Middleware Auth Condition For Submit Form In Livewire Component

In my Laravel project render the livewire component for submiting the form. What I need? Basically the form is public but I want a auth condition means if user submit the form without logged in then the login page appear. Can anyone tells me how to use $this->middleware('auth')in livewire component becasue it redirect the error. This is my component

<?php

namespace App\Http\Livewire\Rfq;

use App\Rfq;
use App\City;
use App\currency;
use App\Tbl_units;
use Livewire\Component;
use App\Tbl_productcategory;
use App\Tbl_product_subcategory;

class RfqForm extends Component
{
    public $product_name;
    public $product_quantity;
    public $unit_id;
    public $currency_id;
    public $purchase_price;
    public $city;
    public $details;
    public $isChecked;

    public $product_category_id;
    public $subcategories = [];
    public $sub_category_id;

    public function updated()
    {
        $this->validate([
            'product_name' => 'required',
            'product_category_id' => 'required',
            'sub_category_id' => 'required',
            'product_quantity' => 'required',
            'unit_id' => 'required|not_in:0',
            'purchase_price' => 'required',
            'city' => 'required|',
            'isChecked' => 'required|accepted',
        ]);
    }

    public function store()
    {
        $validatedData = $this->validate([
            'product_name' => 'required',
            'product_category_id' => 'required',
            'sub_category_id' => 'required',
            'product_quantity' => 'required',
            'unit_id' => 'required|not_in:0',
            'purchase_price' => 'required',
            'city' => 'required|',
            'isChecked' => 'required|accepted',
        ]);

        $validatedData['details'] = $this->details;

        // Rfq::create($validatedData);
        auth()->user()->rfqs()->create($validatedData);
        
        session()->flash('message', 'RFQ submitted successfully.');
        
        $this->reset();
    }

    public function render()
    {
        if(!empty($this->product_category_id)) {
            $this->subcategories = Tbl_product_subcategory::where('procat_id', $this->product_category_id)->get();
        }

        return view('livewire.rfq.rfq-form')->with([
            'categories' => Tbl_productcategory::has('tbl_product_subcategory')->get(),
        ]);
    }
}

Dec
30
4 weeks ago
Activity icon

Replied to Tailwind Dropdown Doesn't Work

@neomuckel which javascript are using...? You have to write javascript for dropdown if you're using tailwind... In this case I suggest use alpine js for simple dropdown..it is easy

Activity icon

Awarded Best Reply on The Requested URL /vendor/livewire/livewire.js Was Not Found On This Server.

Now I have solved this issue by changing the asset_url in the livewire.config file

  • first run php artisan vendor:publish
  • then select livewire config file
  • After that open file and edit asset_url null to your filename
'asset_url'  => 'MY_PROJECT_NAME',
Dec
29
4 weeks ago
Activity icon

Replied to The Requested URL /vendor/livewire/livewire.js Was Not Found On This Server.

Now I have solved this issue by changing the asset_url in the livewire.config file

  • first run php artisan vendor:publish
  • then select livewire config file
  • After that open file and edit asset_url null to your filename
'asset_url'  => 'MY_PROJECT_NAME',
Activity icon

Started a new Conversation The Requested URL /vendor/livewire/livewire.js Was Not Found On This Server.

In my project I have laravel livewire I don't know why this error encounter..

in console it returns this error.

create:77 Uncaught ReferenceError: Livewire is not defined

can anyone tells me what I did wrong the problem

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="dns-prefetch" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet" type="text/css">


    @livewireStyles

</head>

<body>
    <main class="py-4">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-md-8">
                    <livewire:counter />
                </div>
            </div>
    </main>

    @livewireScripts
</body>

</html>

Dec
28
4 weeks ago
Activity icon

Replied to How To Validate Image In Edit Form If There Is No Image Is Selected

no need of two request classes he can also perform with single class aswell

Activity icon

Replied to How To Validate Image In Edit Form If There Is No Image Is Selected

@coder72 you can do something like this

'image' => ($this->getMethod() == 'POST')
                    ? 'required'
                    : '',

and in your database table image column should be nullable

Activity icon

Replied to Livewire Image Upload Without Form And Click Button

Still waiting for some response :(

Dec
26
1 month ago
Activity icon

Replied to Livewire Image Upload Without Form And Click Button

@loyd If I use wire:change then how it would read the photos modal...?

Activity icon

Replied to Livewire Image Upload Without Form And Click Button

@bugsysha yes you're right but I want to apply these type of condition do you have any idea how to implement those?

Activity icon

Replied to Upload Multiple Images Laravel & Dropzone

@vironeer I prefer use laravel livewire it is easy to use for file uploading...

Activity icon

Started a new Conversation Livewire Image Upload Without Form And Click Button

In my project, I have done image upload using form submit but now I want some advanced technique like If I select an image it automatically uploaded. can anyone tells me what should I have to do... These are my method have a look at them, please.

<?php

namespace App\Http\Livewire;

use App\Gallary;
use Livewire\Component;
use Livewire\WithFileUploads;

class AddMedia extends Component
{
    use WithFileUploads;

    public $gallaries;
    
    public $photos = [];

    public $perPage = 10;

    protected $listeners = [
        'mediaLoad' => 'scrollMore',
        'uploadImage' => 'save',
    ];


    public function updatedPhotos()
    {
        $this->validate([
            'photos.*' => 'required|image|max:1024', // 1MB Max
        ]);
    }

    public function save()
    {
        $this->validate([
            'photos.*' => 'required|image|max:1024', // 1MB Max
        ]);

        if ($this->photos) {
            foreach ($this->photos as $photo) {
                // $file_extension = $photo->extension();
                $path_url = $photo->storePublicly('gallary','public');
    
                Gallary::create([
                    'name' =>$photo->getClientOriginalName(),
                    'file_name' => $photo->getClientOriginalName(),
                    'file_photo_url' => $path_url,
                    'mime_type' => $photo->getMimeType(),
                    'size' => $photo->getSize(),
                ]);
            }
        }
        session()->flash('message', 'File Uploaded Successfully');

        $this->reset();

    }

    public function scrollMore()
    {
        $this->perPage = $this->perPage + 6;
    }

    public function render()
    {
        try {
            $this->gallaries = Gallary::latest()->take($this->perPage)->get();
        } catch (\Throwable $th) {
            //throw $th;
        }
        return view('livewire.add-media');
    }
}

and this is my blade component

   <div class="tab-pane fade" id="pills-profile" role="tabpanel"
                            aria-labelledby="pills-profile-tab" x-data="{ isUploading: false, progress: 0 }"
                            x-on:livewire-upload-start="isUploading = true"
                            x-on:livewire-upload-finish="isUploading = false"
                            x-on:livewire-upload-error="isUploading = false"
                            x-on:livewire-upload-progress="progress = $event.detail.progress">
                            {{-- <form wire:submit.prevent="save" enctype="multipart/form-data"> --}}
                            <form enctype="multipart/form-data">
                                <input wire:model="photos" type="file" name="mediaupload" id="mediaupload" id="file-{{ $iteration }}"
                                multiple>
                                @error('photos.*')
                                    <span class="text-danger">{{ $message }}</span>
                                @enderror
                                <!-- Progress Bar -->
                                <div x-show="isUploading">
                                    <progress max="100" x-bind:value="progress"></progress>
                                </div>
                                {{-- <button wire:loading.attr="disabled" type="submit"
                                    class="btn btn-sm btn-outline-primary"
                                    {{ ($photos) ? '' : 'disabled' }}>Upload</button> --}}
                            </form>
                        </div>