اذهب إلى المحتوى

محمود سامي حسين

الأعضاء
  • المساهمات

    155
  • تاريخ الانضمام

  • تاريخ آخر زيارة

كل منشورات العضو محمود سامي حسين

  1. السلام عليكم ورحمة الله وبركاته أستخدم هذه الحزمة مسئولة عن عربة التسوق : https://packagist.org/packages/hardevine/shoppingcart وأستعمل livewire component . عند أستخدام مجال الأسم namespace use Cart; وهذا غير مذكور في توثيق الحزمة ؟ تظهر أخطاء بداخل الملف وذلك لعدم أستدعائة بالشكل الصحيح . ولذلك لا تعمل عربة التسوق . <!-- جزء ملف العرض --> <div class="row"> <ul class="product-list grid-products equal-container"> @foreach ($products as $product) <li class="col-lg-4 col-md-6 col-sm-6 col-xs-6 "> <div class="product product-style-3 equal-elem "> <div class="product-thumnail"> <a href="{{ route('products.details', ['slug' => $product->slug ]) }}" title="{{$product->name}}"> <figure><img src="{{ asset ('assets/images/products') }}/{{ $product->image }}" alt="{{$product->name}}"></figure> </a> </div> <div class="product-info"> <a href="{{ route('products.details', ['slug' => $product->slug ]) }}" class="product-name"><span>{{ $product->name }}</span></a> <div class="wrap-price"><span class="product-price">{{ $product->regular_price }}</span></div> <a href="#" class="btn add-to-cart" wire:click.prevent="store({{ $product->id }},{{ $product->name }},{{ $product->regular_price }})">Add To Cart</a> </div> </div> </li> @endforeach </ul> </div> <?php //مكون livewire namespace App\Http\Livewire; use App\Models\Product; use Livewire\Component; use Livewire\WithPagination; use Cart; class ShopComponent extends Component { public function store($product_id,$product_name,$product_price){ Cart::add($product_id,$product_name,1,$product_price)->associate('App\Models\Product'); session()->flash('success_message','Item added in Cart'); return redirect()->route('product.cart'); } use WithPagination; public function render() { $products = Product::paginate(12); return view('livewire.shop-component' ,['products'=> $products])->layout('layouts.base'); } }
  2. {{-- تسجيل الدخول للمدير والمستخدم العادي --}} @if(Route::has('login')) @auth{{-- في حال كان المستخدم مدير أو بخلاف ذلك --}} @if(Auth::user()->utype === "ADM" ) <li class="menu-item menu-item-has-children parent" > {{-- عرض أسم المستخدم --}} <a title="My Account" href="#">My Account({{Auth::user()->name}})<i class="fa fa-angle-down" aria-hidden="true"></i></a> <ul class="submenu curency" > <li class="menu-item" > <a title="Dashboard" href="{{ route('admin.dashboard')}}">Dashboard</a> </li> <li class="menu-item"> <a href="{{route('logout')}}" onclick="event.preventDefault(); document.getElementByid('logout-form').submit();">Logout</a> </li> <form id="logout-form" action="{{route('logout')}}" method="post"> @csrf </form> </ul> </li> @else <li class="menu-item menu-item-has-children parent" > {{-- عرض أسم المستخدم --}} <a title="My Account" href="#">My Account({{Auth::user()->name}})<i class="fa fa-angle-down" aria-hidden="true"></i></a> <ul class="submenu curency" > <li class="menu-item" > <a title="Dashboard" href="{{ route('user.dashboard')}}">Dashboard</a> </li> <li class="menu-item"> <a href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementByid('logout-form').submit(); ">Logout</a> </li> <form id="logout-form" action="{{ route('logout') }}" method="post"> @csrf </form> </ul> </li> @endif @else{{-- اذا لم يكن مخول اظهر روابط تسجيل الدخول والتسجيل --}} <li class="menu-item" ><a title="Register or Login" href="{{ route('login') }}">Login</a></li> <li class="menu-item" ><a title="Register or Login" href="{{ route('register') }}">Register</a></li> @endauth @endif
  3. <?php /*أريد شرح للدالة store ما معني Request $request فقط ؟ ما معني الكلمة request انا افهم ان اي دالة تقبل parameters في صورة متغيرات متحكم بسيط لارافيل */ namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; class PostController extends Controller { /** * Show the form to create a new blog post. * * @return \Illuminate\View\View */ public function create() { return view('post.create'); } /** * Store a new blog post. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // Validate and store the blog post... } }
  4. هل هناك ما أخطأت به في هذا المثال وهل هذا فقط هو مصطلح الPolymorphism ؟ <?php /* - Polymorphism أو الواجهات interfaces مصطلح في البرمجة كائنية التوجة بمعني متعدد الأوجة - مثال الريموت كنترول يقوم بنفس الوظيفة في كلا من التلفزيون والريسيفر - يتم التصريح عنة بأستخدام الكلمة المحجوزة interface - ويتم أستخدامة داخل الاصناف بأستخدام الكلمة المحجوزة implemnts */ /*بفرض أن لديك جهاز تليفزيون وريسيفر في منزلك و الواجهة تمثل الريموت كنترول */ interface remotecontrol{ //يمكن حذف هذه الطرق methods ولن يحدث اي خطأ public function channel_1(); public function channel_2(); public function channel_3(); public function channel_4(); public function power_on(); public function power_off(); } // الصنف الأول : ريموت الريسيفر class reciver_remote implements remotecontrol{ //لا يمكن حذف هذه الطرق لانه مصرح عنها في الواجهة والا سوف يحدث خطأ public function channel_1(){ echo "تم تغيير القناة بنجاح أنت تشاهد الأن القناة الأولي "; } public function channel_2(){ echo "تم تغيير القناة بنجاح أنت تشاهد الأن القناة الثانية "; } public function channel_3(){ echo "تم تغيير القناة بنجاح أنت تشاهد الأن القناة الثالثة "; } public function channel_4(){ echo "تم تغيير القناة بنجاح أنت تشاهد الأن القناة الرابعة "; } public function power_on(){ echo "تم تشغيل الرسيفر "; } public function power_off(){ echo "تم أغلاق الريسيفر"; } } // الصنف الثاني : ريموت التيلفزيون class tv_remote implements remotecontrol{ public function channel_1(){ echo "تم تغيير القناة بنجاح أنت تشاهد الأن القناة الأولي "; } public function channel_2(){ echo "تم تغيير القناة بنجاح أنت تشاهد الأن القناة الثانية "; } public function channel_3(){ echo "تم تغيير القناة بنجاح أنت تشاهد الأن القناة الثالثة "; } public function channel_4(){ echo "تم تغيير القناة بنجاح أنت تشاهد الأن القناة الرابعة "; } public function power_on(){ echo "تم تشغيل التيلفزيون "; } public function power_off(){ echo "تم أغلاق التيلفزيون"; } } # الأن للتصريح عن كائنات جديدة وتستطيع تعديلها كما تريد $reciver_remote = new reciver_remote(); $reciver_remote->channel_1(); $reciver_remote->channel_2(); $reciver_remote->channel_3(); $reciver_remote->channel_4(); $reciver_remote->power_on(); $reciver_remote->power_off(); $tv_remote = new tv_remote(); $tv_remote->channel_1(); $tv_remote->channel_2(); $tv_remote->channel_3(); $tv_remote->channel_4(); $tv_remote->power_on(); $tv_remote->power_off(); //لطباعة الكائنات var_dump($reciver_remote,$tv_remote);
  5. السام عليكم ورحمه الله وبركاتة . ما الفرق بين الأصناف المجردة والنهائية في لغة abstract & final php ؟ مرفق مثال للتوضيح يرجي شرح الفرق بالكود . <?php /* -الأصناف المجردة || الأصناف النهائية - abstract classes || final classes - مثال أختبار الأجهزة داخل مصنع أبل للتاكد من عملها بشكل جيد */ // أختبار الأجهزة داخل مصنع أبل مثلا abstract class appleFactory{ abstract public function test_memory(); abstract public function test_screan(); abstract public function test_sound(); } //أختبار جهاز أيفون 6 class iphone6 extends appleFactory{ public function test_memory(){ echo 'memory has been tested okey' . ":)"; } public function test_screan(){ echo 'screan has been tested okey' . ":)"; } public function test_sound(){ echo 'sound has been tested okey' . ":)"; } } // أختبار جهاز أيفون 7 class iphone7 extends appleFactory{ public function test_memory(){ echo 'memory has been tested okey' . ":)"; } public function test_screan(){ echo 'screan has been tested okey' . ":)"; } public function test_sound(){ echo 'sound has been tested okey' . ":)"; } } $iphon6 = new iphone6(); var_dump($iphone6); $iphon7 = new iphone7(); var_dump($iphone7); // أختبار الأجهزة داخل مصنع أبل مثلا final class appleFactory2{ final public function test_memory_1(); final public function test_screan_1(); final public function test_sound_1(); } //أختبار جهاز أيفون 12 class iphone12 extends appleFactory2{ public function test_memory_1(){ echo 'memory has been tested okey' . ":)"; } public function test_screan_1(){ echo 'screan has been tested okey' . ":)"; } public function test_sound_1(){ echo 'sound has been tested okey' . ":)"; } } // أختبار جهاز أيفون 8 class iphone8 extends appleFactory2{ public function test_memory_1(){ echo 'memory has been tested okey' . ":)"; } public function test_screan_1(){ echo 'screan has been tested okey' . ":)"; } public function test_sound_1(){ echo 'sound has been tested okey' . ":)"; } } $iphon12 = new iphone6(); var_dump($iphone12); $iphon8 = new iphone7(); var_dump($iphone8); ?>
  6. هل هناك كتب عربية في أنشاء أضافات وردبريس أم لا ؟ يرجي أرسال رابط له .
  7. عن البحث في معظم الوظائف المطلوبة علي موقع بعيد أجد ما يسمي بلارافيل نوفا وبالدخول الي الموقع الخاص بها أجد أنها لوحة تحكم السؤال هنا ما الخبرة البرمجية المطلوبة للتعامل مع لارافيل nova ؟
  8. ما عدد الصفحات التي يمكن رفعها عبر github pages لحساب مطور عادي وليس منظمة
  9. كيفية تنصيب حزمة GD Library extension واي حزمة أخري علي السيرفر الفعلي وليس المحلي .
  10. <?php //تطبيق أختصار الروابط الموجود علي قناه الاكادمية علي اليوتيوب //كود المتحكم namespace App\Http\Controllers; use App\Models\ShortLink; use Illuminate\Http\Request; class ShortLinkController extends Controller { public function index(){ $shortlinks = ShortLink::paginate(10); return view('short_links',compact('shortlinks')); } public function store(Request $request){ $request->validate([ 'link' => 'required | url | unique:short_links,link' ]); $data ['link'] = $request->link; $data ['code'] = \Illuminate\Support\Str::random(6); Shortlink::create($data); return redirect('/')->with('success','لقد تم أختصار الرابط بنجاح '); } public function show($code){ $row = ShortLink::where('code',$code)->firstOrFail(); $row->visits_count += 1 ; $row->save(); return redirect($row->link); } } //ملف العرض view <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="shortcut icon" type="image/x-icon" href="{{ asset('icon.png') }}" /> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <title>{{__('home_page.shortened_links')}}</title> <style> h1 { text-align: center} .card { direction: rtl} </style> </head> <body dir="rtl" > <div class="container"> <hr> <h1 class="text-center">{{__('home_page.shortened_links')}} </h1> <hr> <div class="card"> <div class="card-header"> <form action="{{ route('generate-shortenlink') }}" method="POST"> @csrf <div class="input-group mb-3"> <input type="text" class="form-control" placeholder="{{__('home_page.write_a_link')}}"> <div class="input-group-append"> <button class="btn btn-success">{{__('home_page.generate_shortened_link')}}</button> </div> </div> @if ($errors->has('link')) <span class="alert-danger"> <strong>{{$errors->first('link')}}</strong> </span> @endif </form> </div> <div class="card-body"> @if (session('success')) <div class="alert alert-success"> <p>{{session('success')}}</p> </div> @endif <table class="table"> <thead> <tr> <th>{{__('home_page.original_link')}}</th> <th>{{__('home_page.shortened_link')}}</th> <th>{{__('home_page.number_of_visits')}}</th> </tr> </thead> <tbody> @foreach ($shortlinks as $row) <tr> <td>{{ $row->link}}</td> <td><a href="{{ route('show-shorten-link' ,$row->code ) }}"> {{ url('') . '/' . $row->code }} </a></td> <td>{{ $row->visits_count }}</td> </tr> @endforeach </tbody> </table> <div class="d-flex justify-content-center"> {{ $shortlinks->links() }} </div> </div> </div> </div> </body> </html> <?php //المسارات use App\Http\Controllers\ShortLinkController; use Illuminate\Support\Facades\Route; /* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | */ Route::get('/', [ShortLinkController::class, 'index'] ); Route::post('/generate-shorten-link', [ShortLinkController::class, 'store'])->name('generate-shortenlink'); Route::get('/{code}', [ShortLinkController::class, 'show'])->name('show-shorten-link'); //ملف التهجير <?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateShortLinksTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('short_links', function (Blueprint $table) { $table->id(); $table->string('link'); $table->string('code'); $table->integer('visits_count')->default(0); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('short_links'); } } رابط المشروع علي جوجل درايف
  11. التخلص من خطأ أثناء التهجير عبر منصة هيروكو مرفق صورة للخطأ
  12. <div class="modal-body text-right"> <form> @csrf <div class="form-group"> <label for="recipient-name" class="col-form-label ">العملاء</label> <textarea class="form-control"></textarea> <table> <td>كل العملاء الذين تم أختيارهم من القائمة :عدد العملاء </td> <td> logic to count </td> </table> </div> <div class="form-group"> <label for="message-text" class="col-form-label ">نص الرسالة</label> <textarea class="form-control" name="message" id="message"></textarea> <table> <tr> <td id="remaining">الحروف المتبقية 160 حرف</td> </tr> <tr> <td id="messages">رسالة</td> </tr> </table> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">خروج</button> <button type="button" class="btn btn-primary">أرسال</button> </div> </form> </div> <script> $(document).ready(function(){ var $remaining = $('#remaining'), $messages = $remaining.next(); $('#message').keyup(function(){ var chars = this.value.length, messages = Math.ceil(chars / 160), remaining = messages * 160 - (chars % (messages * 160) || messages * 160); $remaining.text(remaining + 'الحروف المتبقية'); $messages.text(messages + 'رسالة'); }); }); </script>
  13. تم حلها في الكود المرفق التالي : https://www.tutorialrepublic.com/codelab.php?topic=faq&file=jquery-show-hide-div-using-select-box
  14. تم حلها في الكود المرفق التالي https://www.tutorialrepublic.com/codelab.php?topic=faq&file=jquery-show-hide-div-using-select-box
  15. السلام عليكم ورحمة الله وبركاته قمت بعمل اضافه سابقا تقوم بعمل un set لحقول ووكومرس وردبريس وتزيل الحقول الغير مرغوبه كما يريد المستخدم كما اري في معظم اضافات وردبريس السؤال هنا جميع اضافات وردبريس تحتوي علي ملف index.php هذا الملف يحتوي فقط علي عباره >php? // sillince is golden فقط تابعت العديد من الشروحات الاجنبيه لم اجد سوي انه يتم وضع هذا الملف فقط لانه معروف ان اي متصفح يقرا ملف index اولا ........... وبذلك يجبر مستخدم لو فتح اي ملف بدوم قصد ان يفتح هذا الملف هل هذا هو امان اضافات وردبريس فقط . حتي الاضافات الاساسية في وردبريس تحتوي علي هذا الملف ك hello dolly https://github.com/mahmoudsamyhosein/checkout_page_edit_By_mshm
  16. السلام عليكم ورحمة الله وبركاته، أريد ان يشرح لي أحد كود الحلقة باالرابط المرفق أظنه حل لسؤال سابق لي، فأنا اريد تنفيذ الكود الرئيسي للمشروع بـ PHP فقط بدون كتابة أكواد جافا سكربت لاني لا اعلم عنها شيئا في الوقت الحالي.
  17. خطأ برمجي لارافيل /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit() { return view('clients.edit'); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request ,Guest $guest, $id) { $guest= Guest::find($id); $guest->name = $request->name; $guest->guest_type = $request->guest_type; $guest->phone_of_work = $request->phone_of_work; $guest->approve_type = $request->approve_type; $guest->place_of_issue = $request->place_of_issue; $guest->date_of_birth = $request->date_of_birth; $guest->email = $request->email; $guest->category = $request->category; $guest->nationalty = $request->nationalty; $guest->id_copy = $request->id_copy; $guest->date_of_expiry = $request->date_of_expiry; $guest->kind = $request->kind; $guest->phone = $request->phone; $guest->place_of_work = $request->place_of_work; $guest->address = $request->address; $guest->note = $request->note; $guest->note_2 = $request->note_2; $guest->approve_number = $request->approve_number; $guest->save(); session()->flash('flash_message', 'تم نعديل العميل بنجاح'); return redirect(route('clients.index')); } //////////////////////////////////////////////////////////////
  18. ممكن التوضيح بالكود لست أفهم ؟ او هل تقصد ان ازيل التوابع من ملف العرض او الاحقة {{ (' clients.create')route }} ----الخ انا اعلم جافا سكربت لكن اريد تنفيذ المشروع بالاعتماد علي php فقط والا كنت أعتمدت علي حزمة jarabox datatable وهي لن تممكني من تعديل مظهر الجداول و ملف العرض فهي تستخدم ajax لذلك أو كنت أعتمدت علي تطبيقات laravel crud الموجودة علي كود كانيون مثلا ولن أكتب سطر برمجي واحد في المشروع .
  19. حتي أكون محددا في الصنف create ما هل يجب ان أمرر متغير أخر أم لا والصنف show وهو المتغير الذي يخزن قيمه التعديل او التحديث .
  20. سؤال بخصوص الدالة compact (). اذا كان لدي ملف عرض وحيد بالتابع index يتم فيه أجراء العمليات-------------------------------( عرض تعديل حذف أضافة - crud) ---------------------من خلال بوتستراب modal . وقمت بتمرير المتغير الي العرض view من خلال الدالة ----------------- compact (). هل يجب أن أقوم بتمريره الي التوابع الاخري edit و store و show ؟ وفي هذه الحالة يجب أن أمرر متغير الدالة الذي قمت بانشاءة في نفس التابع أم لا . مرفق ملف العرض والمتحكم . ClientController.php index.blade.php
  21. تم تطبيق المثال في هذا المقال حرفيا علي المشروع الذي أقوم بتنفيذة https://codeanddeploy.com/blog/laravel/laravel-8-crud-operation-tutorial-and-example-for-beginners#3sl0l0ONFnzsfTObF4gZRZg8g ومراجعه مقالات الاكاديمية لم تتناول هذ ا الmethod https://laravel.com/docs/5.1/validation#form-request-validation لا يتم تحديث بيانات العملاء او اضافه عميل جديد اريد معرفه الخطا الذي وقعت فقط . https://github.com/mahmoudsamyhosein/otel مسار العرض view clients/index المتحكم clientcontroller ملاحظه اذا قمت بتغيير الmethod المستخدم و استخدام request يعمل بصورة طبيعية ولا يوجد اي خطأ.
  22. في التوثيق الرسمي للارافيل لم يذكر كيفيه أستعمال التوابع الخاصة بالاقام سواء integer or float عند أنشاء البيانات الاختبارية وحتي موسوعة حسوب . ما التابع المستخدم لانشاء بيانات من نوع integer أو float . وما معني السطر المرفق في الصورة وكيف يقوم لارافيل بتشفير كلمة المرور في قاعدة البيانات . <?php namespace Database\Seeders; use App\Models\User; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use Illuminate\Support\Facades\Hash; class UserSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->insert([ 'first_name' => Str::random(10), 'last_name' => Str::random(30), 'hotel_name' => Str::random(20), //المفترض قيمة عددية بدلا من نصيه 'phone' => str::random(10), /////////////////////////////////////////// 'city' => Str::random(20), 'neighborhood' => Str::random(30), 'address' => Str::random(50), 'email' => Str::random(10) .'@gmail.com', 'password' => Hash::make('password'), ]); } 1-https://laravel.com/docs/8.x/seeding 2-https://wiki.hsoub.com/Laravel/seeding
  23. السلام عليكم ورحمه الله وبركاته أسهل لغة فعلا لتعلمها هي بايثون من ناحية السهولة لكن قاعدة البيانات ليست مقياس لبدء تعلمك لغة ام لا فاي اطار عمل مستخدم لبناء مواقع الويب كDjango المبني علي بايثون أو لغة بايثون يدعم قواعد البيانات التالية : 1-PostgreSQL 2-MariaDB 3-MySQL 4-Oracle 5-SQLite لكن بما أني أفضل لغة php وأطار عمل لارافيل فانصحك بها.
  24. ملف العرض : views/clients/index أسم المتحكم : ClientController في حالة انة قاعدة البيانات ليس بها حقول يعرض الخطأ التالي
×
×
  • أضف...