sanjayacloud

sanjayacloud

Member Since 1 Year Ago

Experience Points
5,340
Total
Experience

4,660 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
8
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 2
5,340 XP
Nov
13
4 weeks ago
Activity icon

Started a new Conversation Unable To Get Google Adwords Campaign Data

We used "edujugon/laravel-google-ads" to get campaign data from Google Adwords. So far we have been not able to gather the data as the response only seems to return the field names but not the field data. We used this method available in the "edujugon/laravel-google-ads " documentation.

  $ads = new GoogleAds();
        $ads->service(CampaignService::class)
            ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
            ->get();
        dd($ads);

The output we are getting is as follows.

GoogleAds {#263 ▼
  #userCredentials: null
  #session: null
  #service: Service {#258 ▼
    #where: ""
    #orderBy: ""
    #limit: ""
    #session: AdWordsSession {#305 ▶}
    #adWordsServices: AdWordsServices {#259 ▶}
    #service: CampaignService {#289 ▶}
    #fields: array:6 [▼
      0 => "Id"
      1 => "Name"
      2 => "Status"
      3 => "ServingStatus"
      4 => "StartDate"
      5 => "EndDate"
    ]
  }
}

Is there a workaround to get the actual campaign data?

Thank You in Advance.

Nov
11
1 month ago
Activity icon

Replied to Class Google\AdsApi\AdWords\v201806\cm\CampaignService Does Not Exist

@jaytee thanks for the reply. so far with the test account, we are getting an output like this.

GoogleAds {#263 ▼
  #config: array:4 [▶]
  #env: "test"
  #userCredentials: null
  #session: null
  #service: Service {#258 ▼
    #where: ""
    #orderBy: ""
    #limit: ""
    #session: AdWordsSession {#305 ▶}
    #adWordsServices: AdWordsServices {#259 ▶}
    #service: CampaignService {#289 ▶}
    #fields: array:6 [▼
      0 => "Id"
      1 => "Name"
      2 => "Status"
      3 => "ServingStatus"
      4 => "StartDate"
      5 => "EndDate"
    ]
  }
}

*And this is my method, I am using "edujugon/laravel-google-ads" package.

  $ads = new GoogleAds();

        $ads->service(CampaignService::class)
            ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
            ->get();
        dd($ads);
Activity icon

Replied to Class Google\AdsApi\AdWords\v201806\cm\CampaignService Does Not Exist

@jaytee I have made a test account and it's work fine. But I don't have any idea how to get campaign data like a live campaigns. Do you have any idea about that? Then I can wait until google feedback

Activity icon

Started a new Conversation Error From Google Ads API

Hi All,

We have applied for a developer token about a week ago and we are still getting the above error. How long does it take for a developer token to be approved? Is there any workaround for this type of issue?

Thank You in Advance.

Oct
31
1 month ago
Activity icon

Started a new Conversation Class Google\AdsApi\AdWords\v201806\cm\CampaignService Does Not Exist

Hi Friends,

I am using https://github.com/spotonlive/laravel-google-ads package for Google Ads. And I got the above error. Can anyone help me to resolve this?

My code.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use LaravelGoogleAds\Services\AdWordsService;
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201806\cm\CampaignService;
use Google\AdsApi\AdWords\v201806\cm\OrderBy;
use Google\AdsApi\AdWords\v201806\cm\Paging;
use Google\AdsApi\AdWords\v201806\cm\Selector;

class AdController extends Controller
{
    /** @var AdWordsService */
    protected $adWordsService;

    /**
     * @param AdWordsService $adWordsService
     */
    public function __construct(AdWordsService $adWordsService)
    {
        $this->adWordsService = $adWordsService;
    }


