vinubangs

vinubangs

Member Since 1 Year Ago

Experience Points
1,780
Total
Experience

3,220 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
1,780 XP
Aug
30
3 weeks ago
Activity icon

Started a new Conversation How To Post Form Data Through Guzzle In Api

I created an API for login in laravel. In postman it is working properly. Now I want to use that api from my web form. I have an login form and fill email and password then click on button then my login api should be run and should be redirect on dashboard.

For this I am using GUZZLE.

API is (in, routes/api.php):

Route::post('login', 'apifolder\[email protected]');

login method in AuthCOntroller is:

public function login(Request $request)
    {
        $request->validate([
            'email' => 'required|string|email',
            'password' => 'required|string',
            'remember_me' => 'boolean'
        ]);

        $credentials = request(['email', 'password']);
        if(!Auth::attempt($credentials))
            return response()->json([
                'message' => 'Unauthorized'
            ], 401);

        $user = $request->user();
        
        $tokenResult = $user->createToken('Personal Access Token');
        $token = $tokenResult->token;
        if ($request->remember_me)
            $token->expires_at = Carbon::now()->addWeeks(1);
        $token->save();
        return response()->json([
            'access_token' => $tokenResult->accessToken,
            'token_type' => 'Bearer',
            'expires_at' => Carbon::parse(
                $tokenResult->token->expires_at
            )->toDateTimeString()
        ]);
    }

Above API is working properly in postman.

Now I want to use it from my web form.

routes are(in, routes/web.php):

Route::get('/','[email protected]')->name('login');
Route::POST('/login','[email protected]_submit')->name('login.submit');

controller is:

    public function login_submit(Request $request)
    {
    	$client = new \GuzzleHttp\Client();
    	 $url = "http://127.0.0.1:8000/api/auth/login";
    	
    	 $body['form_param'] = array('email'=>$request->email,'password'=>$request->password);
    	 $request = $client->post($url,$body);
    	 $response = $request->send();
    	
    	 dd($response);
    }

login blade is:

 <form action="{{ route('login.submit') }}" method="post">
        @csrf
        <div class="input-group mb-3">
          <input type="email" class="form-control" name="email" placeholder="Email">
          <div class="input-group-append">
            <div class="input-group-text">
              <span class="fas fa-envelope"></span>
            </div>
          </div>
        </div>
        <div class="input-group mb-3">
          <input type="password" class="form-control" name="password" placeholder="Password">
          <div class="input-group-append">
            <div class="input-group-text">
              <span class="fas fa-lock"></span>
            </div>
          </div>
        </div>
        <div class="row">
          <!-- /.col -->
          <div class="col-4">
            <button type="submit" class="btn btn-primary btn-block">Sign In</button>
          </div>
          <!-- /.col -->
        </div>
      </form>

But not working.

Jul
30
1 month ago
Activity icon

Replied to Save Image As Icon Onclick Button.

If click on button then an image should be save, like icon and after click on that icon then downloaded image should be open.

Activity icon

Replied to Save Image As Icon Onclick Button.

In my android mobile in web page.

Activity icon

Started a new Conversation Save Image As Icon Onclick Button.

I have a button in my webpage in LARAVEL. If I click on that button then an image downloads.

But I need, if click on button then image should be download in icon and after click on that icon downloaded image should be show.

I tired from 2 days. But I did't get any idea. Please give any idea or URL.

Jun
26
2 months ago
Activity icon

Started a new Conversation How To Convert Html To Image

I am making an API in laravel lumen. I want to convert blade file into image in laravel. First I am converting blade file into html and then html to image. blade to html is converting, but how to convert html to image?

I have to return path of converted image in response.

my controller is:

