adhik13th

adhik13th

Member Since 10 Months Ago

Experience Points
3,890
Total
Experience

1,110 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
1
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
3,890 XP
Feb
23
3 days ago
Activity icon

Started a new Conversation How Do You Add Variables To The Layout And Be Accessible On All Pages In Laravel?

I have some function to count data and want to showing at blade template . but i have a problem . this variable just working in 1 view and didnt not working in another view because i NOT parsing this variable on another view . So how i can set this variable count to all view ?

this is ilustration script :

 public function inventaris_baru()
{
    
    $user_id = null;
    $unit        = User::where('roles_id' , 1)->pluck('nama_unit', 'id'); 
    

    $alat    = Alat::with('users')
    ->where('jenis' ,'Alkes')
    ->where('is_active',  'false')
    ->orderBy('created_at', 'desc')->get();

    $count = $alat->count();

    return view('sarpras.inventaris_baru',['unit' => $unit, 'user_id' => $user_id ,'alat' => $alat ,'count' => $count]);
}

on this blade in layout

 <li class="nav-item">
                <a href="{{route('inventaris_baru')}}" class="nav-link">
                  <i class="far fa-circle nav-icon"></i>
                  <p>Inventaris Baru <span class="badge badge-danger right"> {{$count}} </span></p>
                </a>
              </li>

this $count only work in the view sarpras.inventaris_baru , how i can set global and can parse this on the layouts ?

can someone give me best way to this ?

Feb
20
6 days ago
Activity icon

Started a new Conversation How To Use Laravel With 3 Where Clause In Function?

i have a function to show data with 3 where clause condition . but this output is invalid . i have 4 data and just show 1 . this function like this :

public function alkes_user()
{
    $user_id = Auth::user()->id;

    $unit        = User::where('roles_id' , 1)->pluck('nama_unit', 'id'); 

    
    $alat    = Alat::with('users')
    ->where('jenis' ,'Alkes')
    ->where('user_id',  $user_id)
    ->where('is_active',  'true')
    ->orderBy('created_at', 'desc')->paginate(10);
    return view('users.alkes_user',['alat' => $alat , 'unit' => $unit  ]);
}

this data only showing 1 , but in database i have so many data . what wrong and how to solve this ? thanks you

Feb
14
1 week ago
Activity icon

Replied to How To Get Old Value On Select Option ?

i try change too

  <div class="form-group">
              <label>Status</label>  
                 <select class="form-control select2 select2-hidden-accessible" style="width: 100%;"  tabindex="-1"      
                             aria-hidden="true"
                             name="user_id" id="user_id" required>
                               @foreach($unit as $id => $nama_unit )
                               <option value="{{ $id }}" {{ old('user_id') == $id ? "selected" :""}}>{{ $nama_unit }}</option>
                               @endforeach
                         </select> 
                 <div class="help-block with-errors"></div>
             </div>

but this still didnt work .

i add

return view('sarpras.alkes',['user_id' => $user_id , 'unit' => $unit,'alat' => $alat  ])
    
    ->withInput();

but this is have error : Undefined offset: 0

Activity icon

Started a new Conversation How To Get Old Value On Select Option ?

i have filter form using select dropdown , but i cant get this old value after i submit this filter like input like type text . someone can help ?

<div class="form-group">
     <label>Status</label>  
        <select class="form-control select2 select2-hidden-accessible" style="width: 100%;" data-select2-id="1" tabindex="-1" aria-hidden="true"
                    name="user_id" id="user_id" required
                    >
                      @foreach($unit as $id => $nama_unit )
                      <option value="{{ $id }}">{{ $nama_unit }}</option>
                      @endforeach
                </select> 
        <div class="help-block with-errors"></div>
    </div>

i add my function controller :

public function search_filter_alkes(Request $request)
{   
    
    $unit        = User::where('roles_id' , 1)->pluck('nama_unit', 'id'); 
    $user_id = $request->user_id;
    
   
    $alat = Alat::with('users')->where('user_id',$user_id)
    ->where('jenis', 'Alkes')->
    get();

    session()->put('user_id',$user_id);

    return view('sarpras.alkes',['user_id' => $user_id , 'unit' => $unit,'alat' => $alat  ])
    
    ->with('user_id', $user_id)
    ;
  

}
Jan
26
1 month ago
Activity icon

Started a new Conversation Image Not Found Or Type Unknown

I have problem in my view image on PDF , in local its still work but on hosting this image cant dispay . My direktory folder like that

subdomain.web.com
   * assets
         +build
         +assets
          build 
          dist
 
          docs
 
          PDF
             -header.PNG  

