public function destroy($id)
{
$image_gallery = ImageGallery::whereGalleryId($id)->get();
foreach($image_gallery as $image_galleries) {
ImageGallery::whereId($image_galleries->id)->delete();
}
$gallery = Gallery::findOrFail($id);
$gallery->delete();
return Redirect::action('admin\GalleryController@index')->with('success','User deleted successfully');
}
Selasa, 19 Desember 2017
Jumat, 15 Desember 2017
Cara mengambil data dengan kolom yang tidak kosong dan limit data yang di ambil (get data on db where data not null and get limit data ) laravel controller
$companies = Company::orderBy('created_at', 'desc')
->whereNotNull('name')
->paginate(3);
->whereNotNull('name')
->paginate(3);
radio button mengambil data di db checked (get value radio button edit)
@foreach($skalas as $i=>$skala)
<input name="skala" type="radio" <?php echo ($user_profile->id_skala == $skala->id)? 'checked' : ''; ?> value="{{ $skala->id }}"> {{ $skala->deskripsi }} <br>
@endforeach
http://localhost:8000/profil-dashboard
<input name="skala" type="radio" <?php echo ($user_profile->id_skala == $skala->id)? 'checked' : ''; ?> value="{{ $skala->id }}"> {{ $skala->deskripsi }} <br>
@endforeach
http://localhost:8000/profil-dashboard
Jumat, 08 Desember 2017
Cara Share Web Ke Sosial Media Facebook, Twitter, Google Plus, WA (How To Share Web To Social media Facebook, Twitter, Google Plus, WA) Laravel
Kalo Kalian Tampilan nya dengan sistem templating, maka simpan script ini di induk nya :
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<link rel="icon" href="/front/img/vavicon.png" type="image/x-icon">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i" rel="stylesheet">
<meta name="_token" content="{!! csrf_token() !!}"/>
<meta property="og:type" content="@yield('type')" />
<meta property="og:title" content="@yield('title')" />
<meta property="og:description" name="description" content="@yield('fb_description')" />
<meta property="og:image:url" content="@yield('image')" />
<meta property="og:image" content="@yield('image')" />
<meta property="og:url" content="@yield('url')" />
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="650" />
<meta property="og:image:height" content="366" />
<meta name="description" content="@yield('description')" />
<meta content="@yield('description')" itemprop="headline"/>
<meta name="thumbnailUrl" content="@yield('thumbs')" itemprop="thumbnailUrl" />
<meta property="og:site_name" content="CMYK" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image:title" content="@yield('titletwit')"/>
<meta name="twitter:description" content="@yield('description')" />
<meta name="twitter:image:src" content="@yield('imagetwit')" />
----------------------------------------------------------------------------------------------------------------
Terus untuk di blade nya di pasang script :
@section('type'){{"article"}}@stop
@section('title'){{str_replace(' ',' ',preg_replace('/\s+/',' ',substr(strip_tags(str_limit($berita->judul, 200, $end = '...')),0,160)))}}@stop
@section('isi_berita'){{str_replace(' ',' ',preg_replace('/\s+/',' ',substr(strip_tags(str_limit($berita->isi_berita, 1000, $end = '...')),0,160)))}}@stop
@if($berita->gambar)
@section('image:url'){{ url('images/berita/'.$berita->gambar) }}@stop
@endif
@if($berita->gambar)
@section('image'){{ url('images/berita/'.$berita->gambar) }}@stop
@endif
@section('fb_description'){{str_replace(' ',' ',preg_replace('/\s+/',' ',substr(strip_tags(str_limit($berita->isi_berita, 1000, $end = '...')),0,160)))}}@stop
@section('url'){{ request()->url() }}@stop
@section('titletwit'){{ $berita->judul }}@stop
@if($berita->gambar)
@section('image'){{ url('images/berita/'.$berita->gambar) }}@stop
@endif
@if($berita->gambar)
@section('thumbs'){{ url('images/berita/thumbs/'.$berita->gambar) }}@stop
@endif
@if($berita->gambar)
@section('imagetwit'){{ url('images/berita/'.$berita->gambar) }}@stop
@endif
---------------------------------------------------------------------------------------------------
Dan paling bawah di masukan script JS :
Dan paling bawah di masukan script JS :
@section('js')
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/id_ID/sdk.js#xfbml=1&version=v2.10&appId=1695128474132497';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
@endsection
--------------------------------------------------------------------------------------------------
Untuk pemanggilan di tampilannya bisa pakai ini :
<div class="post-footer">
<h5>Share this post:</h5>
<ul class="list-inline list-inline-xs">
<li>
<a href="javascript:window.open('https://www.facebook.com/sharer/sharer.php?u={{ request()->url() }}','Facebook Share','width=500,height=500')" class="fa fa-facebook">
</a>
</li>
<li>
<a href="javascript:window.open('https://plus.google.com/share?url={{ request()->url() }}','Google plus Share','width=500,height=500')" class="fa fa-google-plus">
</a>
</li>
<li>
<a href="javascript:window.open('https://twitter.com/intent/tweet?url={{ request()->url() }}','Twitter Share','width=500,height=500')" class="fa fa-twitter">
</a>
</li>
<li>
<a href="javascript:window.open('whatsapp://send?text={{ request()->url() }}','Whatsapp Share','width=500,height=500')" class="fa fa-whatsapp">
</a>
</li>
</ul>
</div>
http://fkum.uninus.ac.id/article-detail/4
Cara Delete File dari Berkas dan DB (Delete File On Storage and DB) Laravel
public function destroy(Request $request, $id)
{
$pimpinan_jurusan = PimpinanJurusan::where('id', $id)->firstOrFail();
// Delete file in storage
File::delete('images/pimpinan-jurusan/thumbs/'.$pimpinan_jurusan->file);
File::delete('images/pimpinan-jurusan/'.$pimpinan_jurusan->file);
$pimpinan_jurusans = PimpinanJurusan::where('id', $id)->firstOrFail();
$pimpinan_jurusans->delete();
return Redirect::action('admin\PimpinanJurusanController@index');
}
{
$pimpinan_jurusan = PimpinanJurusan::where('id', $id)->firstOrFail();
// Delete file in storage
File::delete('images/pimpinan-jurusan/thumbs/'.$pimpinan_jurusan->file);
File::delete('images/pimpinan-jurusan/'.$pimpinan_jurusan->file);
$pimpinan_jurusans = PimpinanJurusan::where('id', $id)->firstOrFail();
$pimpinan_jurusans->delete();
return Redirect::action('admin\PimpinanJurusanController@index');
}
Sabtu, 18 November 2017
Hitung Jumlah Pemilih Terbanyak (max), dan memecah array
$records = array(
array(
'id' => 21,
'first_name' => 'John',
'last_name' => 'Doe',
),
array(
'id' => 22,
'first_name' => 'Sally',
'last_name' => 'Smith',
),
array(
'id' => 23,
'first_name' => 'Jane',
'last_name' => 'Jones',
),
array(
'id' => 24,
'first_name' => 'Peter',
'last_name' => 'Doe',
)
);
// memecah array
$first_names = array_column($records, 'first_name', 'id');
// echo "<pre>";
// // print_r($first_names);
// print_r(max($first_names));
// // print_r($records);
// echo "</pre>";
// exit();
array(
'id' => 21,
'first_name' => 'John',
'last_name' => 'Doe',
),
array(
'id' => 22,
'first_name' => 'Sally',
'last_name' => 'Smith',
),
array(
'id' => 23,
'first_name' => 'Jane',
'last_name' => 'Jones',
),
array(
'id' => 24,
'first_name' => 'Peter',
'last_name' => 'Doe',
)
);
// memecah array
$first_names = array_column($records, 'first_name', 'id');
// echo "<pre>";
// // print_r($first_names);
// print_r(max($first_names));
// // print_r($records);
// echo "</pre>";
// exit();
Senin, 30 Oktober 2017
membuat pop up konfirmasi delete/hapus di laravel (pop up confirmation delete in laravel)
<td>
<a href='{{URL::action("admin\GalleryController@edit",array($gallery->id))}}'>edit</a>
<a href='{{URL::action("admin\GalleryController@show",array($gallery->id))}}'>show</a>
{{ Form::open(array(
'action'=>['admin\GalleryController@destroy', $gallery->id],
'method'=>'DELETE',
'id' => $gallery->id,
'style' => 'display:inline'
)) }}
<button class='btn btn-sm btn-danger delete-btn'
type='button'
data-judulbuku='{{$gallery->judul}}'
data-formid='{{$gallery->id}}'>
<i class='fa fa-times-circle'></i> Hapus
</button>
{{ Form::close() }}
<script>
$(".delete-btn").on("click", function (e) {
e.preventDefault();
var self = $(this);
var judul = $(this).attr("data-judulbuku");
var formid = $(this).attr("data-formid");
swal({
title: "HAPUS",
text: "Hapus Data Gallery Judul : "+judul+" ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Ya, Hapus !",
closeOnConfirm: true
},
function () {
$("#"+formid).submit();
});
});
</script>
</td>
<a href='{{URL::action("admin\GalleryController@edit",array($gallery->id))}}'>edit</a>
<a href='{{URL::action("admin\GalleryController@show",array($gallery->id))}}'>show</a>
{{ Form::open(array(
'action'=>['admin\GalleryController@destroy', $gallery->id],
'method'=>'DELETE',
'id' => $gallery->id,
'style' => 'display:inline'
)) }}
<button class='btn btn-sm btn-danger delete-btn'
type='button'
data-judulbuku='{{$gallery->judul}}'
data-formid='{{$gallery->id}}'>
<i class='fa fa-times-circle'></i> Hapus
</button>
{{ Form::close() }}
<script>
$(".delete-btn").on("click", function (e) {
e.preventDefault();
var self = $(this);
var judul = $(this).attr("data-judulbuku");
var formid = $(this).attr("data-formid");
swal({
title: "HAPUS",
text: "Hapus Data Gallery Judul : "+judul+" ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Ya, Hapus !",
closeOnConfirm: true
},
function () {
$("#"+formid).submit();
});
});
</script>
</td>
Minggu, 08 Oktober 2017
Error migrate string ( Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes)
Tambahkan script default string di file AppServiceProvider.php
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
Sabtu, 07 Oktober 2017
cara update php dan mysql di ubuntu (requirment laravel)
sudo apt-get install php-mbstring
sudo apt-get install php-xml
sudo apt-get install php7.1-mysql
Langganan:
Postingan (Atom)