adnan483

adnan483

Member Since 1 Year Ago

Experience Points
2,040
Total
Experience

2,960 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-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 1
2,040 XP
Oct
12
6 days ago
Activity icon

Started a new conversation Two Middleware For One Group Of Routes

I have this code in routes

Route::group(['middleware' => 'admin','financial '], function() {
//some routes
}

How can I use group to give access to both type of users, with this code, user must be admin and financial, but I want to give access to users who are financial but not admins ?

Oct
11
1 week ago
Activity icon

Replied to Executing Artisan Command

I try like this

Route::get('/echo3/backup',function(){
      Artisan::call('echo3:backup -vvv');
      return redirect()->back();
});

and still same error

Activity icon

Replied to Executing Artisan Command

I tried a lot of them and have same problem, work from terminal normally and problem with schedule or backup with route, this one is right now

https://github.com/sarfraznawaz2005/backupmanager


Activity icon

Replied to Executing Artisan Command

I did that and got

array:2 [▼
  "f" => false // I think this is for files
  "d" => false // for database
]
Activity icon

Replied to Executing Artisan Command

I got this message:

"Database Backup Failed"
Activity icon

Replied to Executing Artisan Command

Here is Command

class MyAppBackup extends Command
{
    protected $signature = 'myapp:backup';
    protected $description = 'Command description';

    
    public function __construct()
    {
        parent::__construct();
    }

    
    public function handle()
    {
      $result = BackupManager::createBackup();

      // set status messages
      if ($result['f'] === true) {
          $message = 'Backup uspješno završen';
          $this->info($message);
          Log::info($message);
      } else {
          if (config('backupmanager.backups.files.enable')) {
              $message = 'Backup nije uspio!';
              $this->error($message);
              Log::error($message);
          }
      }

      if ($result['d'] === true) {
          $message = 'Kopija baze podataka uspješno napravljena!';
          $this->info($message);
          Log::info($message);
      } else {
          if (config('backupmanager.backups.database.enable')) {
              $message = 'Database Backup Failed';
              $this->error($message);
              Log::error($message);
          }
      }
    }
}
Activity icon

Replied to Executing Artisan Command

Yeah, It does the same, just generates empty file, but from terminal works fine with same command.

Activity icon

Replied to Executing Artisan Command

Schedule:run will call that job, but the problem is when I use it from Terminal it generate backup file with all tables and data, but executing task from application generate empty file

Activity icon

Started a new conversation Executing Artisan Command

Hi, all. I have problem for executing artisan command, when I use this command in Terminal it works as expected, but calling it from click on button it doesnt work:

//Routes
Route::get('/myapp/backup',function(){
    Artisan::call('schedule:run');
    return redirect()->back();
});

//Kernel
protected $commands = [
        //
        Commands\MyAppBackup::class,
    ];

protected function schedule(Schedule $schedule)
 {
        $schedule->command('myapp:backup')->everyMinute();
 }

writing this to terminal works fine:

php artisan myapp:backup
Jul
09
3 months ago
Activity icon

Replied to Button Not Responding On Update

Thank you for your response, that code works fine, problem was something with jquery, which prevent button to be clicked.

Activity icon

Started a new conversation Button Not Responding On Update

I have problem with updating, when I click on button nothing happened. controller

public function update(Request $request, $id){
    $year = Year::latest()->first();
    DB::table('nalogs')
          ->where('id', $id)
          ->update(['reported' => 1]);
    return redirect()->back();
  }

view

<form method="post" action="/montage/edit/{{$n1->id}}">
 @method('PATCH')
@csrf
<button type="submit" class="btn btn-outline-primary">Report</button>
 </form>

route

Route::post('/montage/edit/{id}','[email protected]');

Jun
23
3 months ago
Activity icon

Replied to Laravel Testing

@TRAY2 - thank you Tray, that's it!

Activity icon

Replied to Laravel Testing

@FUTUREFUTURE - There is no error, all tests passed, but on every run I have new company added, but non of them is edited or deleted.

Jun
22
3 months ago
Activity icon

Started a new conversation Laravel Testing

hi, I'm new to testing, and I have there three tests, but they are not working, what is wrong here?

/** @test */
  public function can_add_new_company()
    {
        $data = [
            'name' => 'Apple',
            'email' => '[email protected]',
            'website' => 'www.apple.com'
        ];
        $this
            ->post(route('company.store', $data))
            ->assertStatus(302);
    }

for editing

/** @test */
    public function can_update_the_company()
    {
        $company = factory(Company::class)->create();
        $data = ['name' => 'Edited NAME!'];
        $this
            ->put(route('company.update', $company->id), $data)
            ->assertStatus(302);
    }

and for deleting

/** @test */
    public function can_delete_the_company()
    {
        $company = factory(Company::class)->create();
        $this
            ->delete(route('company.destroy', $company->id))
            ->assertStatus(302);
    }

Dec
20
9 months ago
Activity icon

Started a new conversation Sending Email With Mailgun - Undefined Variable

public function send(Request $request,$email)
    {
      $advert = Advert::find($request->adverts);
      $maildata = [
        'advert' => $advert
      ];
      Mail::send('email.reklama',$maildata, function($message){
        $message->to($email, 'User')->subject('Email');
      });
      return redirect()->back();
    }

I have problem with this line $message->to($email, 'User')->subject('Email');, undefined variable $email, I tried $request->email, but it doesn't work too. Is possible to use variable on that place?

Nov
24
10 months ago
Activity icon

Started a new conversation Filter With Laravel And Ajax

is possible to make filter on this way with laravel and ajax: Ajax code:

function filter_data(){
                $('.filter_data').html('<div id="loading"></div>');
                var minimum_price = $('#hidden_minimum_price').val();
                var maximum_price = $('#hidden_maximum_price').val();
                var brand = get_filter('brand');
                var size = get_filter('size');
                var color = get_filter('color');
                var cat = $('#cat').val();
                var orderby = $('.orderby').val();
                $.ajax({
                        headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        url: '/products',
                        type: 'get',
                        data: {minimum_price:minimum_price, maximum_price:maximum_price, brand:brand, size:size, orderby:orderby,color:color, cat:cat},
                        success:function(data){
                            $('.filter_data').html(data);
                        }
                });
            }

Controller

public function sviproizvodi(){
       $products = DB::table('products as p')->join('product_attributes as pa','p.id','=','pa.product_id')->select('p.*','pa.size')->where('p.status', 1)->groupBy('p.id');

       if (isset($request->minimum_price) && isset($request->maximum_price)) {
           $products->whereBetween('p.price', [$request->minimum_price, $request->maximum_price]);
       }
       if (isset($request->brand)) {
           $products->whereIn('p.brand_id', $request->brand);
       }
       if (isset($request->cat)) {
           $products->whereIn('p.category_id', $request->cat);
       }
       if (isset($request->orderby)) {
         if ($request->orderby == "standardno") {
           $products->orderBy('p.id','desc');
         }
         if ($request->orderby == "istaknute") {
           $products->orderBy('p.featured','desc');
         }
         if ($request->orderby == "novi") {
           $products->orderBy('p.id','desc');
         }
         if ($request->orderby == "cijena1") {
           $products->orderBy('p.price','asc');
         }
         if ($request->orderby == "cijena2") {
           $products->orderBy('p.price','desc');
         }
         if (isset($request->size)) {
             $products->whereIn('pa.size', $request->size);
         }
         if (isset($request->color)) {
             $products->whereIn('pa.color', $request->color);
         }
       }
      $proizvodi = $products->paginate(15);
       return view('products',compact('proizvodi'));
    }
Nov
08
11 months ago
Activity icon

Started a new conversation Joining Two Tables

I have this code to left join two tables but problem is I have listed products with same image times as sizes for that product in another table, I need each product only once listed

$products = DB::table('products')->join('product_attributes', 'products.id','=','product_attributes.product_id')->select('products.*', 'product_attributes.*')->where('products.status', 1);
        if (isset($request->minimum_price) && isset($request->maximum_price)) {
            $products->whereBetween('products.price', [$request->minimum_price, $request->maximum_price]);
        }
        if (isset($request->brand)) {
            $products->whereIn('products.brand_id', $request->brand);
        }
        if (isset($request->size)) {
            $products->whereIn('product_attributes.size', $request->size);
        }
        $result = $products->get();
Activity icon

Replied to Write Complex Query With Eloquent

@cronix I tried it like this

$products = DB::table('products')->join('product_attributes', 'products.id','=','product_attributes.product_id')->select('products.*', 'product_attributes.*')->where('products.status', 1);
        if (isset($request->minimum_price) && isset($request->maximum_price)) {
            $products->whereBetween('products.price', [$request->minimum_price, $request->maximum_price]);
        }
        if (isset($request->brand)) {
            $products->whereIn('products.brand_id', $request->brand);
        }
        if (isset($request->size)) {
            $products->whereIn('product_attributes.size', $request->size);
        }
        $result = $products->get();

but problem is I have products as many as sizes in attributes table, and distinct is not working in this case

Activity icon

Replied to Write Complex Query With Eloquent

@cronix I have in another table sizes and colors is possible to add that table in that query to? Same thing like brand but only size and color from product-stock

Nov
06
11 months ago
Activity icon

Started a new conversation Write Complex Query With Eloquent

Is possible to do this with query builder:


$query = "SELECT * FROM products WHERE status = 1";

some if statement and concat 

$query .= "AND product_price BETWEEN $request->minimum AND $request->maximum";

again some if and

$brand_filter = implode("','",$request->brand);
$query .= "AND product_brand IN('". $brand_filter."')";

Activity icon

Replied to Get All Sizes And Their Count

@tisuchi

I solve it on this way

$sizes = DB::table('product_attributes')->select(DB::raw('count(*) as totalPerSize, size'))

Is possible to do this with query builder:

$query = "SELECT * FROM products WHERE status = 1";

some if statement and concat 

$query .= "AND product_price BETWEEN $request->minimum AND $request->maximum";

again some if and

$brand_filter = implode("','",$request->brand);
$query .= "AND product_brand IN('". $brand_filter."')";
Activity icon

Started a new conversation Get All Sizes And Their Count

Is possible to get all sizes and their count on this way?

$sizes = ProductAttributes::distinct('size')->get();
Nov
03
11 months ago
Activity icon

Started a new conversation Reading Cookies On Load

I have problem with reading cookies which I have this code in AppService Provider

public function register()
    {
        //
        view()->composer('*', function($view){
            if (empty(Cookie::get('Currency'))) {
              Cookie::queue('Currency', 1, 100000);
              Cookie::queue('CurrencySign', '$',100000);
            }
            $currency = Cookie::get('Currency');
            $sign = Cookie::get('CurrencySign');
            $view->with('valuta',$currency);
            $view->with('sign',$sign);
        });
    }

problem is when I open page first time all values are 0, and after refresh everything works fine, how can I solve this?

Oct
09
1 year ago
Activity icon

Started a new conversation Too Few Arguments To Function

hi, I have problem with update code:

public function update(Request $request, $id){
        $user = User::find($id);
          $user->name = $request['name'];
          $user->address = $request['address'];
          $user->city = $request['city'];
          $user->state = $request['state'];
          $user->postcode = $request['postcode'];
          $user->mobile = $request['mobile'];
          $user->password = $request['password'];
        $user->update();
        return redirect()->back();
    }

and

<div class="container" style="margin-top:70px;margin-bottom:50px">
                    {!! Form::model($korisnik,['method'=>'PATCH','action'=>['[email protected]',$korisnik->id]]) !!}
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">Ime:</label>
                            <div class="col-lg-9 effect1">
                                                            {!! Form::text('name',null,['class'=>'s-text7 w-full p-b-5','placeholder'=>'Unesite ime i prezime...']) !!}
                                                            <span class="effect1-line"></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">Adresa:</label>
                            <div class="col-lg-9 effect1">
                              {!! Form::text('address',null,['class'=>'s-text7 w-full p-b-5']) !!}
                                                            <span class="effect1-line"></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">Grad:</label>
                            <div class="col-lg-9 effect1">
                              {!! Form::text('city',null,['class'=>'s-text7 w-full p-b-5']) !!}
                                                            <span class="effect1-line"></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">Regija:</label>
                            <div class="col-lg-9 effect1">
                                {!! Form::text('state',null,['class'=>'s-text7 w-full p-b-5']) !!}
                                                                <span class="effect1-line"></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">Država:</label>
                            <div class="col-lg-9">
                                {!! Form::select('country', ['BIH' => 'Bosna i Hercegovina'], null, ['class'=>'form-control','placeholder' => 'Odaberite državu...']); !!}
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">Broj pošte:</label>
                            <div class="col-lg-9 effect1">
                                {!! Form::text('postcode',null,['class'=>'s-text7 w-full p-b-5']) !!}
                                                                <span class="effect1-line"></span>
                            </div>
                        </div>
                                                <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">Broj telefona:</label>
                            <div class="col-lg-9 effect1">
                                {!! Form::text('mobile',null,['class'=>'s-text7 w-full p-b-5']) !!}
                                                                <span class="effect1-line"></span>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">Lozinka</label>
                            <div class="col-lg-9 effect1">
                                {!! Form::password('password', ['class' => 's-text7 w-full p-b-5']); !!}
                                                                <span class="effect1-line"></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">Potvrdi lozinku</label>
                            <div class="col-lg-9 effect1">
                                {!! Form::password('confirm_password', ['class' => 's-text7 w-full p-b-5']); !!}
                                                                <span class="effect1-line"></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label"></label>
                            <div class="col-lg-9">
                                {!! Form::submit('Spremi promjene!',['class'=>'btn btn-primary btn-large pull-right']); !!}
                            </div>
                        </div>
                    {!! Form::close() !!}
    </div>
Oct
05
1 year ago
Activity icon

Replied to Operating With Dates

@Cronix that's it, works perfect :) thank you

Activity icon

Started a new conversation Operating With Dates

<div class="block2-img wrap-pic-w of-hidden pos-relative {{ ($product->created_at->diffForHumans()<7) ? 'block2-labelnew' : '' }}">

I want to show for one week icon NEW over products. Is it possible with some date function to count days?

Aug
19
1 year ago
Activity icon

Replied to Html Collective Select - Unsupported Operand Types

Combinations from controller doesn't work, but I solve it on this way:

<div>
{!! Form::select('parent_id', [''=>'Glavnakategorija']+App\Category::where(['parent_id'=>0])->pluck('name','id')->all(),null,['class'=>'form-control show-tick']) !!}
</div>
Activity icon

Replied to Html Collective Select - Unsupported Operand Types

It doesn't work, I tried that.

Activity icon

Started a new conversation Html Collective Select - Unsupported Operand Types

I have problem to fill select from database, here is my view:

  {!! Form::select('parent_id', [''=>'Glavna kategorija']+$categories,null,['class'=>'form-control']) !!}

and controller code:

$categories = Category::where(['parent_id'=>0])->pluck('name','id')->all();
return view('admin.category',compact('categories'));
Aug
18
1 year ago
Activity icon

Replied to ECommerce From Scratch?

I'm ready for that but for beginning I need managing products and orders, because this will be for long long time..

Aug
17
1 year ago
Activity icon

Replied to ECommerce From Scratch?

wow, It's second option, I need half of it for beginning, but I have time until january.

Activity icon

Replied to ECommerce From Scratch?

Yeah it is huge, client want custom shop and want me for long term for that, can you suggest me any migrations for it, because I hate when I make migration,and forms add, edit etc.. and need to add something to cover some option.

Activity icon

Started a new conversation ECommerce From Scratch?

Hello all, I'm wondering is good to build eCommerce website with Laravel framework? is it enough secured and is possible to add payment with paypal and credit cards? and is there any good database schema to start with?

Mar
30
1 year ago
Activity icon

Replied to Using FPDF In Laravel 5.5?

Yeah of course, the problem is FPDF is built for PHP 5.*, it doen't work in PHP 7, and in some cases it works from web.php(routes) not in controllers(show method).

Mar
12
1 year ago
Activity icon

Started a new conversation Deleting Photo From Article (pivot Table)

I need help to delete image from pivot table

Here is my view:

<div class="col-md-6">
            @foreach($projekat->slike as $slika)

            <div class="card" style="width: 16rem;">
              <img class="card-img-top" src="{{ $slika->file }}" width="250">
              <div class="card-body">
               <form method="POST" action="/obrisiSliku">
                    <input type="hidden" name="projekatID" value="{{ $projekat->id }}"> 
                    <input type="hidden" name="slikaID" value="{{ $slika->id }}">
                    <input class="btn btn-danger" type="submit" value="Obriši">
               </form>
              </div>
            </div>
 
            @endforeach

Here is my route:

Route::post('/obrisiSliku', function(){
    $projekatID = request('projekatID');
    $slikaID = request('slikaID');
    $projekat = Projekti::find($projekatID);
    $projekat->slike()->detach($slikaID);
    return redirect()->back();
});

I'm getting only: The page has expired due to inactivity.

Please refresh and try again.

Mar
07
1 year ago
Activity icon

Started a new conversation Requested URL Not Found On Shared Hosting

I uploaded my project on shared hosting, and everything works fine when I put my public folder in public_html folder, but I want to put my project into /public_html/isystem and then every route is not found. I changed path in index.php and it opens login page, but all other are not found?

Feb
13
1 year ago
Activity icon

Replied to Mailgun Not Sending Email

It's view, first parametar of

Mail::send('email',$data,function($message){});

Here is code from that view:

<!DOCTYPE html>
<html>
<head>
    <title>Email</title>
</head>
<body>

    <h1>{{$ime}}</h1>
    <h1>{{$email}}</h1>
    <h1>{{$brojtelefona}}</h1>

    <p>{{$message}}</p>

</body>
</html>
``
Activity icon

Started a new conversation Mailgun Not Sending Email

I'm trying to use Mailgun for emails, here is my route code:

Route::post('/kontakt',function(){
    $data = [
        'ime' => request('ime'),
        'email' => request('email'),
        'brojtelefona' => request('brojtelefona'),
        'message' => request('message')
    ];
    Mail::send('email',$data,function($message){
        $message->to('[email protected]','Test')->subject('Kontakt forma ');
    });
});

Here is data from env file:

MAIL_DRIVER=smtp
MAILGUN_DOMAIN=sandbox7fca0a94dd514107aff835**********
MAILGUN_SECRET=key-46ea918f84ec3***************

I'm always getting error:

"htmlspecialchars() expects parameter 1 to be string, object given (View: /Users/code/kgr/resources/views/email.blade.php)
Activity icon

Replied to Use Data From Pivot Table

@bobbybouwmann I'm accessing data with

$projekti->slike

but how to get only first one because I have a few photos for each project?

Activity icon

Started a new conversation Use Data From Pivot Table

I have data in pivot table

Here is my controller

 public function show($id)
    {
        //
        $projekat = Projekti::find($id);
        return view('project',compact('projekat'));
    }

Here are models:

public function slike() {
    return $this->belongsToMany('App\Slike'); 
    }

and

public function projekti() {
    return $this->belongsToMany('App\Projekti'); 
}

Here is data from table

id  projekti_id slike_id    
1        1                        1 
2        1                        2 
3        1                        3 

Now I want to load them into view page

Feb
12
1 year ago
Activity icon

Started a new conversation Uploading Multiple Files "Invalid Argument Supplied For Foreach()"

I'm trying to upload multiple photos but have problem with "Invalid argument supplied for foreach()" Here is my controller:

 public function store(Request $request)
    {
        //
        $input = request()->all();
        foreach($request->file('slike') as $file) {
            $name = time() . $file->getClientOriginalName();
            $file->move('projekti', $name);
            $photo = Slike::create(['file'=> $name]);
            $input['slike'] .= $photo->id . ',';
        }
        Projekti::create($input);
    }

View:

            <div class="form-group">
            {!! Form::file('slike[]', ['multiple' => 'multiple']); !!}
            </div>
            <div class="form-group">
            {!! Form::submit('Spremi',['class'=>'btn btn-primary btn-block']) !!}
            </div>
Activity icon

Started a new conversation Add Multiple Photos To Article

I'm trying to upload a few photos to some article, but have problem with it..

Here is my table:

        $table->increments('id');
            $table->string('naziv')->nullable();
            $table->string('klijent')->nullable();
            $table->string('lokacija')->nullable();
            $table->string('povrsina')->nullable();
            $table->string('godina')->nullable();
            $table->string('vrijednost')->nullable();
            $table->text('opis')->nullable();
            $table->text('kategorija');
            $table->string('slike')->nullable();
            $table->timestamps();

I have pivot table too

       Schema::create('projekti_slike', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('projekti_id');
            $table->integer('slike_id');
            $table->timestamps();
        });