i call image on my view like this :

 <header>
      <center>
          <img src="{{ public_path('assets/PDF/header.PNG')}}" style="width:720px;height:130px;"  >
      </center>
  </header>

i using public_path on my local in its still work , but on hosting its dont work.

i add storage_link on my route and run this

 Route::get('/foo', function () {
 Artisan::call('storage:link');
 });

but didnt work ? someone cant help or explain my miss code ? thank you

Jan
17
1 month ago
Activity icon

Started a new Conversation How To Retrieve Variable Function To Another Function In 1 Controller Laravel

i Have Search Function, this result of a search is table data and will be export by PDF. but this data on the search did not retrieve on the pdf page ( null ). I don't know what happens, I try to set load pdf in the search function, its show normally but I don't need this because this search function is not working again . you can see at this controller

public function search_range(Request $request)
{
    
    $ipsrs_id = Auth::user()->roles->ipsrs_id;
    $from = $request->from;
    $to = $request->to;
    $status = $request->status;

    if($status == 'Belum Selesai'){
        $new_status =['Tindakan Lanjutan' , 'Belum Dikerjakan' ,'Sedang Dikerjakan'];
    }
    
    elseif($status == 'Semua Laporan'){
        $new_status = ['Tindakan Lanjutan' , 'Belum Dikerjakan', 'Sedang Dikerjakan' , 'Selesai'];
    }
    else{
        $new_status = 'Selesai';
    }

    $stats = collect($new_status);

    $journal = Aduan::where('ipsrs_id',$ipsrs_id)->whereIn('status',$stats)
    ->whereBetween('created_at', [$request->get('from'), $request->get('to')])->get();

    

    return view('sarpras.journal_sarpras',['journal' => $journal ]);

}

public function getPDF(){

      $journal = $this->search_range('journal');// This line doesnt work

      $pdf = PDF::loadView('sarpras.file_pdf',['journal' => $journal]);
      return $pdf->stream('file.pdf');
      
    
}

but after i clicked button export pdf , this pdf not showing data and if i dd its showing null . whats wrong this ?

Jan
16
1 month ago
Activity icon

Replied to Export PDF Get Error ''Too Few Arguments To Function App\Http\Controllers\AdminController::getPDF(), 0 Passed And Exactly 1 Expected''

its have error

Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id

Activity icon

Replied to Export PDF Get Error ''Too Few Arguments To Function App\Http\Controllers\AdminController::getPDF(), 0 Passed And Exactly 1 Expected''

<a href#="/getPDF/{{$journal->id}}" class="btn btn-primary" target="_blank">CETAK PDF

on this line , why u use $journal->id ? this is have error if i use this, because i no need id for all table data ,i remove this $id , i get 404 not found ,

but if i remove all $Journal this pdf can load normally WITHOUT data

Jan
15
1 month ago
Activity icon

Started a new Conversation Export PDF Get Error ''Too Few Arguments To Function App\Http\Controllers\AdminController::getPDF(), 0 Passed And Exactly 1 Expected''

i create export pdf on MY TABLE data , so this table no need $id like i export profile user or anything , but in this table i have search date range in this table ,and this result will can export pdf by Dompdf .

this is my controller :

 public function journal_sarpras()
{
    $ipsrs_id = Auth::user()->roles->ipsrs_id;

    $journal    = Aduan::with('users')->where('ipsrs_id',$ipsrs_id)->orderBy('created_at', 'desc')->paginate(10);
    return view('sarpras.journal_sarpras',['journal' => $journal ]);
}
  1. public function search_range(Request $request) {

     $ipsrs_id = Auth::user()->roles->ipsrs_id;
     $from = $request->from;
     $to = $request->to;
     $status = $request->status;
    
     if($status == 'Belum Selesai'){
         $new_status =['Tindakan Lanjutan' , 'Belum Dikerjakan' ,'Sedang Dikerjakan'];
     }
     
     elseif($status == 'Semua Laporan'){
         $new_status = ['Tindakan Lanjutan' , 'Belum Dikerjakan', 'Sedang Dikerjakan' , 'Selesai'];
     }
     else{
         $new_status = 'Selesai';
     }
    
     $stats = collect($new_status);
    
     $journal = Aduan::where('ipsrs_id',$ipsrs_id)->whereIn('status',$stats)
     ->whereBetween('created_at', [$request->get('from'), $request->get('to')])->paginate();
    
     //dd($aduan);
    
     return view('sarpras.journal_sarpras',['journal' => $journal]);
     
    

    }

  1. public function getPDF($journal){

     $pdf = PDF::loadView('file_pdf', ['journal' => $journal]);
     dd($pdf);
     return $pdf->stream('file_pdf.pdf')->header('Content-Type','application/pdf');
    

    }