    public function index()
    {
        $customerClientId = '697-169-9937';

        $campaignService = $this->adWordsService->getService(CampaignService::class, $customerClientId);
         dd($campaignService);
        // Create selector.
        $selector = new Selector();
        $selector->setFields(array('Id', 'Name'));
        $selector->setOrdering(array(new OrderBy('Name', 'ASCENDING')));

        // Create paging controls.
        $selector->setPaging(new Paging(0, 100));

        // Make the get request.
        $page = $campaignService->get($selector);
    }
}

Oct
10
2 months ago
Activity icon

Replied to Auth Middleware Error.

After clear all cache it solved.

Activity icon

Replied to Auth Middleware Error.

Problem solved. Thanks all of you for your attention.

Activity icon

Replied to Auth Middleware Error.

Ok will try.

Activity icon

Replied to Auth Middleware Error.

@munazzil You mean Admin Middleware (Admin.php) right?

Activity icon

Replied to Auth Middleware Error.

@sinnbeck @bobbybouwmann Here's my kernal.php

  protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
        'admin' => \App\Http\Middleware\Admin::class,
    ];

Activity icon

Started a new Conversation Auth Middleware Error.

Hi Everyone,

I am trying to make auth middleware call "Admin" And it registered on http kernal. But when i add it into my controller in constructor. I got below error.

Error: "Class admin does not exist"

My constructor

public function __construct()
    {
        $this->middleware(['auth','admin']);
    }

And below my middleware

<?php

namespace App\Http\Middleware;

use Closure;

class Admin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if(auth()->user()->role == 5){
            $response = $next($request);
            $response->header('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0')->header('Pragma', 'no-cache')->header('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT');
            return $response;
        }
        return redirect('/admin/login')->with('login-msg','You have not admin access');
    }
}

Anyone can help me to resolve this error?

Oct
09
2 months ago
Activity icon

Replied to Logout Error.

@nakov You are correct. That's why it does not work. After I remove href value and replace it with"#" it's work

Activity icon

Replied to Logout Error.

@bobbybouwmann My route list has a logout post method. here's my route list.

+--------+-----------+------------------------------+--------------------+------------------------------------------------------------------------+--------------+
| Domain | Method    | URI                          | Name               | Action                                                                 | Middleware   |
+--------+-----------+------------------------------+--------------------+------------------------------------------------------------------------+--------------+
|        | GET|HEAD  | /                            |                    | App\Http\Controllers\[email protected]                            | web          |
|        | GET|HEAD  | about                        |                    | App\Http\Controllers\[email protected]                            | web          |
|        | GET|HEAD  | api/user                     |                    | Closure                                                                | api,auth:api |
|        | GET|HEAD  | checkout/{id}                |                    | App\Http\Controllers\[email protected]                         | web          |
|        | GET|HEAD  | contact                      |                    | App\Http\Controllers\[email protected]                          | web          |
|        | POST      | contact                      |                    | App\Http\Controllers\[email protected]                           | web          |
|        | GET|HEAD  | home                         | home               | App\Http\Controllers\[email protected]                          | web          |
|        | GET|HEAD  | hosting                      |                    | App\Http\Controllers\[email protected]                          | web          |
|        | GET|HEAD  | login                        | login              | App\Http\Controllers\Auth\[email protected]                | web,guest    |
|        | POST      | login                        |                    | App\Http\Controllers\Auth\[email protected]                        | web,guest    |
|        | POST      | logout                       | logout             | App\Http\Controllers\Auth\[email protected]                       | web          |
|        | POST      | password/email               | password.email     | App\Http\Controllers\Auth\[email protected]  | web,guest    |
|        | POST      | password/reset               | password.update    | App\Http\Controllers\Auth\[email protected]                | web,guest    |
|        | GET|HEAD  | password/reset               | password.request   | App\Http\Controllers\Auth\[email protected] | web,guest    |
|        | GET|HEAD  | password/reset/{token}       | password.reset     | App\Http\Controllers\Auth\[email protected]        | web,guest    |
|        | POST      | payment                      |                    | App\Http\Controllers\[email protected]                           | web          |
|        | GET|HEAD  | projects                     |                    | App\Http\Controllers\[email protected]                         | web          |
|        | GET|HEAD  | publicView                   | publicView.index   | App\Http\Controllers\[email protected]                            | web          |
|        | POST      | publicView                   | publicView.store   | App\Http\Controllers\[email protected]                            | web          |
|        | GET|HEAD  | publicView/create            | publicView.create  | App\Http\Controllers\[email protected]                           | web          |
|        | GET|HEAD  | publicView/{publicView}      | publicView.show    | App\Http\Controllers\[email protected]                             | web          |
|        | PUT|PATCH | publicView/{publicView}      | publicView.update  | App\Http\Controllers\[email protected]                           | web          |
|        | DELETE    | publicView/{publicView}      | publicView.destroy | App\Http\Controllers\[email protected]                          | web          |
|        | GET|HEAD  | publicView/{publicView}/edit | publicView.edit    | App\Http\Controllers\[email protected]                             | web          |
|        | POST      | quotation                    |                    | App\Http\Controllers\[email protected]                         | web          |
|        | POST      | register                     |                    | App\Http\Controllers\Auth\[email protected]                  | web,guest    |
|        | GET|HEAD  | register                     | register           | App\Http\Controllers\Auth\[email protected]      | web,guest    |
|        | GET|HEAD  | services                     |                    | App\Http\Controllers\[email protected]                         | web          |
|        | GET|HEAD  | user/help                    |                    | App\Http\Controllers\[email protected]                            | web          |
|        | GET|HEAD  | user/orders                  |                    | App\Http\Controllers\[email protected]                          | web          |
|        | GET|HEAD  | user/portal                  |                    | App\Http\Controllers\[email protected]                          | web          |
|        | POST      | user/ticket                  |                    | App\Http\Controllers\[email protected]                          | web          |
|        | GET|HEAD  | vps                          |                    | App\Http\Controllers\[email protected]                             | web          |
+--------+-----------+------------------------------+--------------------+------------------------------------------------------------------------+--------------+

