jeudi 11 février 2021

How to download files directly from amazone s3

This is my file uploading function

$file = $req->file('upload_file');
$name = $file->getClientOriginalName();
$fileName = time() . rand(1, 10000) . '_' . $name;
if($file )
{
$storage = \Storage::disk('s3')->put($fileName, file_get_contents($file), 'public');
}
if ($storage) {
$savePdf = Pdf_exports::create(
 [
   'pdf_name'      => $fileName,
 ]);
 }

Iam using jquery datatable to list the files and here below is my download link

 $('td:eq(6)', nRow).html('<div class="actionGrp"><a href="' + URL_general + '/dowlnoadPdf?id=' + aData.id + '" data-tooltip="tooltip" data-placement="top" title="Download"><span class="fa fa-download"></span></a></div>').addClass('txt-center');

I want a function to download the pdf directly when clicking the the download option.. Please help me..Iam less familiar with Amazone s3 bucket and file uploading



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

my popup not showing in upper side , i have tried many ways to do thid in laravel

enter image description here

this is my laravel blade code, I want to show the popup on the same page, it is showing also. But it is not clickable, and shows fade model can anyone suggest me to do another method, as I have tried other's method also. Thank you in advance.

@foreach($popup as $pop)
  <div class="popup col-md-3">
    <div class="contain">
      <img src="" alt="Avatar" class="image" style="width:100%">
      <div class="middle">
        <a class="btn btn-warning"  data-toggle="modal" data-target="#myModal">Preview</a>
      </div>
    </div>
    ">
      {!! $pop->website !!}
    </div>--}}
  </div>
  <div id="myModal" class="modal fade" role="dialog">
    <div class="modal-dialog">
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
@endforeach     


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

Getting data from checkbox into laravel controller

This seems so simple. But has me stumped... I have a table with some records and one cell has a bootstrap custom-switch input in it. The switches are rendering correctly. But i cannot get the array back into my controller.

Blade View

<form action="" method="POST">
    @csrf
    @method('PUT')
    <div class="custom-control custom-switch">
        <input  type="checkbox" 
                class="custom-control-input" 
                id="sitelive" 
                name="sitelive[]" 
                value="" 
                onchange="javascript:this.form.submit()" 
                @if($prop->sitelive == 1) checked @endif>
        <label class="custom-control-label" for="sitelive"></label>
    </div>
</form>

Controller

class AdminLiveOnSiteController extends Controller
{    
    public function update(Request $request, $id)
    {
        $prop = Properties::findorFail($id);    
        $validated = $request->validate(['sitelive' => 'required']);
        $prop->sitelive = $validated['sitelive'];        
        $prop->save();

        $request->session()->flash('alert-class', 'alert-success');
        $request->session()->flash('message', 'Live status updated!');

        return redirect()->route('Admin.Admin',  [ 'Property', 'All' ]);            
    }
}

Any ideas?



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

include navigate menu and footer are not working properly in Laravel

in my home blade I have following codes segments including _nav and _footer inside the content

@extends('layouts.app')

@section('content')
@include('partials._nav')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">Dashboard</div>

                <div class="card-body">
                    @if (session('status'))
                        <div class="alert alert-success" role="alert">
                            
                        </div>
                    @endif

                    You are logged in!
                </div>
            </div>
        </div>
    </div>
</div>
@include('partials._footer')
@endsection

I have following looks here Alt image

how could I make proper way to view the nav and footer here....



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

Hello guys...Error while setting foreign key constraints

Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table manage_db.sub_services (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table sub_services add constraint sub_services_id_foreign foreign key (id) references `service_lists

please find the migration table of sub_service

   Schema::create('sub_services', function (Blueprint $table) {
        
        $table->unsignedBigInteger('id');
        $table->foreign('id')->references('sub_service_id')->on('service_lists');

        $table->unsignedBigInteger('main_service_id');
        $table->foreign('main_service_id')->references('id')->on('main_services');
        
        $table->string('sub_service_name');
        $table->timestamps();


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

mercredi 10 février 2021

How to modify SQL string in PHP?

My code is this:

elseif ($criteria == 'doctoratedegree')
    $query->where('postgradcourses', 'LIKE', '%' . $searchItem . '%');

So basically in the front end, a person will select "Doctorate degree" in the form drop down menu, then type the course they want to search for and the code will look for the course in the postgradcourses column of the courses database table. problem is, the Masters degree option in the menu is coded in the same way where the code will also look in the postgradcourses column.

How can I modify the query code so that it searches for: PhD in . $searchItem . ?

Basically, the code will add a specific string along with whatever the person searched for.



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

Too few arguments laravel

I'm trying to do my own method of registration (in my project only admins can registrate). So i did UserController and registration function:

public function registration(array $data)
    {
        
          if ($data['submit']) {
                  $user=new User;
                  $user->name=$data['name'];
                  $user->surname=$data['surname'];
                  $user->email=$data['email'];
                  $user->password=Hash::make($data['password']);
                  $user->save();
                  
    }

        return view('registration');
    }

but i'm getting error:

Too few arguments to function App\Http\Controllers\UserController::registration(), 0 passed in C:\OpenServer\domains\projecticable\vendor\laravel\framework\src\Illuminate\Routing\Controller.php on line 54 and exactly 1 expected

And it alludes to public function registration(array $data)

There is no problems with view and route(it shows without registration function).



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