this 3 controller is View Table ,View Search Date range and export Pdf .on this export pdf i using variable on search pdf to parse this data in view like data viewed on table.

and this is my route

Route::get('getPDF', '[email protected]')->name('getPDF');

and parsing on this view

<a href="{{route('getPDF')}}" class="btn btn-primary" target="_blank">CETAK PDF</a>

but this is having error

Too few arguments to function App\Http\Controllers\AdminController::getPDF(), 0 passed and exactly 1 expected

what wrong with this pdf ?

Jan
14
1 month ago
Activity icon

Started a new Conversation Search Function Get Wrong Value

I create a search function to search data on table , but this result on search is not like what i need . its because i cant/not know how to put i line query on where clause . this function like this

public function search(Request $request)
{
    
    $ipsrs_id = Auth::user()->roles->ipsrs_id;
    $cari = $request->cari;


    $ipsrs_aduan = Aduan::where('ipsrs_id',$ipsrs_id);// i dont know where i can put this line


    $query = Aduan::query();
   
    $columns = ['aduan', 'nama_pengadu', 'status' ];
    foreach($columns as $column){
        
        $query->orWhere($column,'like','%'.$cari.'%');
    }   
    $aduan = $query->paginate();

    return view('admin.report_sarpras',['aduan' => $aduan]);
}

this problem is i cant put this line

 $ipsrs_aduan = Aduan::where('ipsrs_id',$ipsrs_id);// i dont know where i can put this line

someone can help this ??

Jan
08
1 month ago
Activity icon

Started a new Conversation Displaying Select Dropdown In Where Clause Get Failed Data

I have 3 table . this name is aduan, ipsrs , teknisi

struckture aduan table

id 
user_id
ipsrs_id
teknisi_id
aduan
etc.....

ipsrs table

id
nama_bagian
etc....

teknisi table

id
ipsrs_id
nama_teknisi
etc...

this is have models like this

class Aduan extends Model {


use SoftDeletes;

protected $table = 'aduan';
protected $fillable = [
    'user_id', 'ipsrs_id','nama_pengadu', 'aduan','teknisi_id'
];

protected $dates = ['deleted_at'];

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


public function ipsrs()
{
    return $this->belongsTo(\App\Models\Ipsrs::class ,'ipsrs_id');
    // return $this->HasMany(\App\User::class ,'user_id');
}

public function teknisi()
{
    return $this->belongsTo(\App\Models\Teknisi::class ,'teknisi_id');
    // return $this->HasMany(\App\User::class ,'user_id');
}

Teknisi Model

class Teknisi extends Model {
protected $table = 'teknisi';
protected $fillable = [
    'ipsrs_id', 'nama_teknisi', 'bagian',
];


public function ipsrs()
{
    return $this->belongsTo(\App\Models\Ipsrs::class ,'ipsrs_id');
    // return $this->HasMany(\App\User::class ,'user_id');
}}

with this table i want to create select dropdown on the modal . i create select dropdown using pluck , this data is showing but not like what iam need . its in the controller

 public function index(Request $request)
{
    $ipsrs = DB::table('ipsrs')->pluck('nama_bagian','id');
    
    $belum_kerjakan = Aduan::with('users')->where('status','Belum Dikerjakan')->get();
   $teknisi        = Teknisi::where('ipsrs_id' , 1)->pluck('nama_teknisi', 'id');  // this is to get pluck teknisi where this id ( ipsrs_id on **teknisi**) same like ipsrs_id on aduan ( if you see this table ,you will see this ipsrs_id in two table , but its didnt work and **show all data**)  
    $dalam_proses   = Aduan::with('users')->where('status','Sedang Dikerjakan')->get();
    $selesai        = Aduan::with('users')->where('status','Selesai')->get();
    return view('admin.admin_dashboard',[
        'belum_dikerjakan' => $belum_kerjakan,
        'dalam_proses'     => $dalam_proses,
        'selesai'          => $selesai,
        'ipsrs'            => $ipsrs,
        'teknisi'          => $teknisi,
    ]);
   
}

in my conclusion how i can catch onli ipsrs_id on this form ?

$teknisi = Teknisi::where('ipsrs_id' , 1)->pluck('nama_teknisi', 'id'); // i need to change this '1' to ipsrs_id

only data where ipsrs_id (on teknisi) is same like ipsrs_id (on aduan)

Jan
05
1 month ago
Activity icon

Started a new Conversation How To Store Update Data On Modal Laravel

i have a update function to update data on table using modal for view . in my view this modal can display data but i stuck on my store procedure , if i die dump this data, its not showed , its my view , controller and route :

view :

<tbody>
                @php
                  $no=0;
                 @endphp
                 @foreach ($belum_dikerjakan as $i)
                <tr>
                  <td> {{++$no}} </td>
                  <td> {{$i->users->nama_unit}}</td>
                  <td> {{$i->created_at}} </td>
                  <td> {{$i->nama_pengadu}} </td>
                  <td> {{$i->ipsrs->nama_bagian}} </td>
                  <td> {{$i->aduan}}</td>
                  <td><span class="badge bg-danger"> Belum Dikerjakan</span></td>
                  <td><button type="button" class="btn btn-default" data-toggle="modal" 
                    data-id="{{$i->id}}"
                    data-nama_unit="{{$i->users->nama_unit}}"
                    data-tgl_aduan="{{$i->created_at}}"
                    data-nama_pengadu="{{$i->nama_pengadu}}"
                    data-tujuan_aduan="{{$i->ipsrs->nama_bagian}}"
                    data-aduan="{{$i->aduan}}"
                    data-status="{{$i->status}}"
                    data-target="#modal-lg" >
                    Action
                  </button></td>
                </tr> 
                @endforeach
              </tbody>
            </table>
          </div>
    </div>