Activity icon

Started a new Conversation Logout Error.

Hello friend,

I have an error when trying to logout from system, It's says "Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException"

This is my logout form

@if(Auth::check())
                                            <a data-content="inline" data-aux-classes="tml-form-modal height-auto" data-toolbar="" data-modal-mode data-modal-width="500" data-modal-animation="scaleIn" data-lightbox-animation="fadeIn" href="{{url('user/portal')}}" class="button small rounded no-label-on-mobile no-margin-bottom fade-location client-portal"><span class="icon-lock left"></span><span class="hide-on-mobile">Client Portal</span></a>
                                               <a href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();" data-content="inline" data-aux-classes="tml-form-modal height-auto" data-toolbar="" data-modal-mode data-modal-width="500" data-modal-animation="scaleIn" data-lightbox-animation="fadeIn" class="button small rounded no-label-on-mobile no-margin-bottom fade-location client-portal"><span class="icon-log-out left"></span><span class="hide-on-mobile">Logout</span></a>
                                            <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                                @csrf
                                            </form>
                                        @else
                                            <a data-content="inline" data-aux-classes="tml-form-modal height-auto" data-toolbar="" data-modal-mode data-modal-width="500" data-modal-animation="scaleIn" data-lightbox-animation="fadeIn" href="{{url('login')}}" class="button small rounded no-label-on-mobile no-margin-bottom fade-location client-portal"><span class="icon-lock left"></span><span class="hide-on-mobile">Client Portal</span></a>
                                        @endif

And this is my logout method,

 public function logout(Request $request) {
        Auth::logout();
        return redirect('/login');
    }

Can anyone help me?

Sep
30
2 months ago
Activity icon

Replied to Cannot Load Routes From Database

@filipc Thanks. Its work.

Activity icon

Replied to Cannot Load Routes From Database

@siangboon How Can i do that?

If I echo the output in route Its look like below.

