davy_yg

davy_yg

Member Since 2 Years Ago

Jakarta

Experience Points 59,200
Experience Level 12

800 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 317
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.

15 Aug
2 days ago

davy_yg started a new conversation API Login

Hello,

I create api for login that returns username and message retrieved user successfully:

public function index(Request $request)
{
 
    $data = $request->all();
    $data['email'] = $request->email;
    $password = bcrypt($request->password);

    $User = User::where('email', $data['email']) and where('password', $password)->get();

    if($User != null){

        return $this->sendResponse($data->toArray(), 'Users retrieved successfully');    
    }
    
   }

I am not sure if I write this line correctly:

$User = User::where('email', $data['email']) and where('password', $password)->get();

please help me correct it?

davy_yg left a reply on Elorest

I am working on top of someone else code. I have to build new api. The previous developer uses elorest. I have used laravel for around 1 year. I have no choice but to use elorest.

Most of the tutorial I watches only uses echo json. Elorest seems to be different when calling the api.

davy_yg left a reply on Has

So it's checking if there is a transaction row connected to the transaction table?

davy_yg started a new conversation Has

Cek this code:

$seller = Seller::has('transactions')->findOrFail($id);

has('transaction') is it checking the existance of transactions table?

davy_yg left a reply on Elorest

I read the documentation but still do not understand the syntax to call the api. I working on someone else program:

http://*/public/oauth/[email protected]&password=&grant_type=password&scope=[]&client_id=1&client_secret=2ZxtO4C4pyfeBsRZKO5q9AcSAPKPmHU8bacWThKf

I cannot understand where do you get oauth/ and token ?

and there is another one:

http://*******/public/api/products?query[a][function]=get

This link works but not understandable. Since I have to get another similar api and create the api

What is the point of using elorest? and why not using normal api?

14 Aug
3 days ago

davy_yg started a new conversation Elorest

Hello,

What is elorest is for?

Elorest::routes();