and here is my controller

public function store(Request $request)
    {
        //
        if ($file = $request->file('file')) {
            # code...
            $name = time() . $file->getClientOriginalName();

            $file->move('projekti', $name);

            $photo = Slike::create(['file'=> $name]);

            $input['slike'] = $photo->id;

        }
        Projekti::create($input);
    }

I'm trying to do this using dropzoneJS for uploading pictures

Jan
17
1 year ago
Activity icon

Started a new conversation Choose Current Year By Java Script

I have year values in select box On top I added on div container onload="myFunction()"

{!! Form::select('godina', $nlg ,null,['class'=>'form-control','id'=>'test'],array('onchange' => 'myFunction()')) !!}

I want to load only data from this year on load and to load old data if user change select box value

<script>
function myFunction() {
  var input, filter, table, tr, td, i,strUser;
  input = document.getElementsById("test");
  strUser = input.options[input.selectedIndex].value;
  filter = strUser.value.toUpperCase();
  table = document.getElementById("myTable");
  tr = table.getElementsByTagName("tr");
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[10];
    if (td) {
      if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}
</script>
Jan
14
1 year ago
Activity icon

Started a new conversation Is Possible To Use Where() And WhereBetween()

I have query but need to add where() too:

$nalozi = Nalog::whereBetween('rokisporuke',[request('od'),request('do')])->orderBy('rokisporuke', 'ASC')->get();
Jan
12
1 year ago
Activity icon

Replied to Put Data From Database To Chart

@BezhanSalleh thank you for course, I'll check it. I found solution to fill chart but have one more problem, here is my query:

DB::select('SELECT sum(ukupni_dug) AS "ukupno",DAY(created_at) as dan FROM duznicis GROUP BY DAY(created_at) LIMIT 31;');

is possible to add after table name something like WHERE month = current_month because if I add value to 1. January and 1. February, it sum both values, I want to get report for specific month or last 31 day from today?

Activity icon

Started a new conversation Put Data From Database To Chart

I want to take from database all dates until today or last 15 days and sum of solds for each day and all that put in chart

Route::get('/admin/statistic',function(){
    $montly = DB::table('salles')
    ->select(DB::raw('SUM(total) as total'))
    ->groupBy(DB::raw('DAY(created_at) DESC'));
    return view('admin.statistika.index',compact('montly'));
});

I'm trying to put this inside of this chart can't echo anything from $montly

<script>
  Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
Chart.defaults.global.defaultFontColor = '#292b2c';
  var ctx = document.getElementById("poslovanje");
var myLineChart = new Chart(ctx, {
  type: 'line',
  data: {
    labels: ["Mar 1", "Mar 2", "Mar 3", "Mar 4", "Mar 5", "Mar 6", "Mar 7", "Mar 8", "Mar 9", "Mar 10", "Mar 11", "Mar 12", "Mar 13"],
    datasets: [{
      label: "Sessions",
      lineTension: 0.3,
      backgroundColor: "rgba(2,117,216,0.2)",
      borderColor: "rgba(2,117,216,1)",
      pointRadius: 5,
      pointBackgroundColor: "rgba(2,117,216,1)",
      pointBorderColor: "rgba(255,255,255,0.8)",
      pointHoverRadius: 5,
      pointHoverBackgroundColor: "rgba(2,117,216,1)",
      pointHitRadius: 20,
      pointBorderWidth: 2,
      data: [10000, 30162, 26263, 18394, 18287, 28682, 31274, 33259, 25849, 24159, 32651, 31984, 38451],
    }],
  },
  options: {
    scales: {
      xAxes: [{
        time: {
          unit: 'date'
        },
        gridLines: {
          display: false
        },
        ticks: {
          maxTicksLimit: 7
        }
      }],
      yAxes: [{
        ticks: {
          min: 0,
          max: 40000,
          maxTicksLimit: 5
        },
        gridLines: {
          color: "rgba(0, 0, 0, .125)",
        }
      }],
    },
    legend: {
      display: false
    }
  }
});
</script>

Activity icon

Replied to Upload Validation Issue (Error Communication)

You can try making new request

php artisan make:request UploadRequest

Here is Upload Request file:

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UploadRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //
            'avatar.*' => 'required|mimes:jpg,jpeg,png,bmp|max:800',
            'avatar.*.required' => 'Please upload an image',
            'avatar.*.mimes' => 'Only jpeg,png and bmp images are allowed',
            'avatar.*.max' => 'Sorry! Maximum allowed size for an image is 20MB'
        ];
    }
}

and then:

public function uploadAvatar(UploadRequest $request){

        if($request->hasFile('avatar')){
            $user = Auth::user();
            $input_data = $request->all();
            $image = $request->file('avatar');
            $filename = time() . '.' . $image->getClientOriginalExtension();
            $location = public_path('uploads/avatars/'. $filename);
            Image::make($image)->resize(300,300)->save($location);
            $user->avatar = $filename;
            $user->save();  
        }

        return redirect()
            ->route('profile.editavatar')
            ->with('info', 'Your avatar has been uploaded.');
    }

don't forget to import Request on top of controller:

use App\Http\Requests\UploadRequest;
Jan
11
1 year ago
Activity icon

Replied to Backup Doesn't Work

@BezhanSalleh I finally insert it into my project, but how to backup only database, I tried this but doesn't work?

 \Artisan::call('backup:run --only-db');
Activity icon

Replied to Backup Doesn't Work

@BezhanSalleh Thank you for advice, but I solve this problem deleting file services.php from bootstrap/cache, can you suggess me any other working backup?

Jan
10
1 year ago
Activity icon

Replied to Backup Doesn't Work

@Snapey Laravel Framework 5.4.36