{"id":1,"title":"Route Permission","route_name":"permission","method_type":"get","controller_name":"RoutePermissionController","method_name":"index","created_at":"2019-09-30 12:11:22","updated_at":"2019-09-27 13:03:56"}
Activity icon

Started a new Conversation Cannot Load Routes From Database

Hi Friends,

I want load routes from database & access it. I have load routes from database But its says 404 error. But That Route is there & Also controller method is there.

My web.php like below.

$routes = \App\Route::all();

foreach ($routes as $route){
    $method_type = $route->method_type;
    Route::$method_type("'".$route->route_name."'", "'".$route->controller_name."@".$route->method_name."'");

    echo $route;
}

Controller Code.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class RoutePermissionController extends Controller
{
    public function index()
    {
        echo "Test";
    }
}

Activity icon

Replied to Access To Undeclared Static Property: Illuminate\Support\Facades\Route::$route

I followed your steps. Then I have error like below.


My Code.

$routes = \App\Route::all();
foreach ($routes as $route){
    $method = $route->method_type($route->route_name, $route->controller_name . '@' . $route->method_name);
    Route::$method;
}
Activity icon

Replied to Access To Undeclared Static Property: Illuminate\Support\Facades\Route::$route

@bobbybouwmann & @resin Sorry. I lost my full code posted to in this post. This is the full code.

$routes = \App\Route::all();
foreach ($routes as $route){
    Route::$route->method_type("'".$route->route_name."'", "'".$route->controller_name."@".$route->method_name."'");
}
Activity icon

Started a new Conversation Access To Undeclared Static Property: Illuminate\Support\Facades\Route::$route

Hi Guys,

I am trying to load routes from database. When i am trying to load I got below error.

Error

  Symfony\Component\Debug\Exception\FatalThrowableError  : Access to undeclared static property: Illuminate\Support\Facades\Route::$route

  at E:\xampp\htdocs\projects\client\laravel_admin_panel\routes\web.php:35
    31|
    32| $routes = \App\Route::all();
    33|
    34| foreach ($routes as $route){
  > 35|     Route::$route->method_type("'".$route->route_name."'", "'".$route->controller_name."@".$route->method_name."'");
    36| }
    37|
    38|

  Exception trace:

  1   require()
      E:\xampp\htdocs\projects\client\laravel_admin_panel\vendor\laravel\framework\src\Illuminate\Routing\RouteFileRegistrar.php:35

  2   Illuminate\Routing\RouteFileRegistrar::register(Object(Illuminate\Database\Eloquent\Collection))
      E:\xampp\htdocs\projects\client\laravel_admin_panel\vendor\laravel\framework\src\Illuminate\Routing\Router.php:415
  Please use the argument -v to see more details.

My Code in web.php

foreach ($routes as $route){
    Route::$route->method_type("'".$route->route_name."'", "'".$route->controller_name."@".$route->method_name."'");
}
Sep
24
2 months ago
Activity icon

Replied to Artisan Command Not Work

Thanks. It's work @snapey

Activity icon

Replied to Artisan Command Not Work

Then I got below error

My Error, Symfony\Component\Console\Exception\InvalidArgumentException The "CategoryController" argument does not exist.

My Method

public function create()
    {
        $exitCode = Artisan::call('make:controller', [
            'CategoryController' => true,
        ]);
      return $exitCode;
    }

Activity icon

Started a new Conversation Artisan Command Not Work

Hi Guys,

I want to run artisan command from my method. when I trying make controller through my method, I got below error, Can anyone help me for do this?

Error,

Symfony\Component\Debug\Exception\FatalThrowableError Argument 2 passed to Illuminate\Foundation\Console\Kernel::command() must be an instance of Closure, string given, called in E:\xampp\htdocs\projects\client\laravel_admin_panel\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php on line 239

My method,

 public function create()
    {
      $ct = Artisan::command('make:controller', 'CategoryController');
      return back();
    }

Sep
05
3 months ago
Activity icon

