https://github.com/zircote/swagger-php/blob/master/Examples/example-object/example-object.php
Sunday, December 26, 2021
swagger json request body
* @OA\RequestBody(
Thursday, December 23, 2021
Tuesday, December 21, 2021
laravel test email with attachment
| <?php | |
| namespace App\Http\Controllers; | |
| use App\Mail\TestEmail; | |
| use Illuminate\Http\Request; | |
| use Illuminate\Http\JsonResponse; | |
| use Illuminate\Support\Facades\Mail; | |
| class EmailController extends Controller | |
| { | |
| public function list() | |
| { | |
| $emails = \App\Models\TestEmail::all(); | |
| $results = []; | |
| foreach ($emails as $key => $email) { | |
| $results[$key]['id'] = $email->id; | |
| $results[$key]['email'] = $email->email; | |
| $results[$key]['subject'] = $email->subject; | |
| $results[$key]['body'] = $email->body; | |
| $results[$key]['body'] = $email->body; | |
| $results[$key]['attachments'] = $email->attachments ? asset('storage/attachments/' . $email->attachments) : ''; | |
| } | |
| return $results; | |
| } | |
| public function send(Request $request): JsonResponse | |
| { | |
| $fields = $request->validate([ | |
| 'email' => 'required|string|email', | |
| 'subject' => 'required|string', | |
| 'body' => 'required|string' | |
| ]); | |
| try { | |
| // If any attachment found | |
| $attachments = ''; | |
| if ($request->file('attachments')) { | |
| $attachments = time() . '_' . $request->file('attachments')->getClientOriginalName(); | |
| $request->file('attachments')->move(storage_path('app/public/attachments/'), $attachments); | |
| } | |
| $testEmail = \App\Models\TestEmail::create([ | |
| 'email' => $fields['email'], | |
| 'subject' => $fields['subject'], | |
| 'body' => $fields['body'], | |
| 'attachments' => $attachments, | |
| ]); | |
| Mail::to($testEmail->email)->send(new TestEmail($testEmail)); | |
| } catch (\Exception $e) { | |
| return response()->json(['status' => 'error', 'message' => 'error on mail sending ' . $e->getMessage()]); | |
| } | |
| return response()->json(['status' => 'success', 'message' => 'Mail sent successfully']); | |
| } | |
| } |
Monday, December 20, 2021
git personal access token
From August 13, 2021, GitHub is no longer accepting account passwords when authenticating Git operations. You need to add a PAT (Personal Access Token) instead, and you can follow the below method to add a PAT on your system.
Create Personal Access Token on GitHub
From your GitHub account, go to Settings => Developer Settings => Personal Access Token => Generate New Token (Give your password) => Fillup the form => click Generate token => Copy the generated Token, it will be something like
ghp_sFhFsSHhTzMDreGRLjmks4Tzuzgthdvfsrta
Now follow below method based on your machine:
For Windows OS ⤴
Go to Credential Manager from Control Panel => Windows Credentials => find
git:https://github.com=> Edit => On Password replace with with your GitHub Personal Access Token => You are DoneIf you don’t find
git:https://github.com=> Click on Add a generic credential => Internet address will begit:https://github.comand you need to type in your username and password will be your GitHub Personal Access Token => Click Ok and you are done
For macOS ⤴
Click on the Spotlight icon (magnifying glass) on the right side of the menu bar. Type Keychain access then press the Enter key to launch the app => In Keychain Access, search for
github.com=> Find the internet password entry forgithub.com=> Edit or delete the entry accordingly => You are done
For a Linux-based OS ⤴
For Linux, you need to configure the local GIT client with a username and email address,
$ git config --global user.name "your_github_username" $ git config --global user.email "your_github_email" $ git config -lOnce GIT is configured, we can begin using it to access GitHub. Example:
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY > Cloning into `Spoon-Knife`... $ Username for 'https://github.com' : username $ Password for 'https://github.com' : give your personal access token hereNow cache the given record in your computer to remembers the token:
$ git config --global credential.helper cacheIf needed, anytime you can delete the cache record by:
$ git config --global --unset credential.helper $ git config --system --unset credential.helperNow try to pull with
-vto verify$ git pull -v
Linux/Debian (Clone as follows):
git clone https://<tokenhere>@github.com/<user>/<repo>.git
For PhpStorm
If you are using PhpStorm, go to menu Git => pull and select authentication via Personal Access Token. Enter your
PATit will allow you to pull/push the changes.
-
Vuetify is a popular UI framework for Vue apps. In this article, we’ll look at how to work with the Vuetify framework. Color Picker Inputs W...
-
In today’s software development landscape, APIs (Application Programming Interfaces) are essential for enabling communication between differ...
-
concat() join() fill() includes() indexOf() reverse() sort() splice() at() copyWithin() flat() Array.from() findLastIndex() forEach() every(...