    <div class="modal fade" id="modal-lg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog modal-lg" role="document">
          <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">Ubah Status Aduan</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
              
            </div>
            <div class="modal-body">
  
  
            <form data-toggle="validator" action="{{route('update_aduan')}}" method="post">
              @csrf
              {{method_field('patch')}}
            <div class="form-group">
            <label class="control-label" for="title">Nama Unit:</label>
                <input type="text" name="nama_unit" id="nama_unit" class="form-control" data-error="Please enter title." required disabled/>
                <div class="help-block with-errors"></div>
              </div>
            <div class="form-group">
                <label class="control-label" for="title">Tanggal Aduan:</label>
                <textarea name="created_at" class="form-control" id="tgl_aduan" data-error="Please enter description." required disabled></textarea>
                <div class="help-block with-errors"></div>
              </div>
            <div class="form-group">
                  <label class="control-label" for="title">Nama Pengadu:</label>
                  <input type="text" name="nama_unit" class="form-control" id="nama_pengadu" data-error="Please enter title." required disabled/>
                  <div class="help-block with-errors"></div>
                </div>
                <div class="form-group">
                    <label> Isi Aduan </label>
                    <textarea name="aduan" id="aduan" class="form-control" rows="3" placeholder="Isi Aduan atau Keluhan ..."  required disabled></textarea>
                  </div>
              <div class="form-group">
                  <label>Select Gender</label>  
                  <select name="status" id="status" class="form-control">  
                       <option value="Belum Dikerjakan">Belum Dikerjakan</option>  
                       <option value="Sedang Dikerjakan">Sedang Dikerjakan</option>  
                  </select>  
                  <div class="help-block with-errors"></div>
                </div>

              <input type="hidden" name="id" id="id" value="">
              <div class="form-group">
                <button type="submit" class="btn btn-success crud-submit-edit">Submit</button>
              </div>
                </form>

and its my modal function

 <script>
$('#modal-lg').on('show.bs.modal', function (event) {
  
  var button = $(event.relatedTarget) // Button that triggered the modal
  var id           = button.data('id')
  var nama_unit    = button.data('nama_unit')
  var tgl_aduan    = button.data('tgl_aduan')
  var nama_pengadu = button.data('nama_pengadu')
  var tujuan_aduan = button.data('tujuan_aduan')
  var aduan        = button.data('aduan') 
  var status       = button.data('status') 
  var modal = $(this)
 
  modal.find('.modal-body #nama_unit').val(id);
  modal.find('.modal-body #nama_unit').val(nama_unit);
  modal.find('.modal-body #tgl_aduan').val(tgl_aduan);
  modal.find('.modal-body #nama_pengadu').val(nama_pengadu);
  modal.find('.modal-body #tujuan_aduan').val(tujuan_aduan);
  modal.find('.modal-body #aduan').val(aduan);
  modal.find('.modal-body #status').val(status);
})
</script>

its my controller

 public function update_aduan(Request $request)
{

 //$id = $request->id;
 //$aduan = Aduan::findOrFail($id);


 //$aduan->update($request->all());
 dd($request->all());


}

and its my die dump form this controller

    array:4 [▼
  "_token" => "fPAPkD358ulkxOJyhjS9mGIh93dDQOt0d7HbbVcN"
  "_method" => "patch"
  "status" => "Sedang Dikerjakan"
  "id" => null
]

i dont know if i remover this "//" on my all controller , if i submit this form its will going to 404