Started a new Conversation How To Change File Upload Directory In Unisharp/laravel-filemanager Public Folder To Storage Folder ?

Does anyone know, How to change file upload directory in unisharp/laravel-filemanager public folder to storage folder ?

Aug
29
3 months ago
Activity icon

Started a new Conversation Can I Know, How To Use Unisharp/laravel-filemanager Without Login ?

Anyone can help me, how to use unisharp/laravel-filemanager without login?

Aug
28
3 months ago
Activity icon

Replied to How To Check If Voucher Is Expired After It Purchased One Year.?

This is what i am tried. Its not work.

$voucher = Voucher::where('code', $request->code)->first();

        $today = date("Y-m-d H:i:s");
        $startdate = $voucher['created_at'];
        $offset = strtotime("+365 day");
        $enddate = date($startdate, $offset);
        $today_date = new  \DateTime($today);
        $expiry_date = new \DateTime($enddate);

        if ($expiry_date < $today_date) {

            return response()->json(['error' =>"Voucher is expired"]);
        }

Activity icon

Started a new Conversation How To Check If Voucher Is Expired After It Purchased One Year.?

Hi Guys,

I am building a voucher generate system in laravel. This voucher validity period is one year. Now i want do is when user trying to redeem a voucher then user cannot do it because of it is expired. Any one can help me to do this. Because I don't have any idea about this.

Jul
31
4 months ago
Activity icon

Replied to Datatable Date Sort Not Work.

I have used that. but still not work

here's the code.

  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js"></script>
    <script src="https://cdn.datatables.net/plug-ins/1.10.12/sorting/datetime-moment.js"></script>
<script>
    $(document).ready(function () {
        $.fn.dataTable.moment( 'DD/MM/YYYY' );
        $('#purchase-history').daterangepicker(null, function (start, end, label) {
            bringData( start.format('YYYY-MM-DD') , end.format('YYYY-MM-DD'));
        });
        bringData('{{date("Y/m/d" , strtotime("-1 months"))}}' , '{{date("Y/m/d")}}');
        function bringData(start, end) {
            $.ajax({
                url: base + '/admin/used-boxes-data',
                type: 'post',
                data: 'start='+start+'&end='+end,
                async: false,
                success: function (respond) {
                    if (respond.success) {
                        $('#content').html(respond.data);
                          $("#used").DataTable({
                              ordering: true,
                              paging: true,
                              searching: true,
                                dom: "Blfrtip",
                                buttons: [
                                    {
                                        extend: "copy",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "csv",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "excel",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "pdfHtml5",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "print",
                                        className: "btn-sm"
                                    }
                                ],
                                responsive: true,
                                order: [[ 2, "desc" ]],
                            });

                    } else {

                    }
                },
                complete: function () {
                }
            });
        }
    });
</script>

Any idea?

Activity icon

Started a new Conversation Datatable Date Sort Not Work.

Hi I have use datatable in my project. I want to sort my date column. Its not work. But other column sort work fine. here's my code.

  $(document).ready(function () {
        $('#purchase-history').daterangepicker(null, function (start, end, label) {
            bringData( start.format('YYYY-MM-DD') , end.format('YYYY-MM-DD'));
        });
        bringData('{{date("Y/m/d" , strtotime("-1 months"))}}' , '{{date("Y/m/d")}}');
        function bringData(start, end) {
            $.ajax({
                url: base + '/admin/used-boxes-data',
                type: 'post',
                data: 'start='+start+'&end='+end,
                async: false,
                success: function (respond) {
                    if (respond.success) {
                        $('#content').html(respond.data);
                          $("#used").DataTable({
                                dom: "Blfrtip",
                                buttons: [
                                    {
                                        extend: "copy",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "csv",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "excel",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "pdfHtml5",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "print",
                                        className: "btn-sm"
                                    }
                                ],
                                responsive: true,
                              order: [[ 1, "desc" ]],
                              columnDefs : [{"targets":1, "type":"date-eu"}],
                            });

                    } else {

                    }
                },
                complete: function () {
                }
            });
        }
    });
