hashing image with watermark in laravel - laravel

i use in my project image package Intervention-Image
to add watermark to every uploaded image in serve i use code blow but have error in hashing
hashing give me the hash of watermark.png only every time
Route::post('/upload_image',function (Request $request)
{
$real_path = Image::make($request->file('image')->getRealPath());
$img_for_hash = Image::make($real_path);
$img = Image::make($real_path);
// calculate md5 hash of encoded image
$hash = md5($img_for_hash->__toString());
// use hash as a name
$path = "images/{$hash }.jpg";
$watermark = Image::make(public_path('watermark.png'));
$img->insert($watermark, 'bottom-right', 10, 10);
// save it locally to ~/public/images/{$hash}.jpg
$img->save(public_path($path));
return $hash ;
})->name('upload_image');
view
<!DOCTYPE html>
<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">
<title>Upload Image</title>
</head>
<body>
<form action="{{ route('upload_image') }}" method="post" enctype="multipart/form-data" >
#csrf
<input type="file" name="image">
<button type="submit"> upload </button>
</form>
</body>
</html>
are any solution use call back or this because watermark ?? i don't know why this code give me same hash every time .

Related

How to use Stripe Element Into Laravel Blade

I have a Laravel project. I want to add Stripe payment system in my Laravel app. In stripe there is js Element but unfortunately I cannot use it in blade files. Can anyody help me suggest other way to do this?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stripe Payment</title>
</head>
<body>
<!-- Mount the instance within a <label> -->
<label>Card
<div id="card-element"></div>
</label>
<!--
Or create a <label> with a 'for' attribute,
referencing the ID of your container.
-->
<label for="card-element">Card</label>
<div id="card-element"></div>
<script src="https://js.stripe.com/v3/"></script>
<script>
var stripe = Stripe('pk_test_....');
const elements = stripe.elements();
const cardElement = elements.create("payment", {"clientSecret": "sk_test_...."});
cardElement.mount('#card-element');
</script>
</body>
</html>

Ckeditor is not functioning properly?

Question
How come my ckeditor is not functioning?
Error
"Uncaught TypeError: Cannot read property 'options' of undefined"
https://prnt.sc/ttqdm8
Version
ckeditor_4.14.1_full
File Structure
https://prnt.sc/ttqg7w
Code
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex, nofollow">
<title>File Manager Integration</title>
<script src="./plugin/ckeditor/ckeditor.js" type="text/javascript"></script>
</head>
<body>
<textarea cols="10" id="editor1" name="editor1" rows="10" data-sample-short><p>This is some <strong>sample text</strong>. You are using <a href="https://ckeditor.com/">CKEditor</a>.</p></textarea>
<script>
// CKEDITOR.replace('editor1');
CKEDITOR.replace('editor1', {
height: 300,
filebrowserBrowseUrl: './plugin/ckfinder/ckfinder.html',
filebrowserImageBrowseUrl: './plugin/ckfinder/ckfinder.html?type=Images',
filebrowserUploadUrl: './plugin/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
filebrowserImageUploadUrl: './plugin/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images'
});
</script>
</body>
</html>
I found the solutions. The problem is caused by the folder name. Directly change the folder name from
D:\xampp\htdocs\testingProject\copypasteeditor --> D:\xampp\htdocs\testingproject\copypasteeditor
Change testingProject to testingproject.

Can not seem to successfully pass through a variable through to a laravel Route

I am a complete newb trying to teach myself the laravel framework. I have a little PHP experience from a past life and am just trying to learn a new skill set. I am def not a developer by trade.
I am trying to complete a tutorial on routes.
In my web.php file I have this
Route::get('/test/{post}', function($post) {
$posts = [
'my-first-post' => 'Hello, this is my first blog post!',
'my-second-post' => 'Now I am getting the hang of this blogging thing',
'test' => 'test'
];
if (! array_key_exists($post, $posts)) {
abort(404, 'Sorry, that post was not found');
}
return view('post', [
'post' => $posts[$post]
]);
});
In my blade file I have this
<!DOCTYPE HTML>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
This is a test
</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title m-b-md">
this is a test
{{$post}}
</div>
</div>
</div>
</body>
</html>
When I refresh the page with the following URL http://127.0.0.1:8000/test/test
I get the following error
InvalidArgumentException
View [post] not found.
Am i doing something silly?
Through the exception it seems that the view 'post' does not exist.
Please make sure that post.blade.php exists in project_root/resources/views/post.blade.php
For further details please refer to this link:
https://laravel.com/docs/7.x/views#creating-views

i have used laravel blade template make layout but doent work

Template:
<!DOCTYPE html>
<html>
<head>
<title>App Name #yield('title')</title>
</head>
<body>
#section('content')
</div>
</body>
</html>
View:
#section('content')
#if(session('message'))
<p>{{session('message')}}</p>
#endif
#foreach ($posts as $post)
<h2> {{$post->title}}</h2>
<p>{{$post->body}}</p>
Edit
Delete
#endforeach
#endsection
I have used this code and get white screen how to solve this problem
make layout folder and layout file get only white screen no any error and output
MASTE PAGE:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta name="csrf-token" content="{{csrf_token()}}">
#yield('metas')
#yield('head')
#yield('style')
</head>
<title>#yield('title')</title>
<body class="skin-blue sidebar-mini">
#yield('body')
</body>
<footer>
#yield('footer')
#yield('script_whole')
</footer>
</html>
CHILD PAGES:
#extends('path.to.master_page')
#section('head')
//head elemetns here
#endsection
#section('style')
//style here
#endsection
#section('title', 'my_title')
#section('content')
//content elemetns here
#endsection
#section('footer')
//footer elemetns here
#endsection
#section('script_whole')
//scripts here
#endsection
and now every page that extends from MASTER_page, so should use #section
Instead of using
#section('content');
in main blade file use
#yield('content');

Laravel Dompdf taking too long to download pdf

I want to make a pdf invoice from blade template using Dompdf in Laravel 5.5.
The problem is when clicking on the download button the page is loading and after ~3 min i the pdf starts downloading.
Why is it taking so long?
the download link
<i class="fa fa-file-pdf-o"></i> Download Invoice
web route:
Route::get('/order/download-invoice/{OrderID}', 'Admin\AdminOrderController#downloadOrderInvoice')->name('admin.download-invoice');
a simple template (invoice.blade.php)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other
head content must come *after* these tags -->
<title>Invoice</title>
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}" media="screen">
</head>
<body>
<div>{{ $invoice->InvoiceTitle }} </div>
</body>
</html>
donwload invoice controller function:
use Barryvdh\DomPDF\Facade as PDF;
public function downloadOrderInvoice($OrderID){
$invoice = Invoice::where('OrderID', $OrderID)->first();
$pdf = PDF::loadView('invoice.invoice', compact('invoice'))->setPaper('a4', 'landscape');
return $pdf->download('invoice.pdf');
}
What i did wrong? Did i miss something?
UPDATE
clear the header and using EXTERNAL CDN bootstrap works.
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
Why is not using the local bootstrap using asset???
<link href="{{asset('css/bootstrap.min.css')}}" rel="stylesheet">

Resources