Elorest::routes([ 'middleware' => ['auth:api', 'throttle:60,1'], // 'only' => ['post', 'put', 'patch', 'delete'], 'except' => ['get'] ]);

There isn't much information on google about it.

davy_yg started a new conversation Decrypting Bcrypt Password

Hello,

I have been looking for away to decrypt bcrypt password online but I cannot understand why they keep asking for a string to check against?

When encrypting it as simple as this:

$user->password = bcrypt($request->password); $user->save();

What am I missing?

davy_yg left a reply on Casts

I still do not get the point of using casts if we can use validation to validate the data.

13 Aug
4 days ago

davy_yg started a new conversation Api Routes

Hello,

I would like to check:

routes/api.php

Route::get('reports/documents', '[email protected]');   

Route::resource('customer_groups', 'CustomerGroupAPIController');

How to know if my api works or not using these routes. Is it enough to type: www.mainurl.com/reports/documents and www.mainurl.com/customer_groups

?

davy_yg started a new conversation Casts

Hello,

I have a question regarding casts in model. If you define the phone as integer in casts and the user input a string will there be an error message?

protected $casts = [
    'phone' => 'integer'
];

davy_yg left a reply on ProductRepository

It's a project that I am working on. I just get the code from my friend, I have to continue his job.

davy_yg left a reply on ProductRepository

Dude, I have look for several tutorials about repositories but cannot find the exact matches. For example: https://itnext.io/repository-design-pattern-done-right-in-laravel-d177b5fa75d4

Please help me out.

davy_yg left a reply on ProductRepository

I have a quick question:

$customer = $this->customerRepository->findWithoutFail($id); $customer = $this->customerRepository->update($input, $id);

Is findWithoutFail($id) and update($input, $id) is a common syntax to interact with the table? Since I did not find the syntax define in customerRepository

davy_yg left a reply on ProductRepository

Can you refer to me where at in the documentation or tutorial? I have search this keyword "productRepository" in the laravel documentation but cannot find it.

davy_yg started a new conversation ProductRepository

Hello,

I came across this code:

$product = $this->productRepository->findWithoutFail($id);

if (empty($product)) {
           return $this->sendError('Product not found');
       }

$product = $this->productRepository->update($input, $id);

return $this->sendResponse($product->toArray(), 'Product updated successfully');

I wonder where does productRepository comes from?

01 May
3 months ago

davy_yg left a reply on Escape String

please help. I don't really understand how the other escape string could perform sqlia?

davy_yg started a new conversation Escape String

Hello,

Can you tell me why :

\'  single quote
\"  double quote
\  backslash
\n  new line
\r  carriage return
\t  tab
\b  backspace
\f  form feed
\v  vertical tab (Internet Explorer 9 and older treats '\v as 'v instead of a vertical tab ('\x0B). If cross-browser compatibility is a concern, use \x0B instead of \v.)
LARACASTS_SNIPPET_PLACEHOLDER  null character (U+0000 NULL) (only if the next character is not a decimal digit; else it is an octal escape sequence)
\xFF    character represented by the hexadecimal byte "FF"

The rest besides ' and '' could be dangerous in performing sqlia if not using mysqli_escape_string?

11 Apr
4 months ago

davy_yg started a new conversation Prepared Statement

Hello,

This is php native question to prevent sqlia:

<?php 
$id = -1 ;
if(isset($_GET['id']))
    {
    $id = $_GET['id'];
}

$stmt = $db->prepare("select * from product where id = ?");

if($id == -1)
{
$stmt = $db->prepare("select * from product order by 1 asc limit 1;");
}
?>

<?php if ($stmt->execute(array($_GET['id']))) {
while ($b = $stmt->fetch()) { ?>

<div id="title"><?php echo $b->judul;?></div><br><br>
<div id="pic2"><img style="width:150px;height:150px;" src="images/<?php echo $b->image;?>"></div>
<?php echo $b->deskripsi;?>
</div>

<? }
}
?>

Warning: mysqli_stmt::execute() expects exactly 0 parameters, 1 given in /home/advancew/rustoleum.advance-web-studio.com/Rustoleum2.php on line 145

07 Apr
4 months ago

davy_yg started a new conversation Dispatch

What is dispatch for in Javascript?

for example:

 if(!tokenFromStorage){
          reject();  
        }
        dispatch(authSetToken(tokenfromStorage));
        resolve(tokenFromStorage);
26 Mar
4 months ago

davy_yg started a new conversation The Best Forum For React Native

Hello,

This might not having anything to do with laravel. I am assigned to do react native task. Any best forum for react native? Any clue?

Thanks in advance.

08 Mar
5 months ago

davy_yg left a reply on Selecting Row Number 2

@mushood

An uncaught Exception was encountered

Type: Error

Message: Call to undefined method CI_DB_mysqli_driver::skip()

Filename: C:\xampp\htdocs\masterlink_web\application\models\M_home.php

Line Number: 123

Backtrace:

File: C:\xampp\htdocs\masterlink_web\application\controllers\Home.php Line: 34 Function: our_servis_no2

File: C:\xampp\htdocs\masterlink_web\index.php Line: 315 Function: require_once

M_home.php

function our_servis_no2(){
    $r = $this->db->select('*')
            ->from('our_servis')
            ->skip(1)
            ->limit(1)
            ->get()->result();
    return $r;
}

Home.php

public function epoxy()
{
    $data['epoxy'] = $this->m_home->our_servis_no2();

    $this->load->view('public/epoxy', $data);
}

davy_yg started a new conversation Selecting Row Number 2

Hello,

I would like to know how to select row number 2 for example. only number 2. The id changes everytime there is an edit on that particular row.

davy_yg left a reply on Count(): Parameter Must Be An Array Or An Object That Implements Countable

There is nothing wrong with the back();

There is something wrong these:

 Products::where('prod_id', $product->prod_id)->delete();
    Wishlists::where('prod_id', $product->prod_id)->delete();
07 Mar
5 months ago

davy_yg left a reply on Count(): Parameter Must Be An Array Or An Object That Implements Countable

I do get prod_id for example 1 or 2.

dd($product->prod_id);

This is Products.php model:

class Products extends Model
{
    use SoftDeletes;

    protected $primaryKey = 'prod_id';
    protected $guarded = ['prod_id'];
    protected $dates = ['deleted_at'];

    public function productMetas()
{
    return $this->hasMany(ProductsMeta::class, 'prod_id');
}

public function productMainImage()
{
    return $this->hasOne(Images::class, 'img_id', 'prod_main_img');
}

public function reviews()
{
    return $this->hasMany(Reviews::class, 'prod_id');
}

public static function get_featured()
{
    return static::where('prod_featured', 1)->limit('4')->get();
}

public static function checkStockAvailability($prod_id, $amount)
{
    $stock = static::select('prod_stock', 'prod_stockable')->where('prod_id', $prod_id)->first();

    if ($stock->prod_stockable == 0) {
        return true;
    }

    if ($stock->prod_stock < $amount) {
        return false;
    }

    return true;
    }
}

davy_yg started a new conversation Count(): Parameter Must Be An Array Or An Object That Implements Countable

When trying to delete a row I am getting this error message:

count(): Parameter must be an array or an object that implements Countable

products.blade.php

<form style="display:inline" method="POST" action="{{url( '/cpages/products/'. $product->prod_id )}}">
        {{ csrf_field()}}
        {{ method_field('DELETE') }}
        <input type="submit" class="delete fix-inline-btn" value="Delete" />
      </form>

routes/web.php

Route::delete('/cpages/products/{product}', '[email protected]');

ProductsController.php

public function softDelete(Products $product)
    {

        Products::where('prod_id', $product->prod_id)->delete();
        Wishlists::where('prod_id', $product->prod_id)->delete();
        session()->flash('flash', 'Product Dihapus');

        return back();
    }

davy_yg left a reply on Base Url

What this mean:

URL::asset('themes/style/add.css')

Which exact folder does it refer to?

davy_yg left a reply on Base Url

Is URL::asset the same like public_html?

<link rel="stylesheet" href="{{ URL::asset('themes/style/add.css') }}" />

davy_yg started a new conversation Base Url

Hello,

I want to add base url in laravel, how to do so?

value="{{ $image->img_name }}"

Add base url to the value

davy_yg left a reply on Php Artisan Not Working

I cannot find both /etc/php5/apache2 and /etc/php5/cli/ inside php.ini files. I wonder which part do I need to edit?

davy_yg started a new conversation Php Artisan Not Working

Hello,

I wonder when trying to create controller I am getting this error message:

C:\xampp\htdocs\lekaeshop>php artisan make:controller PageController
PHP Warning:  Module 'mysqli' already loaded in Unknown on line 0

Warning: Module 'mysqli' already loaded in Unknown on line 0
Could not open input file: artisan

C:\xampp\htdocs\lekaeshop>php artisan
PHP Warning:  Module 'mysqli' already loaded in Unknown on line 0

Warning: Module 'mysqli' already loaded in Unknown on line 0
Could not open input file: artisan

C:\xampp\htdocs\lekaeshop>

How to solve it?

05 Mar
5 months ago

davy_yg started a new conversation Edit(elm)

Can someone help me explain this code:

function edit(elm){
    $.each(elm,function( i , el){
      $("#"+i).val(el);
    });
            
    $("#mdl-our-servis").modal('show');
}

Where does elm comes from? How about i and el?

Thanks in advance.

04 Mar
5 months ago

davy_yg started a new conversation FindOrFail();

Hello,

I wonder what is the difference between findOrFail and find ?

$Product = Product:findOrFail($id);

Thanks in advance.

22 Feb
5 months ago

davy_yg started a new conversation Style

I wonder if you can add a class component? for example:

<div class="class_A"></div>

// I define this over since I cannot find the class_A below.  I would like to replace the background color.

class_A {

    background-color: yellow !important;

}

// This part is hidden and difficult to find since I can only find it through inspect element.
class_A {

    background-color: black;
    font: Arial;

}

Is it possible to redefine the class_A above?  Which style will the computer read?
13 Jan
7 months ago

davy_yg started a new conversation Laravel Cart

Hello,

I have a question: I am watching laravel tutorials from a website. Which are using several laravel cart function such as:

cart::add, cart::remove, cart::update

I wonder if there are good documentations on the internet about this so that I can understand them better?

Thanks in advance.

10 Jan
7 months ago

davy_yg started a new conversation Location.href

Hello,

I would like to know why the apply button does not work? I wonder if I write the location.href incorrectly?

recruitment.blade.php

<div class="card-body" >
                            <p><?php echo Lang::get('message.job-intro1');?></p>
                            <div class="job-desc">                                    
                                <?php echo $data['description']; ?> 
                            </div>
                            <div class="career-background">
                                <h3>Background</h3>
                                <?php echo $data['background']; ?>
                            </div>
                            <div class="competencies">
                                <h3>Kompetensi</h3>
                                <?php echo $data['qualification']; ?>
                            </div><br>
                            <button class="btn btn-primary" onclick="location.href='{{ url("/form/".<?php echo $data["detail_id"]; ?>) }}'"> Apply </button><br>
                        </div>

davy_yg left a reply on Method Illuminate\Database\Eloquent\Collection::join

I added this:

use Illuminate\Support\Facades\DB;

and the same error still appears:

BadMethodCallException
Method Illuminate\Database\Eloquent\Collection::join does not exist.

davy_yg started a new conversation Method Illuminate\Database\Eloquent\Collection::join

Hello,

How to fix this error message:

Method Illuminate\Database\Eloquent\Collection::join does not exist.

PageController.php

public function application()
    {
        $data2 = ApplicationModel::all()
            ->join('tb_detail', function ($join) {
                $join->on('detail_id','=','detail_id');
            })
            ->get();

        // $data = ApplicationModel::all();

        return view('admin.application')->with('list', $data2);
    }

davy_yg started a new conversation Passing Value

Hello,

I would like to pass value id from PageController.php to the form.blade.php. I am not quite sure how to pull the detail id from the view. Is this the correct syntax:

{{ $JobDetail->detail_id }}

Please cek form.blade.php

PageController.php

public function form(Request $request)
    {

        $detail_id = $request->id;

        $JobDetail = JobDetailModel::get();     

        return view('form', compact('JobDetail'));
    }

form.blade.php

<form class="needs-validation" novalidate method="post" action="{{ Url('/saveapps') }}" enctype="multipart/form-data">
      <input type="hidden" name="_token" value="{{ csrf_token() }}"/>
            
            <input required type="hidden" class="form-control" id="nama" placeholder="" value="" name="{{ $JobDetail->detail_id }}">
08 Jan
7 months ago

davy_yg started a new conversation Form Feedback

Hello,

any clue where the comes from?

form.php

<div class="row">
          <div class="col-md-6 mb-3">
            <label for="name">Nama Lengkap</label>
            <input type="text" class="form-control" id="nama" placeholder="" value="" name="nama" required>
            <div class="invalid-feedback">
              Nama harus diisi
            </div>
          </div>
    </div>

davy_yg started a new conversation Custom Email Message

Hello,

I would like to create a custom email message. Can anyone help?

I only get this message: Please enter an email address

PageController.php

public function saveapps(Request $request) {

    Validator::make($request->all(), [
        
        "cover_letter" => "required|max:500",
        "nama" => "required",
        "jenis_kelamin" => "required",
        "tanggal_lahir" => "required",
        "nohp" => "required",
        "email" => "required|email",
        "alamat" => "required",
        "provinsi" => "required",
        "kota" => "required",
        "zip" => "required|integer",
        "status" => "required",
        "jumlah_tanggungan" => "required",
        "agama" => "required",
        "salary" => "required",
        "file_attachment" => "required",             
    ],
    [
        "cover_letter.max" => 'Maksimal 500 karakter', 
        "zip.integer" => 'Kode zip harus angka', 
        "email.email" => 'Tolong isi dengan format email',          
    ]
    )->validate();

form.blade.php

 @if ($errors->any())
          <div class="alert alert-danger">
              <ul>
                  @foreach ($errors->all() as $error)
                      <li>{{ $error }}</li>
                  @endforeach
              </ul>
          </div>
      @endif

...
    
<div class="mb-3">
          <label for="email">Email</label>
          <input type="email" class="form-control" id="email" name="email" placeholder="[email protected]">
          <div class="invalid-feedback">
            Mohon isi email Anda yang valid
          </div>
        </div>
07 Jan
7 months ago

davy_yg started a new conversation Custom Error Message

Hello,

I wonder why this custom message does not appears:

"zip" => 'Kode zip harus angka',

on the form when I enter alphabeth.

Validator::make($request->all(), [
        
            "cover_letter" => "required | max:500",
            "nama" => "required",
            "jenis_kelamin" => "required",
            "tanggal_lahir" => "required",
            "nohp" => "required",
            "email" => "required | email",
            "alamat" => "required",
            "provinsi" => "required",
            "kota" => "required",
            "zip" => "required | integer",
            "status" => "required",
            "jumlah_tanggungan" => "required",
            "agama" => "required",
            "salary" => "required",
            "file_attachment" => "required",             
        ],
        [
            "cover_letter.max" => 'Maksimal 500 karakter', 
            "zip" => 'Kode zip harus angka',            
        ]
    )->validate();


form.blade.php

 @if ($errors->any())
          <div class="alert alert-danger">
              <ul>
                  @foreach ($errors->all() as $error)
                      <li>{{ $error }}</li>
                  @endforeach
              </ul>
          </div>
      @endif

      <span style="color: red;">{{ $errors->first("zip") }}</span>  
    
      <h4 class="mb-3">Biodata</h4>

davy_yg started a new conversation Validation

Hello,

How to validate integer only?

like zip code

"zip" => "required",

davy_yg left a reply on Error Message Does Not Appears

I leave it blank. and it only highlight the textbox with red box with no error message. I expect error messages on top of the form mentions all the field that are required to be filled that have not been filled.

davy_yg left a reply on Error Message Does Not Appears

I try it does not work. I still wonder why. I also updated my form.blade.php

davy_yg started a new conversation Error Message Does Not Appears

Hello,

I would like to know why the error does not appears in here.

PageController.php

public function saveapps(Request $request)
        {

        Validator::make($request->all(), [
        
            "cover_letter" => "required | max:500",
            "nama_lengkap" => "required",
            "jk" => "required",
            "tgl_lahir" => "required",
            "nomor_ponsel" => "required",
            "email" => "required",
            "alamat" => "required",
            "provinsi" => "required",
            "kota" => "required",
            "zip" => "required",
            "status" => "required",
            "tanggungan" => "required",
            "agama" => "required",
            "salary" => "required",
            "attachment" => "required",             
        ],
        [
            "cover_letter.max"=>'Maksimal 500 karakter',
        
        ]
        )->validate();
    
    $m = new ApplicationModel;
        $m->nama_lengkap  = $request->nama;
        $m->jk            = $request->jenis_kelamin;
        $m->tgl_lahir     = $request->tanggal_lahir;
        $m->nomor_ponsel  = $request->nohp;
        $m->email         = $request->email;
        $m->alamat        = $request->alamat;
        $m->provinsi      = $request->provinsi;
        $m->kota          = $request->kota;
        $m->zip           = $request->zip;
        $m->status        = $request->status;
        $m->tanggungan    = $request->jumlah_tanggungan;
        $m->agama         = $request->agama;
        $m->salary        = $request->salary;

        $namafile = date("YmdHis") . "_" .                                                                                  $request->file_attachment->getClientOriginalName();
        $request->file_attachment->move("CV", $namafile);

        $m->attachment    = $namafile;

        $m->cover_letter         = $request->cover_letter;

        $m->save();

    Session::flash('flash', 'Data anda sudah di simpan');

    return redirect()->back();

}

form.blade.php

@if ($errors->any())
          <div class="alert alert-danger">
              <ul>
                  @foreach ($errors->all() as $error)
                      <li>{{ $error }}</li>
                  @endforeach
              </ul>
          </div>
     @endif
           
      <h4 class="mb-3">Biodata</h4>

      @include('includes.flash')

      <!-- <form method="post" action="select.php"> -->
      <!-- <form class="needs-validation" novalidate method="post" action="select.php"> -->
    <form method="post" action="{{ Url('/saveapps') }}" enctype="multipart/form-data">
      <input type="hidden" name="_token" value="{{ csrf_token() }}"/>

        <div class="row">
          <div class="col-md-6 mb-3">
            <label for="name">Nama Lengkap</label>
            <input type="text" class="form-control" id="nama" placeholder="" value="" name="nama" required>
            <div class="invalid-feedback">
              Nama harus diisi
            </div>
          </div>
        </div>
          <div class="form-check form-check-inline">
              <label for="gender">Jenis Kelamin</label>
            <input class="form-check-input" type="radio" name="jenis_kelamin" id="jenis_kelamin" value="P">
            <label class="form-check-label" for="inlineRadio1">P</label>
          </div>
          <div class="form-check form-check-inline">
            <input class="form-check-input" type="radio" name="jenis_kelamin" id="jenis_kelamin" value="L">
            <label class="form-check-label" for="inlineRadio1">L</label>
          </div>
          <div class="col-md-6 mb-3">
            <label for="birthDate">Tanggal Lahir</label>
            <input type="date" class="form-control" id="tanggal_lahir" placeholder="" name="tanggal_lahir" value="" required>
            <div class="invalid-feedback">
              Tanggal lahir harus diisi
            </div>
          </div>

davy_yg left a reply on Import Mysql File Into Mysql Linux

Do you understand anything about vmware?

I would like to import *.sql file into vmware. If I want to change the setting of the shared folder to import file I must power off before I change it correct?

Will poweroff the particular vmware file will reset the whole file? since I have a working vmware file on progress.

davy_yg started a new conversation Import Mysql File Into Mysql Linux

This is linux:

mysql>

Can you import *.sql file into mysql linux ?

Or do I have to create the db, tables, and insert the data with the insert command
04 Jan
7 months ago

davy_yg left a reply on Cart

I appologize. It's a tutorial from udemy. I do not find the files.

davy_yg left a reply on Cart

What's the database format from the Cart::content(); ?

Do they have the default cart model template ?

davy_yg started a new conversation Cart

Hello,

I would like to know how to interpret this code:

$cartItems = Cart::content();

Any clue what the codes means?