Jul
29
4 months ago
Jul
27
4 months ago
Activity icon

Started a new Conversation How To Pass To Email For Laravel Notification

Hi, I want to know how to pass to email for below method.

public function sendOrderSummeryMessage($cartItems , $price , $orderId , $date) {
        return $this->notify(new OrderSummeryMessage($this->first_name , $cartItems , $price , $orderId , $this->user , $date ));
    }
Jul
23
4 months ago
Activity icon

Replied to Ajax Request Not Work

Yes. I add it like this.

Activity icon

Replied to Ajax Request Not Work

Not work.

Jul
21
4 months ago
Activity icon

Started a new Conversation Ajax Request Not Work

Hi all,

I am trying to send ajax form request but when I click on the submit button my page is reloaded. And say "The POST method is not supported for this route. Supported methods: GET, HEAD."

Thus is my form

  <form id="user-update" class="form-horizontal form-label-left input_mask" action=""
                                                                          method="POST">
                                                                        @csrf
                                                                        <div class="col-md-6 col-sm-12 col-xs-12">
                                                                            <div class="form-group ">
                                                                                <label>Name</label>
                                                                                <input type="text" id="name"
                                                                                       class="form-control validation {{ $errors->has('name') ? ' is-invalid' : '' }}"
                                                                                       name="name"
                                                                                       value="{{ old('name') }}">
                                                                                <span class="invalid-feedback error"
                                                                                      role="alert"
                                                                                      style="display: none;">
                                                                                </span>
                                                                            </div>
                                                                        </div>
                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-default" onclick="location.reload();">Close</button>
                                                            <button type="submit" class="btn btn-success btn-send">Update user</button>
                                                        </div>
                                                        </form>

And this is my JS function

            e.preventDefault();
            $.ajax({
                url: base+'/profile/store',
                type: 'POST',
                data: new FormData(this),
                contentType: false,
                cache: false,
                processData: false,
                beforeSend: function () {
                    $('.btn-send').html('Updating...').attr('disabled', true).addClass('disabled');
                    $('.btn-send').attr('disabled', true).addClass('disabled');
                },
                success: function (data) {
                    if (data.success) {
                        swal({
                            title: "Good job!",
                            text: data.success,
                            icon: "success",
                        });
                        $('#user-update').each(function () {
                            this.reset();
                        });
                    } else {
                        printErrorMsg(data.error);
                    }
                },
                complete: function () {
                    $('.btn-send').html('Update user').attr('disabled', false).removeClass('disabled');
                    $('.btn-send').attr('disabled', false).removeClass('disabled');
                }
            });
        });
        function printErrorMsg (msg) {
            $(".print-error-msg").find("ul").html('');
            $(".print-error-msg").css('display','block');
            $.each( msg, function( key, value ) {
                $(".print-error-msg").find("ul").append('<li>'+value+'</li>');
            });
        }

This my controller method

public function store(Request $request)
    {
        $validate = Validator::make($request->all(), [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
        ]);

        if ($validate->fails()){
            return response()->json(['error'=> $validate->errors()->all()]);
        }
    }
``

This is my route

Route::post('/profile/store', '[email protected]');


Can anyone help me to resolve this? Where I am wrong?
Jul
17
4 months ago
Activity icon

Started a new Conversation Error SQLSTATE[22007]: Invalid Datetime Format: 1366 Incorrect String Value: '\xC5\x8D-tan...' In Laravel

Hi all,

I got above error "SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xC5\x8D-tan...' in laravel" when insert strings. anyone can explain me, whay that error is getting. My column Collation is utf8mb4_unicode_ci

Jul
06
5 months ago
Activity icon

Replied to Cannot Load Image To Pdf With Barryvdh/laravel-dompdf

Is there any way to make the grid as bootstrap grid to this pdf file?

