MJML converts links in email clients to mjt.lu - laravel

Laravel-mix-mjml plugin converts href links. All links work fine except one link which is a form with post request. It doesn't pass the parameters. In the browser the links are not converted. How can I fix this? Thanks
<mj-text>
<form action="https://www.carsale.com/login" method="post" target="_blank">
<input type="hidden" name="customerId" value="{{ $inquiry->customer->customer_id ?? '' }}">
<input type="hidden" name="authToken" value="{{ $inquiry->customer->auth_token ?? '' }}">
<button type="submit" name="submit">Lets go</button>
</form>
Lets go
</mj-text>

Related

The POST method is not supported for this route in Laravel when external api sends data to me

I'm submitting these parameters to an external API at www.sample.com/gateway
<form action="www.sample.com/gateway/" method="POST">
<input type="hidden" name="MerchantCode" value="123abc">
<input type="hidden" name="MerchantRefNo" value="1234">
<input type="hidden" name="Particualrs" value="Transaction_type=Bill;Account Number=4321;Account Name=John Doe;Email Address=jd#test.com">
<input type="hidden" name="Amount" value="100">
<input type="hidden" name="PayorName" value="John Doe">
<input type="hidden" name="PayorEmail" value="jd#test.com">
<input type="hidden" name="ReturnURLOK" value="success.php">
<input type="hidden" name="ReturnURLError" value="{{ url('/paymentdetails') }}">
<input type="hidden" name="Hash" value="{{ md5('123abc' . '1234' . 100">
<button type="submit" class="btn btn-primary " value="POST TO GATEWAY"><i class="far fa-credit-card"></i> PAY NOW </button>
</form>
After which, on the ReturnURLError
Controller
public function getPaymentDetail()
{
$response = Http::get('https://sample.com/api.php');
return $response->json();
}
Route
Route::get('/paymentdetails', 'App\Http\Controllers\PaymentController#getPaymentDetail');
I am getting The POST method is not supported for this route. Supported methods: GET, HEAD. when external api sends back data to me.
I triend changing the route to post but then the error becomes The GET method is not supported in this route
Can someone help?

Change PUT request to POST request to include image update

I wrote a post edit method which at first consisted only of text. I did the update using a PUT request.
Now I want to include images to my posts, so I added it, and it works for my POST request of creating a post but doesn't work for my update post, when I want to change image, since PUT request doesn't support file uploads.
So now I'm stuck trying to change my update method from PUT request that only updates text to a POST request that updates both the text and an image if supplied.
This is the code I wrote so far:
public function update(Request $request, Post $post)
{
//store updated image
if($request->hasFile('image') && $request->file('image')->isValid()){
if($post->hasMedia('posts')) {
$post->media()->delete();
}
$post->addMediaFromRequest('image')->toMediaCollection('post', 's3');
}
$post->update(request()->validate([
'body' => 'required'
]));
return redirect($post->path());
}
I think that the $post->update doesn't work for the POST request. I just want to update a text if an update was given.
Using Laravel 6.
EDIT: My form layout structure (simplified)
<form action="action="/posts/{post}" method="POST">
#method('PUT')
#csrf
<div class="form-group row">
<input id="body" type="text" class="form-control" name="body" value="{{ old('body', $post->body) }}">
<input id="image" type="file" class="form-control" name="image">
<button type="submit" class="btn btn-primary">Update Post</button>
</form>
My routes:
Route::get('/posts/{post}/edit', 'PostsController#edit')->name('posts.edit');
Route::put('/posts/{post}', 'PostsController#update');
I tried your code and it worked fine with me , only added #csrf in form tag.
<form action="/posts/{post}" method="POST" enctype="multipart/form-data">
#csrf
#method('PUT')
<div class="form-group row">
<input id="body" type="text" class="form-control" name="body" value="{{ old('body', $post->body) }}">
<input id="image" type="file" class="form-control" name="image">
<button type="submit" class="btn btn-primary">Update Post</button>
</form>

How to add delete confirmation in laraadmin modules?