 Route::patch('/ubah_aduan', '[email protected]_aduan')->name('update_aduan');

someone can help ?

Jan
03
1 month ago
Activity icon

Started a new Conversation Update Data Using Modal On Laravel

I want to create edit data on laravel using a modal for view . but i dont know how to catch one data on on my edit form .

i build controller like edit data on another page ( not using modals )

 public function index()
{
    $ipsrs = DB::table('ipsrs')->pluck('nama_bagian','id');
    $belum_kerjakan = Aduan::with('users')->where('status','Belum Dikerjakan')->get();
    $dalam_proses   = Aduan::with('users')->where('status','Sedang Dikerjakan')->get();
    $selesai        = Aduan::with('users')->where('status','Selesai')->get();
    return view('admin.admin_dashboard',[
        'belum_dikerjakan' => $belum_kerjakan,
        'dalam_proses'     => $dalam_proses,
        'selesai'          => $selesai,
        'ipsrs'            => $ipsrs,
    ]);
   
}


public function change_aduan($id) 
{
   
    $aduan = Aduan::findOrFail($id);
    if (!$aduan)
    abort(404);
    
    return view('admin.admin_dashboard',[
        'aduan' => $aduan
    ]);
}

this route . ( but i dont know where i used this route ?

 Route::get('admin_dashboard', '[email protected]')->name('admin_dashboard');  // this route for view table
 Route::get('change/{id}','[email protected]_aduan')->name('change_aduan');   // this route "will" showing data on this modals

my View

 <div class="card-body" align='center'>
        <div class="card-body p-0">
            <table class="table table-condensed">
              <thead align="center">
                <tr class="satu">
                  <th style="width: 3%">#</th>
                  <th style="width: 10%">Nama Unit</th>
                  <th style="width: 15%">Tanggal Aduan</th>
                  <th style="width: 8%">Nama Pengadu</th>
                  <th style="width: 8%">Tujuan Aduan</th>
                  <th style="width: 30%">Isi Aduan </th>
                  {{-- <th>Label</th> --}}
                  <th style="width: 5%">Status</th>
                  <th style="width: 5%">Action</th>
                </tr>
              </thead>
              <tbody>
                @php
                  $no=0;
                 @endphp
                 @foreach ($belum_dikerjakan as $i)
                <tr>
                  <td> {{++$no}} </td>
                  <td> {{$i->users->nama_unit}}</td>
                  <td> {{$i->created_at}} </td>
                  <td> {{$i->nama_pengadu}} </td>
                  <td> {{$i->ipsrs->nama_bagian}} </td>
                  <td> {{$i->aduan}}</td>
                  <td><span class="badge bg-danger"> Belum Dikerjakan</span></td>
                  <td><button type="button" class="btn btn-default" data-toggle="modal" data-id="{{$i->id}}" data-target="#modal-lg" > // modals button
                    Action
                  </button></td>
                </tr> 
                @endforeach
              </tbody>
            </table>
          </div>
    </div>

    <div class="modal fade" id="modal-lg">
        <div class="modal-dialog modal-lg">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title"> Change Status  </h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">

            {{-- Here this Form --}}
             {{-- {{$aduan->nama_pengadu}} --}} // this Line is failur
            </div>
            <div class="modal-footer justify-content-between">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              <button type="button" class="btn btn-primary">Save changes</button>
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>

i dont know how to next step , on another tutorial this data is can showed using {{ $data->name }} , but in my view cant do this . whats wrong ,and how i can solved this ?

Jan
02
1 month ago
Activity icon

Replied to How To Set Locale Location On Laravel

if i input some data , if i not change this config , this data on created_at field will be follow date on en , but i change to id , id_ID its follow my true date now .

Activity icon

Replied to How To Set Locale Location On Laravel

on config . i set all on id like this this time on my input is change ( true on my time location) but this month not changes to indonesian language

 'timezone' => 'Asia/Jakarta',

/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/

'locale' => 'id',

/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/

'fallback_locale' => 'id',

/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/

'faker_locale' => 'id_ID',
Activity icon

Replied to How To Set Locale Location On Laravel

my timezone is update to my local area , but this month . like January its not changes . how ?

Jan
01
1 month ago
Activity icon

Started a new Conversation How To Set Locale Location On Laravel

i browsing how to add and set locale global on laravel . i add this line on app/Providers/AppSserviceProvider.php

public function boot()
{
    config(['app.locale' => 'id']);
    \Carbon\Carbon::setLocale('id');
}

i want to change datetime 'F' to indonesian language ( January to Januari .. etc)

but this line on function boot didnt work , anyone have solution ?

Dec
04
2 months ago
Activity icon

Replied to How To Connect Foreign-key On 3 Tables Relation

why first ? i want to show all data on this id

Dec
03
2 months ago
Activity icon

Started a new Conversation How To Connect Foreign-key On 3 Tables Relation

I dont know how to create a great title , iam sorry . so i have 3 table . USER , SPECIAL_USER, EDUCATION_SPECIAL_USER

in USER i have data basic like

id ,name , address , email ,etc

in SPECIAL_USER data

id , user_id , height , weight

in EDUCATION_SPECIAL_USER i have

id , special_user_id , name_school , skills , etc

i have table LIKE on this table . i have problem how to call EDUCATION_SPECIAL_USER based on id on USER . its have problem because my EDUCATION_SPECIAL_USER is not have relation directly on USER table . its my controller , how to solve this

  public function PDF_profile(Request $request,$id){
   $users = User::findOrFail($id);
   $special_users= Special_Users::where('user_id',$id)->first();
   $EDUCATION_SPECIAL_USER= EDUCATION_SPECIAL_USER::where('Special_User_id',$id)->get();
   
    $pdf = PDF::loadView('admin.pdf_profile',
    [
    'EDUCATION_SPECIAL_USER '=>$EDUCATION_SPECIAL_USER ,
    'users' => $users,
    'special_users'=> $special_users,
   

    
    ]);
    dd($r_kgb);
     //return $pdf->stream('Profile.pdf')->header('Content-Type','application/pdf'); 
                 
}

this data is not out because this wrong id , how i can solve this ?

Nov
26
3 months ago
Activity icon

Replied to How To Update File Upload Laravel ?

omg i miss that , iam sorry sir. solved

Activity icon

Replied to How To Update File Upload Laravel ?

i add this sir

Activity icon

Replied to How To Update File Upload Laravel ?

can someone help ?

Activity icon

Started a new Conversation How To Update File Upload Laravel ?

I have a edit form , and this edit form is can changes imageupload . i can show this image. but on store function update is not work properly . only image cant updated .

its my store function

 public function update_non_pns(Request $request,$id)
{
    
    $users  = User::find($id);
    

    $users->nama                 = $request->input('nama');
    $users->email                = $request->input('email');
    $users->alamat               = $request->input('alamat');
    $users->NIK                  = $request->input('NIK');
    $users->jenis_kelamin        = $request->input('jenis_kelamin');
    $users->tempat_lahir         = $request->input('tempat_lahir');
    $users->tanggal_lahir        = $request->input('tanggal_lahir');
    $users->pendidikan           = $request->input('pendidikan');
    $users->nomor                = $request->input('nomor');
    $users->agama_id             = $request->input('agama_id') ;
    $users->status_pegawai_id    = $request->input('status_pegawai_id');
    $users->unit_kerja_id        = $request->input('unit_kerja_id') ;

    
    if($request->hasfile('foto'))

    {   
    $file = $request->file('foto');
        $extension = $request->foto->getClientOriginalExtension();  //Get Image Extension
        $fileName = uniqid().'.'.$extension;  //Concatenate both to get FileName (eg: file.jpg)
        $file->move(public_path().'/files/', $fileName);  
        $data = $fileName; 
        $users->foto = $data;
    }

    
    dd($users);
    //  $users->save();
    //  return redirect()->back()->with('success', 'Your info are updated');
}

i have some update function to edit File not Image , this file can update successfully but i use this function to image its cant be updated .

i try to dd($request->foto): its success and show a true image on my input , so

whats wrong on my store function ?

Activity icon

Started a new Conversation How To Edit File/image On Update Form Laravel

I have a form edit, and this form have data file/image. I want to edit this but I don't know what to do. I cant display this file/image and can't edit this.

<div class="item form-group">
    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="file_scan">
        File Scan Sertifikat
        <span class="required">*</span>
    </label>
    <div class="col-md-6 col-sm-6 col-xs-12">
        <input id="file_scan" type="file" class="form-control @error('file_scan') is-invalid @enderror" name="file_scan" value="{{pelatihan->file_scan}}" required autocomplete="file_scan">

        @error('file_scan')
            <span class="invalid-feedback" role="alert">
                <strong>{{ $message }}</strong>
            </span>
        @enderror
    </div>
</div>

I want to show first this file ( by name I think) and I can edit. What's wrong?

UPDATE I add my controller :

  public function edit_pelatihan($id)
{
    $pelatihan = Master_seminar_pelatihan::findOrFail($id);
    if (!$pelatihan)
    abort(404);
  

    return view('admin/edit/edit_pelatihan', ['pelatihan'=>$pelatihan]);
}
Nov
24
3 months ago
Activity icon

Started a new Conversation How To Auto Select On Radio Button With Value Form Database

I have Update function , and this update data like Sex . Male or Female . But i didnt know how to choose automaticly (auto checked) form database on update form. its my blade view . btw its on table users

<div class="item form-group">
                    <label for="jenis_kelamin" class="control-label col-md-3">Jenis Kelamin <span class="required">*</span></label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      
                       
                        <td>
                        <label> Laki-Laki<input type="radio"  name="jenis_kelamin" value="L" checked>
                        </label>
                       </td>
                      
                      
                        <td>
                        
                        <label> Perempuan
                          <input type="radio"  name="jenis_kelamin" value="P">
                        </label>
                       </td>
                      
                      

                        @error('jenis_kelamin')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                        @enderror
                    </div>
                  </div>

on database my value just L and P . how i can solved this ?

Nov
21
3 months ago
Activity icon

Replied to Cannot Upload Image In Larvel-6, Show The “E:\xampp\tmp\php3A05.tmp” File Does Not Exist Or Is Not Readable

me too , i dont know what happen , i never see this error like this before use laravel under 6 .

Nov
07
3 months ago
Activity icon

Replied to Get Attribute On Models Not To Global Data

i dont know but you're the best . thank you so much

Activity icon

Started a new Conversation Get Attribute On Models Not To Global Data

I have a data on users model like tanggal_lahir or in english its like dob , i create this on User Models to change this format date . like this :

  public function getTanggalLahirAttribute()
  {
     return \Carbon\Carbon::parse($this->attributes['tanggal_lahir'])

    ->format('d, F-Y ');
  }

i know its changed global value form tanggal_lahir to format d,F-Y , but now i have a problem , on specific form (update data form) i need a normall value not d,F-Y in this script

 <input id="tanggal_lahir" type="date" class="form-control @error('tanggal_lahir') is-invalid 
  @enderror" name="tanggal_lahir" value="{{$pns->users->tanggal_lahir}}" 
  required autocomplete="tanggal_lahir">

its form input on update form , if i active getTanggalLahirAttribute() , this value on form not showing , but if i delete/non active this getTanggalLahirAttribute() its will back to normall value (showing)

so in my question how i can specified using

\Carbon\Carbon::parse($this->attributes['tanggal_lahir'])

    ->format('d, F-Y ') 

on my view . i using datatables yajra ,

Activity icon

Replied to How To Showing Value On Dropdown List Form Auto Select Value From Database

its solved sir . i solved with this

<select name="agama_id" id="agama_id" class="form-control">
                          @foreach($agama as $masters => $agamas )
                               <option value="{{ $masters }}" @if ($pns->users->agama_id == $masters ) selected @endif>{{ $agamas }}</option>
                          @endforeach
                      </select>
Activity icon

Replied to How To Showing Value On Dropdown List Form Auto Select Value From Database

iam sorry for a missleading . i think its didnt work because this value not changed and always selected on first row in db.

on this :

@if(old('agama_id', $pns->users->agama_id) === $id) 

i tryng to delete 'agama_id' like this :

@if(old( $pns->users->agama_id) === $id) 

its not getting error ,how ??

Activity icon

Replied to How To Showing Value On Dropdown List Form Auto Select Value From Database

its only 1 users . its like update profile . this

$pns->users->agama_id

its to get agama_id on table users , because i am update 2 table at once time like this on first paragrafph i use

{{$pns->users->nama}}
Activity icon

Replied to How To Showing Value On Dropdown List Form Auto Select Value From Database

i try your code but didnt work i think . i change to this

<div class="form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12">Agama <span class="required">*</span></label>
                      <div class="col-md-6 col-sm-9 col-xs-12">
                        <select name="agama_id" id="agama_id" class="form-control">
                            @foreach($agama as $id => $agamas )
                            <option value="{{ $id }}"
                            @if(old('agama_id', $pns->users->agama_id) === $id) checked @endif>{{ $agamas }}</option>
                            @endforeach
                        </select>
                      </div>
                    </div>
Activity icon

Replied to How To Showing Value On Dropdown List Form Auto Select Value From Database

$agama =$agama DB::table('master_agama')->pluck('agama','id');

its i get $agama

Activity icon

Started a new Conversation How To Showing Value On Dropdown List Form Auto Select Value From Database

i have a from to edit/ update data . on colomn input like name ,email ,date i dont have a problem because this value can e displayed at this colomn like this :

 <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="nama">NAMA <span class="required">*</span>
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                    <input id="nama" type="text" class="form-control @error('nama') is-invalid @enderror" name="nama" value="{{$pns->users->nama}}" required autocomplete="nama">

                        @error('nama')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                        @enderror
                    </div>
                  </div>

this value on this input is value="{{$pns->users->nama}}" and its still working , but how i can do this on this input ? this input is select dropdown list like this :

 <div class="form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12">Agama <span class="required">*</span></label>
                      <div class="col-md-6 col-sm-9 col-xs-12">
                        <select name="agama_id" id="agama_id" class="form-control">
                            @foreach($agama as $masters => $agamas )
                            <option value="{{ $masters }}">{{ $agamas }}</option>
                            @endforeach
                        </select>
                      </div>
                    </div>

where i can user this value like {{$pns->users->nama}} ??? if i open this update form , its will choose automaticlly like this db ??

someone have solution ?

Nov
05
3 months ago
Activity icon

Awarded Best Reply on Javascript Onclick Its Not Worked On Datatables Serverside

NOW its solved . thanks guys , your the best

Activity icon

Replied to Javascript Onclick Its Not Worked On Datatables Serverside

NOW its solved . thanks guys , your the best

Activity icon

Replied to Javascript Onclick Its Not Worked On Datatables Serverside

hmmm you mean this my delete method fault ? or we have some simply delete on datatables ?

Activity icon

Replied to Javascript Onclick Its Not Worked On Datatables Serverside

ok now i add class on my button , and delete on this form submit , but this script alert

$('.delete').submit(function(event){
  if(!confirm('Anda yakin mau menghapus item ini ?')){
      event.preventDefault();
  }

this message is not showing -_-

Activity icon

Replied to Javascript Onclick Its Not Worked On Datatables Serverside

omg why i create or write script here always look untidy . can see this image sir https://ibb.co/KqLccFN

i tryng add this form class

return "<form action='/delete/$pns->id' method='POST' class='delete-form')>

this pop up is showing after i click this delete button but this message is null/empty ,

Activity icon

Replied to Javascript Onclick Its Not Worked On Datatables Serverside

you mean id on this button ?

Activity icon

Started a new Conversation Javascript Onclick Its Not Worked On Datatables Serverside

I have function delete on my table ( using datatables) this delete is work normally but i want to add some pop up alert like "onclick" on my delete , but its didnt work on my button

 public function indexDataTables_pns()
{

    $pns = Data_pns::with('users','master_golongan','master_jabatan')->get();


    return Datatables::of($pns)->addIndexColumn()
    
    ->addColumn('Nama', function ($pns) {
        return '<a href="/pns/'.$pns->id.'" target="_blank">'.$pns->users->nama.'</a>';   
    })
    ->editColumn('edit', function ($pns) {
        return '<a href="/edit_pns/'.$pns->id.'" target="_blank" class="btn btn-xs btn-success"><i class="glyphicon glyphicon-edit"></i></a>';
    })
    ->editColumn('hapus', function ($pns) {
          
        $c = csrf_field();
        $m = method_field('DELETE');

    return "<form action='/delete/$pns->id' method='POST')>
            $c
            $m
            
            <button style='margin-left:10px; width: 30px;' type='submit'
                class='btn btn-xs btn-danger delete' onclick='return 
                confirm('do you want to delete this data ?')'>
                <i class='glyphicon glyphicon-remove-circle'></i>
            </button>
        </form>";
    })
    ->rawColumns(['Nama' => 'Nama','hapus' => 'hapus','action' => 'action','edit'=>'edit'])
    ->make(true);

}

its didnt work

i trying adding class

<form action='/delete/$pns->id' method='POST' class='delete-form'>

and add this script

<script>
$('.delete-form').submit(function(event){
    if(!confirm('Anda yakin mau menghapus item ini ?')){
        event.preventDefault();
    }
});

but still didnt work . i put this on under my view .

i try to add onsubmit like this

<form onsubmit='return confirm('Anda yakin mau menghapus item ini ?')'>

still didnt work , iam from this thread this link , but i didnt find the answer ..

look this image

can someone help me ?

Activity icon

Replied to How To Display Alert On Button Click In JQuery DataTable?

i try on submit too .look https://ibb.co/8D1FbdJ

didnt work to , whats wrong ?

Activity icon

Replied to How To Display Alert On Button Click In JQuery DataTable?

return "<form action='/delete/$pns->id' method='POST')> $c $m

            <button style='margin-left:10px; width: 30px;' type='submit'
                    class='btn btn-xs btn-danger delete' 
                    onclick='return confirm('Anda yakin mau menghapus item ini ?', function(result) { if(result) {       
                this.form.submit(); }})'>
                <i class='glyphicon glyphicon-remove-circle'></i>
            </button>

like this ? but its didnt work