public function savecard()
{
$result = json_decode(json_encode($result), true);
        $destinationPath = storage_path('uploads/card_html/');
        $new_path = str_replace('\', '/', $destinationPath);

        $html = view($selected_template,compact('result'));
        $html = $html->render();
        File::put($new_path.$html_save, view($selected_template,compact('result'))
                ->with(['CardSave' => $html, 'message' => 'Success'])
                ->render()
                );
}

in above code $result is coming from query and it will show on blade file. But after that, how to convert html to image.

Jun
11
3 months ago
Activity icon

Awarded Best Reply on How To Get Validator Fail Response In Key Value Pair In Laravel

I solve my problem by

$message = count($validator->errors()->all()) > 1 ? implode($validator->errors()->all(), ' and ').'.' : $validator->errors()->all()[0].'.';

return response()->json(['user' => 'Failed', 'message' => $message], 409);
Activity icon

Replied to How To Get Validator Fail Response In Key Value Pair In Laravel

I solve my problem by

$message = count($validator->errors()->all()) > 1 ? implode($validator->errors()->all(), ' and ').'.' : $validator->errors()->all()[0].'.';

return response()->json(['user' => 'Failed', 'message' => $message], 409);
Activity icon

Started a new Conversation How To Get Validator Fail Response In Key Value Pair In Laravel

I am making register API in laravel. I have used Validator to validate the form.

Below is the my controller:

 public function register(Request $request)
{
    $validator = Validator::make($request->all(), [
        'contact' => 'required|numeric|unique:users',
        'email' => 'required|email|unique:users',
        'password' => 'required|min:8|regex:/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#[email protected]$%^&*-]).{6,}$/|confirmed',
    ],
    [
        'contact.unique' => 'The phone number is already in use.',
        'email.unique' => 'The email address is already in use.',
        'password.regex' => 'Password should be a minimum of 8 characters including uppercase and lowercase letters, at least 1 number and at least 1 special character ([email protected]#$%^&*).',
        'password.confirmed' => 'Password does not match.',
    ]
    );

    if ($validator->fails()) {
        return response()->json(['user' => 'Failed', 'message' => $validator->errors()], 409);
    }
}

It gives response in postman:

{
"user": "Failed",
"message": {
    "contact": [
        "The phone number is already in use."
    ],
    "email": [
        "The email address is already in use."
    ]
}
}

But I need like this:

{
"user": "Failed",
"message": "The email address is already in use and The phone number is already in use."
}

How to do this?

Jun
10
3 months ago
Activity icon

Started a new Conversation How To Convert Blade File Into Html And Save Into Folder

I am using laravel lumen for making an API. I need to convert blade file into html and save that file into image.

I tried, but not working.

my controller is:

public function viewcards()
{
$html = View::make('template1');
$html = $html->render();
$html = html_entity_decode($html);
return response()->json(['CardSave' => $html, 'message' => 'Success'], 201);
}

But in response of postman:

{
"CardSave": "<!DOCTYPE html>\r\n<html>\r\n    <head>\r\n        <title>Template One</title>\r\n        <link href=\"http://localhost/ark_newtech_digbiz/digbizcardapi/public/css/style1.css\" rel=\"stylesheet\" />\r\n        <link href=\"http://localhost/ark_newtech_digbiz/digbizcardapi/public/css/font-awesome.min.css\" rel=\"stylesheet\" />
}

why showing \r\n and not taking < in response. And how to save it into html?

I am stuck from 2 days. Please help anyone.

Activity icon

Replied to How To Send Image In Postman

Please help anyone. I am stucked from 2 days.

Jun
09
3 months ago
Activity icon

Started a new Conversation How To Send Image In Postman

I am using laravel lumen to make API. I have to convert and save blade file in image and have to send image path in api.

How to do that? I am not getting idea. I tried by below code-

https://laracasts.com/discuss/channels/lumen/how-to-convert-view-file-in-image-and-return-in-api-in-laravel

But not working. What I am doing wrong? Or any other solution?

Activity icon

Started a new Conversation How To Convert View File In Image And Return In Api In Laravel

I am creating an API in laravel. In which, I have to convert blade file into image and should return path of converted image or base64 in api.

I am using html2canvas.

routes are:

$router->POST('savecard', '[email protected]');
 $router->get('save-capture/{image_for_save}', '[email protected]');

I have to call savecard by POSTMAN and run some code and then I have a blade file template1.blade.php

My controller is:

public function SaveCard(Request $request)
{
$find_edittemplate_id = edittemplate::select('id')->where('user_id','=',$request->user_id)->first();
return view('template1');
}

    public function savecapture($image_for_save)
{
    $image = $image_for_save;
    $image = explode(";", $image)[1];

    // Remove base64 from left side of image data
    // and get the remaining part
    $image = explode(",", $image)[1];

    // Replace all spaces with plus sign (helpful for larger images)
    $image = str_replace(" ", "+", $image);

    // Convert back from base64
    $image = base64_decode($image);
    $destinationPath = storage_path('uploads/');

    file_put_contents($destinationPath,'temp.png',$image);

    return response()->json(['CardSave' => $image, 'message' => 'Success'], 201);
   } 

After view template1 file, I created ajax call for convert image to template1.blade.php.

savecapture() will run on template1.blade.php by ajax

view is:

<!DOCTYPE html>
<html>
<head>
    <title>Template One</title>
    <link href="{{ url('css/style1.css') }}" rel="stylesheet" />
    <link href="{{ url('css/font-awesome.min.css') }}" rel="stylesheet" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
        integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
        integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
    <link href="../css/font-awesome.min.css" rel="stylesheet" />
</head>
<body>
<div class="row" id="mydiv_screenshot">
   <div class="col-md-12 col-sm-12">
     <!-- Logo_Section -->
     <div class="row text-center backgroundf0f0f0 pd20">
     <div class="logo col-md-6 col-sm-8 col-sm-offset-2 col-md-offset-3">
     <img src="{{ url('images/logo.png') }}" alt="Logo" width="100%" height="auto" max-height="130px"/>
     </div>
     <div class="col-md-12 col-sm-12 businessheadlineblack pdt5">
     <h3>Digital Business Card</h3>
     </div>
     </div>
    </div>
 </div>
    </body>
 <!-- Latest compiled and minified JavaScript -->
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
 integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
 crossorigin="anonymous"></script>
</html>

<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
    <script>
    $(document).ready(function() {
    window.scrollTo(0, 0);        
  html2canvas(document.getElementById("mydiv_screenshot")).then(function (canvas) {
 var ajax = new XMLHttpRequest();
 var image_data = canvas.toDataURL("image/jpeg", 0.9);
   $.ajax({
                url: '{{ url("save-capture") }}',
                type: 'GET',
                data: {"image_for_save": image_data},
                success: function(response){
                    if(response != 0){
                        //console.log(response);
                    }else{
                        //console.log(response);
                    }
                }, 
                async: true
                });
            });
        });
    </script>

But It show in postman complete blade file and also not run ajax.

May
29
3 months ago
Activity icon

Replied to How To Upload File On Another Url Folder

@michaloravec

I tried with in config/filesystem.php

I added custom code.



        'custom' => [
            'driver' => 'local',
            'root'   => '../ims_website',
        ],

in my controller.

$image = $request->file('resume');
$store  = Storage::disk('custom')->put($image, 'contents');

But not working.

error: League\Flysystem\Exception Impossible to create the root directory "../ims_website\E:/xampp/tmp".

Activity icon

Replied to How To Upload File On Another Url Folder

@michaloravec

Basically my project and other project both are in same server. Only project folder is different. I need to upload file from my project folder to another project folder. That is why I gave complete URL.

Activity icon

Replied to How To Upload File On Another Url Folder

@michaloravec

Sorry. I am not geeting clearly what to do, from link given by you

Activity icon

Replied to How To Upload File On Another Url Folder

It should simply upload on that directory?

Activity icon

Started a new Conversation How To Upload File On Another Url Folder

I am working on xampp localhost. I have a laravel setup. and I am uploading a file from my project to another laravel project.

public function cvupload(Request $request)
    {
		$this->validate($request,[
		'resume' => 'required|mimes:doc,pdf,docx'
		],
		[
		    'required' => 'This field is required',
		    'mimes' => 'Allowed only doc,pdf,docx',
		]);

		$image = $request->file('resume');
		$name = time().'.'.$image->getClientOriginalExtension();
		$destinationPath = 'http://example.com/adminapi/app/storage/uploads/';
		$image->move($destinationPath, $name);
		$resume_with_path = $destinationPath.$name;
}

But It gives error:

Symfony\Component\HttpFoundation\File\Exception\FileException Unable to create the directory.

May
28
3 months ago
Activity icon

Started a new Conversation How To Get Transaction Id And Name In Bluesnap Payment Gateway

I am using bluesnap payment gateway in Laravel. And it is working properly. But in return I am not getting transaction id and customer name is not showing in sandbox account also.

$environment = 'sandbox'; // or 'production'
$keys = \tdanielcox\Bluesnap\Bluesnap::init($environment, 'API_111111111111111111111', 'password11');

$response = \tdanielcox\Bluesnap\CardTransaction::create([
    'creditCard' => [
        'firstName' => 'Jane',
        'lastName' => 'Shopper',
        'cardNumber' => '3566000020000410',
        'expirationMonth' => '02',
        'expirationYear' => '2023',
        'securityCode' => '123'
    ],
    'amount' => 10.00,
    'currency' => 'USD',
    'recurringTransaction' => 'ECOMMERCE',
    'cardTransactionType' => 'AUTH_CAPTURE',
]);

if ($response->failed())
{
    $error = $response->data;
    $transaction = $response->data;
echo"<pre>";
print_r($transaction);
echo"</pre>";

    // handle error
}

$transaction = $response->data;
echo"<pre>";
print_r($transaction);
echo"</pre>";
//$transaction;

My success response is:

tdanielcox\Bluesnap\Models\CardTransaction Object
(
[children:protected] => Array
    (
        [transactionMetaData] => item
        [creditCard] => item
        [vendorInfo] => item
    )

[cardTransactionType] => AUTH_CAPTURE
[amount] => 10
[recurringTransaction] => ECOMMERCE
[merchantTransactionId] => 
[softDescriptor] => BLS*onboardingDefault
[vaultedShopperId] => 27595185
[currency] => USD
[transactionMetaData] => 
[creditCard] => tdanielcox\Bluesnap\Models\CreditCard Object
    (
        [cardNumber] => 
        [encryptedCardNumber] => 
        [cardLastFourDigits] => 0410
        [cardType] => JCB
        [expirationMonth] => 
        [expirationYear] => 
        [securityCode] => 
        [encryptedSecurityCode] => 
        [children:protected] => Array
            (
            )

        [cardSubType] => CREDIT
        [cardCategory] => STANDARD
        [binCategory] => CONSUMER
        [cardRegulated] => N
        [issuingCountryCode] => us
    )

[transactionFraudInfo] => 
[id] => 1031167745
[usdAmount] => 10
[transactionApprovalDate] => 05/29/2020
[transactionApprovalTime] => 00:07:12
[cardHolderInfo] => Array
    (
    )

[processingInfo] => Array
    (
        [processingStatus] => success
        [cvvResponseCode] => ND
        [authorizationCode] => 654321
        [avsResponseCodeZip] => U
        [avsResponseCodeAddress] => U
        [avsResponseCodeName] => U
    )

[fraudResultInfo] => Array
    (
    )

)
Apr
24
4 months ago
Activity icon

Started a new Conversation How To Show Only Specified Column In Multidimensional Array

I have a table in which 5 columns title,photo1,photo2,photo3,photo4. Now I have 5 rows and I have added external link in photos columns.

public function index()
    {
    	$sampleWorks  =SampleWork::all();

         $sampleWorkswithImage = $sampleWorks->map(function ($message, $key) {
         if ( $message->photo1!="") {
              $message->photo1 = 'http://xyz.com/public/uploads/'.$message->photo1;
         }
         if ( $message->photo2!="") {
             $message->photo2 = 'http://xyz.com/public/uploads/'.$message->photo2;
         }
         if ( $message->photo3!="") {
             $message->photo3 = 'http://xyz.com/public/uploads/'.$message->photo3;
         }
         if ( $message->photo4!="") {
             $message->photo4 = 'http://xyz.com/public/uploads//'.$message->photo4;
         }
        });
        $newarray = $sampleWorks->toArray();
		
    	return view('OurWork/OurWork',compact('newarray'));
    }

My view is:

@foreach($newarray as $array)
   @foreach($array as $key=>$value)
      <div class="col-md-4 our_work_images ">
                               
               <img src="{{ asset('here image path will be set of  all photos') }}"/>
                               
       </div>
   @endforeach
@endforeach                                	

I need only photo1,photo2,photo3,photo4 columns in img tag. How to do that

Apr
21
5 months ago
Activity icon

Replied to Make:controller Is Not Working In Laravel 6.0

Yes I ran composer install......and it is still making folder lumen-framework in vendor/laravel

Activity icon

Replied to Make:controller Is Not Working In Laravel 6.0

Now I see in vendor folder...It is using lumen-framework and asset() also not working. I think lumen-framework is the reason.

And I also tried @bobbybouwmann answer. But same error

Activity icon

Replied to Make:controller Is Not Working In Laravel 6.0

I updated my question. Please read once.

Activity icon

Replied to Make:controller Is Not Working In Laravel 6.0

I updated my question. Please read once.

Activity icon

Replied to Make:controller Is Not Working In Laravel 6.0

Thank you for reply. Actually, my friend given me a zip file of installed laravel project from his system. In which, some API works are done. Now he want to setup a website for public. My php version is 7.2 and given laravel version is 6.0

So it can be affect ?

Activity icon

Started a new Conversation Make:controller Is Not Working In Laravel 6.0

My friend given me a zip file of installed laravel project from his system. In which, some API works are done. Now he want to setup a website for public. My php version is 7.2 and given laravel version is 6.0

I am running command php

php artisan make:controller NewController

But giving error-

Command "make:controller" is not defined.

Did you mean one of these?
    make:migration
    make:seeder