I am using laraadmin in one of my application but module generated by admin not confirming when deleting any record. Please some one help me How to add delete confirmation in laraadmin modules?
I do not know how to work with laraadmin but You can do that by java script:
Blade:
#foreach (items as item)
<form class="delete" action="{{ route('item.destroy', $item->id) }}" method="POST">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<input type="submit" value="Delete">
</form>
#endforeach
JS:
<script>
$(".delete").on("submit", function(){
return confirm("Do you want to delete this item?");
});
</script>
And if you need preety nice confirmation design You can use Sweet Alert JS Library:
https://sweetalert.js.org/guides/

not able to click on button where xpath is showing correct as per selenium IDE 2.9.1

I need to write xpath for 'New' button.
have tried:-
By.xpath("//form[#action='/intruvert/action/CustomRolesAction']/div/div[3]/div/a[1]")
By.xpath("//form[#name='CustomRolesForm']/div/div[3]/div/a[#style='background-color: rgb(242, 242, 242);' and #title='New']")
By.xpath("//form[#name='CustomRolesForm']/div/div[3]/div/a[#title='New']")
but not able to click on New button.
I am not sure here if i missing anything.
kindly suggest.
here is the code:-
<html>
<head>
<body>
<div class="bodywrap">
<form action="/intruvert/action/CustomRolesAction" method="post" name="CustomRolesForm">
<input type="hidden" value="CustomRolesDetails_t" name="userAction"/>
<input type="hidden" value="fullaccess" name="accessRight"/>
<input type="hidden" value="" name="uuid"/>
<input type="hidden" value="true" name="fromTab"/>
<input type="hidden" value="" name="selectedDomain"/>
<input type="hidden" value="/My Company:0/Manager:0" name="resourceName"/>
<input type="hidden" value="MANAGER" name="topMenuName"/>
<input type="hidden" value="Users and Roles" name="secondMenuName"/>
<input type="hidden" value="Roles" name="thirdMenuName"/>
<input type="hidden" value="/My Company:0" name="domainName"/>
<input type="hidden" value="/My Company:0" name="currentDomainName"/>
<input type="hidden" value="/Manager:0" name="shortResourceName"/>
<input type="hidden" value="false" name="ucaplModeEnabled"/>
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
<div class="gensecholder clearfix">
<div class="gensecheader clearfix">
<div class="gensecbody pad10all clearfix">
<div class="gensecfooter clearfix">
<div class="gensecfootright">
<a class="genericbtn" title="New" href="javascript:doSubmit('add')">New</a>
</div>
#Pranay after viewing your code, i got javascript error. inside your html you have not defined anywhere to javascript. see the image
Your html
<a class="genericbtn" title="New" href="javascript:doSubmit('add')">New</a>
Modified html
<a class="genericbtn" title="New" href="#">New</a>
Now use xpath method using javascript executor.
WebElement new_button = driver.findElement(By.xpath("//a[contains(text(), 'New')]"));
((JavascriptExecutor) driver).executeScript("arguments[0].click();", new_button);
OR
driver.findElement(By.xpath("//a[contains(text(), 'New')]")).click();
You can try to locate the button directly without ancestors
// by class name
By.className("genericbtn")
// by title
By.cssSelector("[title='New']")
// by partial href
By.cssSelector("[href*='add']")
//a[.="New"]
Just use text find a tag.
. means current context node(a).
You can just use either title or text property to find out the required link:
By.xpath("//a[#title='New']");
Or
By.linkText("New");
Or
By.xpath("//a[text()='New']");

POST method not working in laravel 5

**THIS is my code for form creation and action is set to post but it is showing error "tokenmismatchexception in verifycsrftoken.php line 53 laravel 5.1";
<html>
<body>
<form action="/abc" method="post">
<b style="padding-right:110px;">Patient's Name:</b>
<input type="text" name="fullname" required><br><br>
<b style="padding-right:50px;">Required Blood Group:</b>
<option>A+</option>
<select>
<option>B+</option>
<option>AB+</option>
<option>O+</option>
<option>A-</option>
<option>B-</option>
<option>AB-</option>
<option>O-</option>
</select><br><br>
<input
type="submit"
style="position:absolute;right:170px;"
name="submit"
value="Request">
</form>
</body>
</html>
You need to include the CSRF token in your form data. Add:
<input type="hidden" name="_token" value="{{ csrf_token() }}">
right after your opening form tag.

Resources