adnan483

Experience

1,150

0 Best Reply Awards

  • Member Since 7 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

30th March, 2018

adnan483 left a reply on Using FPDF In Laravel 5.5? • 3 months ago

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).

12th March, 2018

adnan483 started a new conversation Deleting Photo From Article (pivot Table) • 4 months ago

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.

7th March, 2018

adnan483 started a new conversation Requested URL Not Found On Shared Hosting • 4 months ago

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?

13th February, 2018

adnan483 left a reply on Mailgun Not Sending Email • 5 months ago

It's view, first parametar of

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

adnan483 started a new conversation Mailgun Not Sending Email • 5 months ago

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)

adnan483 left a reply on Use Data From Pivot Table • 5 months ago

@bobbybouwmann I'm accessing data with

$projekti->slike

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

adnan483 started a new conversation Use Data From Pivot Table • 5 months ago

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

12th February, 2018

adnan483 started a new conversation Uploading Multiple Files "Invalid Argument Supplied For Foreach()" • 5 months ago

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>

adnan483 started a new conversation Add Multiple Photos To Article • 5 months ago

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

17th January, 2018

adnan483 started a new conversation Choose Current Year By Java Script • 6 months ago

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>

14th January, 2018

adnan483 started a new conversation Is Possible To Use Where() And WhereBetween() • 6 months ago

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

$nalozi = Nalog::whereBetween('rokisporuke',[request('od'),request('do')])->orderBy('rokisporuke', 'ASC')->get();

12th January, 2018

adnan483 left a reply on Put Data From Database To Chart • 6 months ago

@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?

adnan483 started a new conversation Put Data From Database To Chart • 6 months ago

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>

adnan483 left a reply on Upload Validation Issue (Error Communication) • 6 months ago

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;

11th January, 2018

adnan483 left a reply on Backup Doesn't Work • 6 months ago

@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');

adnan483 left a reply on Backup Doesn't Work • 6 months ago

@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?

10th January, 2018

adnan483 left a reply on Backup Doesn't Work • 6 months ago

@Snapey Laravel Framework 5.4.36

adnan483 left a reply on Backup Doesn't Work • 6 months ago

of course, @BezhanSalleh I did composer update, composer dump-autoload, created new 5.4. project and copy resources, public folder, and app folder and again same problem

adnan483 left a reply on Backup Doesn't Work • 6 months ago

No, I'm still on 5.6, this is after I remove backup from composer

adnan483 left a reply on Backup Doesn't Work • 6 months ago

@Snapey I did that and just have this:

(1/1) FatalErrorException syntax error, unexpected ':', expecting ';' or '{' in Inflector.php (line 265)

adnan483 left a reply on Backup Doesn't Work • 6 months ago

@Snapey I tried spatie backup right now and now have bigger problem, can open application, just see this Class 'Backup\BackupServiceProvider' not found, I remove it from vendor and still same problem

8th January, 2018

adnan483 left a reply on Backup Doesn't Work • 6 months ago

@Snapey I tried that but still same message: Database 'test' cannot be dumped'

7th January, 2018

adnan483 left a reply on Backup Doesn't Work • 6 months ago

@Yama Everything is ok with .env file, I'm using it normally for other things, but still not working.

adnan483 left a reply on Backup Doesn't Work • 6 months ago

@Yama The same problem again, it shows database backed up but it's not, I tried as return \Artisan::output() and got this 'Database 'test' cannot be dumped'

adnan483 left a reply on Backup Doesn't Work • 6 months ago

@Yama Nothing, there is no error. when I use dd() it shows only 0.

adnan483 started a new conversation Backup Doesn't Work • 6 months ago

I'm using paulvl/backup backup package, when I try to use it from Terminal:

php artisan backup:mysql-dump

it works perfect and store it inside of /storage/app/backups but when try to use it from controller

public function store(){
        Artisan::call('backup:mysql-dump');
    }

it doesn't work?

6th January, 2018

adnan483 left a reply on Download File • 6 months ago

My code doesn't work, I'm asking for help :) I'm getting error, file not found.

adnan483 started a new conversation Download File • 6 months ago

How to download file:

@foreach($cjenovnici as $cjenovnik)
    <tr>
        <td>{{$cjenovnik->file}}</td>
        <td><a href="{{response()->download(public_path() . $cjenovnik->file)}}" download class="btn btn-primary">Preuzmi</a></td>
    </tr>
@endforeach 

4th January, 2018

adnan483 started a new conversation Query Builder • 6 months ago

How to make this query with QueryBuilder or what?

SELECT duznici_2018.*,sum(rate_2018.rata) as ukupno FROM duznici_2018 LEFT JOIN rate_2018 ON duznici_2018.duznikID=rate_2018.duznikID  GROUP BY duznikID DESC

2nd January, 2018

adnan483 left a reply on Can't Access Value From Model • 6 months ago

Thank you, I changed that kupac to something else and now it works normally :)

adnan483 started a new conversation Can't Access Value From Model • 6 months ago

Hi, I have problem to access value from model:

Here is my model code :