Activity icon

Replied to Cannot Load Image To Pdf With Barryvdh/laravel-dompdf

When I execute it as a php blade file, It's load correctly with an image. But cannot generate pdf with an image it does not work.

Activity icon

Started a new Conversation Cannot Load Image To Pdf With Barryvdh/laravel-dompdf

Hi everyone,

I am trying to generate pdf attached to my logo. but it does not work. I got the below error. But If i trying to generate pdf without image its generate properly. Also, bootstrap 4 grid does not work properly

Error. " Maximum execution time of 60 seconds exceeded"

Controller method

public function index()
    {
        $pdf = PDF::loadView('quotations.index');
        //$pdf->setPaper('A4', 'portrait');
        return $pdf->download('quotation.pdf');
        
    }

my view file code

<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    <title>Quotation N0: </title>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-6">
            <h3 class="text-danger">Quotation</h3>
        </div>
        <div class="col-6">
            <img src="{{ asset('imgs/logo.png')}}" alt="BTS" width="100">
        </div>
    </div>
</div>

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>

Jul
03
5 months ago
Activity icon

Replied to Trying To Get Property Of Non-object

@RAS1212 - Thanks. It's work

Activity icon

Replied to Trying To Get Property Of Non-object

@NAKOV - I have got the same error. I don't know why. Because my other relationships are working fine.

Activity icon

Replied to Trying To Get Property Of Non-object

@NAKOV - The same error got. Any idea?

Activity icon

Started a new Conversation Trying To Get Property Of Non-object

Hi,

I have got "Trying to get property of non-object" error when I get the user name from ORM. My code like below,

User model method

public function Quotation(){
        return $this->hasMany('App\Quotation');
    }

Quotation model method

 public function users(){
        return $this->belongsTo('App\User', 'user_id');
    }

Quotation controller method

 public function index()
    {
        $title = "All Projects";
        $data = Quotations::all();
        return view('projects.index', compact('title','data'));
    }

View file

<table id="datatable" class="table">
                                <thead>
                                <tr>
                                    <th>Quotation No</th>
                                    <th>Started Date</th>
                                    <th>Total Cost</th>
                                    <th>Created by</th>
                                    <th>Edit</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($data as $item)
                                    <tr>
                                        <td>{{ $item->q_number}}</td>
                                        <td>{{$item->created_at}}</td>
                                        <td>{{$item->total_cost}}</td>
                                        <td>{{$item->users->name}}</td>
                                        <td><a class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-{{$item->id}}"><i class="fa fa-pencil-square-o"></i></a></td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>

Issue is $item->users->name , Its come from User model with above relationship

Activity icon

Replied to How To Get Sum From Inside The Foreach

@SNAPEY - Thanks. Your answer very simple and its best.

Jul
02
5 months ago
Activity icon

Started a new Conversation How To Get Sum From Inside The Foreach

Hi everyone,

I am passing cost array like

 <input name="cost[]" />

in my method I do like below to save it to database

$itemsArray = array();
        $i = 1;
        foreach($request['cost'] as $cost){
            $itemsArray[$i] = $cost;
            $i++;
        }

$data = new model;
$data->cost =  json_encode($itemsArray);

I wan to get sum of all these cost array. Anyone have idea about how to do this calculation ?

Jun
16
5 months ago
Jun
12
6 months ago
Activity icon

Started a new Conversation Instagram Feed Cannot Get With Vinkla Instagram Package.

Hello everyone,

I am trying to get instagram feed data user Vinkla Instagram package. I have followed steps that they given, It as followed.

 $instagram = new Instagram('my_access_token');
        $instagram->media(['count' => 5]);
       dd($instagram);

But i didn't get any data. I got below result.

Instagram {#202 ▼ #accessToken: "my_access_token" #httpClient: Client {#197 ▶} #requestFactory: GuzzleMessageFactory {#213} #request: null }

Can anyone help me to resolve this thing.