samedi 3 octobre 2020

nuxt.js how upload image using laravel back end API

i am struck in image uploading help me i learned lots of things in nuxt.js but i am struck in image uploading.

how to make image uploading form in nuxt.js

i Created laravel API for image uploading.

my Router

Route::group(['middleware' => 'auth:api'], function() {
Route::post('/Employeeregister', 'EMPLOYEE_API\RegisterController@register')->name('Employeeregister');

}); 

CONTROLLER CODE

 public function imageUploadPost(Request $request)
    {
        $request->validate([
            'name' =>  'required | string',
            'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        ]);
  
        $imageName = time().'.'.$request->image->extension();  
   
        $request->image->move(public_path('images'), $imageName);
   
        return back()
            ->with('success','You have successfully upload image.')
            ->with('image',$imageName);
   
    }

MY Nuxt code

<template>
    <v-row justify="center">
        <v-col cols="12" sm="6">
            <form @submit.prevent="submit">
                <v-card ref="form" >
                    <v-card-text>
                        <h3 class="text-center">Register</h3>
                        <v-divider class="mt-3"></v-divider>
                        <v-col cols="12" sm="12">
                            <v-text-field v-model.trim="form.name" type="text" label="Full Name" solo autocomplete="off"></v-text-field>
                        </v-col>
                    </v-card-text>
                    <v-card-actions>
                        <v-spacer></v-spacer>
                        <div class="text-center">
                            <v-btn rounded type="submit" color="primary" dark>Register</v-btn>
                        </div>
                    </v-card-actions>
                </v-card>
            </form>
        </v-col>
    </v-row>
</template>
< script >
  export default {
    middleware: ['guest'],
    data() {
      return {
        form: {
          name: '',
        }
      }
    },
  } <
  /script>


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3cSx2xc
via IFTTT

vendredi 2 octobre 2020

Join table with its model's default scope in Laravel

Currently, we can join 2 tables like

ModelA::join('table_b', 'table_a.id', '=', 'table_b.a_id');

With this approach the default scopes on model for table_b (ie: ModelB) are not applied on query. Suppose the ModelB has SoftDeletes enabled now the above join won't include whereRaw('table_b.deleted_at IS NULL'). I know i can manualy add this using following code.

ModelA::join('table_b', function($join) {
    $join->('table_a.id', '=', 'table_b.a_id')->whereRaw('table_b.deleted_at IS NULL');
});

I want to know if there is any method to join so that it automatically apply default scope(s) in ModeB. Something like:

ModelA::joinModel(ModelB::Class, 'table_a.id', '=', 'table_b.a_id')


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2SipLxf
via IFTTT

Join tables in Laravel Eloquent method

How to write this code in eloquent method ?

$product = DB::table('products')
             ->join('purchase', 'products.id', '=', 'purchase.id')
             ->join('sales', 'purchase.id', '=', 'sales.id')
             ->select('sales.*', 'purchase.*','products.*')
             ->get(); 


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3jr1UXQ
via IFTTT

Laravel Websockets are unable to communicate with each other on aws ubuntu server?

I am using laravel websockets package as pusher replacement . First this ubuntu was not allowing to access the port ``6001``` then I add Inboud securoty group rule on aws . Now it is allowing to access the port but still not allowing to flow data thorug these porst and return this error.

pusher.min.js:8 WebSocket connection to 'ws://52.64.101.38:6001/app/ABCDEF?protocol=7&client=js&version=4.3.1&flash=false' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

I think I need to do more settings on aws but what I don't know.

It is also giving Authentication errors see screenshot enter image description here



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3jsUsMa
via IFTTT

Laravel - Configure storage in a different directory where is the project

I have a project located in this path /var/www/html/backend/api_cars

I have a storage configured to hang certain files in the "public" folder, but now I would need to upload files (for this I use dropzone js), with the particularity that when they are uploaded must be copied to a directory that is not within the project,

Its path is /var/www/html/images/catalog/cars

My question is how can I do it with laravel, I have tried to configure a "storage" of type "folder" but it gives me an error.

In the file config/filesystems.php I have created this

   'public' => [
    'driver' => 'images-cars',
    'root' => storage_path('/var/www/html/images/catalog/cars'),
    'url' => env('APP_URL').'/catalog-cars',
    'visibility' => 'public',
],

It had occurred o create a "Symbolic link" within a project folder to the other folder, but I don't know if it would work.

Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36EEAmf
via IFTTT

Laravel 7 Job queue handle method is not working

I am trying to execute a code after some delay using laravel 7 job queue. The constructor method is working but not the handle method. My code is given below:

Controller:

public function test()
{
    echo 'starting ....';
    $reset = (new ResetLockers())->delay(now()->addSeconds(10));
    dispatch($reset);
}

Job:

class ResetLockers implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    
    public function __construct()
    {
        echo 'constructing ...';
    }

    
    public function handle()
    {
        echo 'job dispatched';
    }
}

database:

enter image description here

output:

enter image description here

any clue?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3neOSPx
via IFTTT

How can I use or create a pagination in REST API in Laravel?

I would like to create a pagination in Rest API for Laravel. I want pagination like, Suppose I have total 30 categories in Database & I want to display 10 items in each page So total page will be 3 and 10 items will display in each page.

I have used paginate() method but it's only showing items by given number , I used below the script but it's not provided output that I mentioned.

$getCategories = Category::All();
$categories = DB::table('category')->paginate($pageNumber);

Does anybody tell me how could i use pagination in Rest Api?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Sj7lMT
via IFTTT