class Reklamacija extends Model
{
    protected $fillable = ['user_id','nalog_id','kupac_id','mjesto','kontakt','stolarijauradjena','kvar','utrosenimaterijal','reklamacijaodradjena','oddo','radsat','cijenaposatu','iznospopravka','firmasnosi','serviser1','serviser2','napomena','kupac','reklamacijuzavrsio','zavrsena','godina'];
    //
    public function user(){
        return $this->belongsTo('App\User');
    }
    public function kupac(){
        return $this->belongsTo('App\Kupac');
    }

Here is my migration code:

Schema::create('reklamacijas', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id');
            $table->integer('nalog_id');
            $table->integer('kupac_id');
            $table->text('mjesto');
            $table->text('kontakt');
            $table->string('stolarijauradjena');
            $table->text('kvar');
            $table->text('utrosenimaterijal')->nullable();
            $table->date('reklamacijaodradjena')->nullable();
            $table->string('oddo')->nullable();
            $table->string('radsat')->nullable();
            $table->float('cijenaposatu')->nullable();
            $table->float('iznospopravka')->nullable();
            $table->float('firmasnosi')->nullable();
            $table->string('serviser1')->nullable();
            $table->string('serviser2')->nullable();
            $table->text('napomena')->nullable();
            $table->string('kupac')->nullable();
            $table->string('reklamacijuzavrsio')->nullable();
            $table->boolean('zavrsena')->default(0);
            $table->string('godina');
            $table->timestamps();
        });

Here is my Controller code:

public function index(){
        $nezavrsene = Reklamacija::where('zavrsena',0)->get();
        $zavrsene = Reklamacija::where('zavrsena',1)->get();
        return view('reklamacije.index', compact('nezavrsene','zavrsene'));
    }

Both of these $nezavrsene and $zavrsene need value from kupacs table like: $nezavrsene->kupac->imeprezime but every time I get error Trying to get propery of non-object??

1st January, 2018

adnan483 left a reply on Trying To Get Property Of Non-object • 6 months ago

thank you a lottt :)

adnan483 started a new conversation Trying To Get Property Of Non-object • 6 months ago

I have problem with pulling data from DB, here is my code?

class ReklamacijaController extends Controller
{
    //
    public function index(){
        $nezavrsene = Reklamacija::where('zavrsena',0)->get();
        return view('reklamacije.index', compact('nezavrsene'));
    }
}

and

<div class="col-md-12">
                    @if($nezavrsene)
                    <table class="table table-hover">
                    <tr>
                        <th>Broj Rek.</th>
                        <th>Br.Naloga</th>
                        <th>Kupac</th>
                        <th>Lokacija</th>
                        <th>Kontakt</th>
                        <th>Kvar</th>
                        <th>Rek.Napravio</th>
                        <th>Kreirano</th>
                        <th>Kupac čeka</th>
                        <th>Završi</th>
                        <th>Pregled</th>
                    </tr>
                    
                    @foreach ($nezavrsene as $nezavrsena)
                    
                    <tr>
                        <td>{{ $nezavrsena->id }}</td>
                        <td>{{ $nezavrsena->nalog_id }}</td>
                        <td>{{ $nezavrsena->kupac->imeprezime }}</td>
                        <td>{{ $nezavrsena->lokacija }}</td>
                        <td>{{ $nezavrsena->kontakt }}</td>
                        <td>{{ $nezavrsena->kvar }}</td>
                        <td>{{ $nezavrsena->user->name }}</td>
                        <td>{{ $nezavrsena->created_at->format('d.m.Y') }}</td>
                        <td></td>
                    </tr>

                    @endforeach
                    @endif

31st December, 2017

adnan483 started a new conversation Using FPDF In Laravel 5.5? • 6 months ago

Hi, I'm trying to use FPDF in my project, I use setasign/fpdf from Git, but every time when I try to open it, it shows tons of unknown data.

Here is my code:

$pdf = new \setasign\Fpdi\Fpdi(); $pdf->AddPage(); $pdf->setSourceFile('dokumenti/garancija.pdf'); $tplIdx = $pdf->importPage(1); // use the imported page and place it at position 10,10 with a width of 100 mm $pdf->useTemplate($tplIdx, 5, 5, 205);

// now write some text above the imported page $pdf->SetFont('Times'); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(25, 75); $pdf->Write(0, 'Test'); $pdf->SetXY(25, 80); $pdf->Write(0, 'Test'); $pdf->SetXY(19, 55); $pdf->Write(0, 'Test'); $pdf->Output();

28th December, 2017

adnan483 started a new conversation If Exist Take Id If Not Create New Client • 6 months ago

Hi, I'm looking solution for my problem, I need to get clients from database while typing(to pick up right one), and if client doesn't exist must create new one, if exist only take his user id and put it in order.

21st December, 2017

adnan483 left a reply on Create Tables And Migrate By Button? • 7 months ago

I made application for one company and they have a lot data like working order, complaints, etc.. and they want to start with new table every new year (in 2018 new table for working order and keep old data in working_orders_2017), I did all that with PHP but is possible to do that by Laravel?

adnan483 started a new conversation Create Tables And Migrate By Button? • 7 months ago

I have project in PHP and want to move it to Laravel and before I start I want to know is possible to create tables for next year by one button click?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.